@univerjs/slides-ui 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/cjs/index.js +3 -3
  2. package/lib/es/index.js +781 -395
  3. package/lib/types/commands/operations/activate.operation.d.ts +1 -1
  4. package/lib/types/commands/operations/append-slide.operation.d.ts +5 -3
  5. package/lib/types/commands/operations/delete-element.operation.d.ts +1 -1
  6. package/lib/types/commands/operations/insert-image.operation.d.ts +1 -1
  7. package/lib/types/commands/operations/insert-shape.operation.d.ts +2 -1
  8. package/lib/types/commands/operations/insert-text.operation.d.ts +2 -1
  9. package/lib/types/commands/operations/set-thumb.operation.d.ts +3 -1
  10. package/lib/types/commands/operations/text-edit.operation.d.ts +0 -1
  11. package/lib/types/commands/operations/update-element.operation.d.ts +1 -1
  12. package/lib/types/components/image-popup-menu/ImagePopupMenu.d.ts +0 -1
  13. package/lib/types/components/panels/ArrangePanel.d.ts +1 -1
  14. package/lib/types/components/panels/FillPanel.d.ts +1 -1
  15. package/lib/types/components/panels/TransformPanel.d.ts +1 -1
  16. package/lib/types/components/sidebar/Sidebar.d.ts +0 -1
  17. package/lib/types/components/slide-bar/SlideBar.d.ts +0 -1
  18. package/lib/types/components/upload-component/UploadFile.d.ts +0 -1
  19. package/lib/types/components/upload-component/component-name.d.ts +1 -1
  20. package/lib/types/const.d.ts +16 -0
  21. package/lib/types/controllers/canvas-view.d.ts +22 -0
  22. package/lib/types/controllers/image.menu.d.ts +0 -1
  23. package/lib/types/controllers/popup-menu.controller.d.ts +1 -2
  24. package/lib/types/controllers/shape.menu.d.ts +0 -1
  25. package/lib/types/controllers/shortcuts/editor.shortcuts.d.ts +0 -1
  26. package/lib/types/controllers/shortcuts/utils.d.ts +0 -1
  27. package/lib/types/controllers/slide-editing.render-controller.d.ts +5 -20
  28. package/lib/types/controllers/slide-editor-bridge.render-controller.d.ts +6 -14
  29. package/lib/types/controllers/slide-ui.controller.d.ts +0 -1
  30. package/lib/types/controllers/slide.render-controller.d.ts +53 -8
  31. package/lib/types/controllers/text.menu.d.ts +0 -1
  32. package/lib/types/index.d.ts +9 -2
  33. package/lib/types/locale/en-US.d.ts +0 -1
  34. package/lib/types/locale/ru-RU.d.ts +0 -1
  35. package/lib/types/locale/vi-VN.d.ts +0 -1
  36. package/lib/types/locale/zh-TW.d.ts +0 -1
  37. package/lib/types/services/slide-editor-bridge.service.d.ts +10 -5
  38. package/lib/types/services/slide-editor-manager.service.d.ts +0 -1
  39. package/lib/types/services/slide-popup-manager.service.d.ts +1 -2
  40. package/lib/types/services/slide-render.service.d.ts +16 -0
  41. package/lib/types/slides-ui-plugin.d.ts +0 -1
  42. package/lib/types/type.d.ts +6 -0
  43. package/lib/types/views/editor-container/EditorContainer.d.ts +1 -2
  44. package/lib/umd/index.js +3 -3
  45. 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 { CommandType, IUniverInstanceService, UniverInstanceType, PageElementType, Tools, useDependency, LocaleService, ICommandService, generateRandomId, BasicShapes, createIdentifier, IContextService, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor, FOCUSING_UNIVER_EDITOR, EDITOR_ACTIVATED, FORMULA_EDITOR_ACTIVATED, Disposable, connectInjector, OnLifecycle, LifecycleStages, Inject, Injector, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, DocumentDataModel, VerticalAlign, HorizontalAlign, RxDisposable, DisposableCollection, toDisposable, FOCUSING_COMMON_DRAWINGS, WrapStrategy, FOCUSING_EDITOR_BUT_HIDDEN, FOCUSING_EDITOR_INPUT_FORMULA, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, Direction, IUndoRedoService, IResourceLoaderService, Plugin, mergeOverrideWithDependencies } from "@univerjs/core";
6
- import { ObjectType, FIX_ONE_PIXEL_BLUR_OFFSET, IRenderManagerService, DeviceInputEventType, pxToNum, ITextSelectionRenderManager, convertTextRotation, ScrollBar, fixLineWidthByScale, Rect } from "@univerjs/engine-render";
7
- import { ISidebarService, IEditorService, useObservable, DISABLE_AUTO_FOCUS_KEY, TextEditor, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, KeyCode, MetaKeys, BuiltInUIPart, ComponentManager, IMenuService, IUIPartsService, IShortcutService, ICanvasPopupService, ILayoutService } from "@univerjs/ui";
8
- import { CanvasView, SLIDE_KEY } from "@univerjs/slides";
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, TextSelectionManagerService, DocSkeletonManagerService, VIEWPORT_KEY, DOCS_COMPONENT_MAIN_LAYER_INDEX, RichTextEditingMutation, MoveSelectionOperation, MoveCursorOperation, DOCS_VIEW_KEY } from "@univerjs/docs";
14
- import { BehaviorSubject, Subject, filter } from "rxjs";
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(_a9) {
45
- var key = _a9[0], value = _a9[1];
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 _a9, defIds = runtimeProps.defIds;
52
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a9 = node.children) === null || _a9 === void 0) && _a9.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
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,325 @@ 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
+ constructor(_renderContext, _injector, _univerInstanceService, _renderManagerService) {
149
+ super();
150
+ __publicField(this, "_objectProvider", null);
151
+ __publicField(this, "_refreshThumb", debounce(() => {
152
+ this.createThumbs();
153
+ }, 300));
154
+ this._renderContext = _renderContext, this._injector = _injector, this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this._objectProvider = this._injector.createInstance(ObjectProvider), this._addNewRender();
155
+ }
156
+ _addNewRender() {
157
+ const { unitId, engine, scene } = this._renderContext, slideDataModel = this._getCurrUnitModel();
158
+ if (!slideDataModel) return;
159
+ const observer = engine.onTransformChange$.subscribeEvent(() => {
160
+ this._scrollToCenter(), observer == null || observer.unsubscribe();
161
+ });
162
+ engine.onTransformChange$.subscribeEvent(() => {
163
+ setTimeout(() => {
164
+ this.createThumbs();
165
+ }, 300);
166
+ });
167
+ const viewMain = new Viewport(SLIDE_KEY.VIEW, scene, {
168
+ left: 0,
169
+ top: 0,
170
+ bottom: 0,
171
+ right: 0,
172
+ isRelativeX: !0,
173
+ isRelativeY: !0,
174
+ isWheelPreventDefaultX: !0
175
+ });
176
+ scene.attachControl(), scene.onMouseWheel$.subscribeEvent((evt, state) => {
177
+ const e = evt;
178
+ if (e.ctrlKey) {
179
+ const deltaFactor = Math.abs(e.deltaX);
180
+ let scrollNum = deltaFactor < 40 ? 0.2 : deltaFactor < 80 ? 0.4 : 0.2;
181
+ 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());
182
+ } else
183
+ viewMain.onMouseWheel(e, state);
184
+ }), scene.onFileLoaded$.subscribeEvent(() => {
185
+ this._refreshThumb();
186
+ }), ScrollBar.attachTo(viewMain), this._renderManagerService.setCurrent(unitId);
187
+ const slide = this._createSlide(scene);
188
+ this._renderContext.mainComponent = slide, this._createSlidePages(slideDataModel, slide), this.createThumbs(), engine.runRenderLoop(() => {
189
+ scene.render();
190
+ });
191
+ }
192
+ _scrollToCenter() {
193
+ var _a11;
194
+ const mainScene = (_a11 = this._currentRender()) == null ? void 0 : _a11.scene, viewMain = mainScene == null ? void 0 : mainScene.getViewport(SLIDE_KEY.VIEW), getCenterPositionViewPort = this._getCenterPositionViewPort(mainScene);
195
+ if (!viewMain || !getCenterPositionViewPort) return;
196
+ const { left: viewPortLeft, top: viewPortTop } = getCenterPositionViewPort, { x, y } = viewMain.transViewportScroll2ScrollValue(viewPortLeft, viewPortTop);
197
+ viewMain.scrollToBarPos({
198
+ x,
199
+ y
200
+ });
201
+ }
202
+ _currentRender() {
203
+ return this._renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SLIDE);
204
+ }
205
+ /**
206
+ * @param mainScene
207
+ */
208
+ _createSlide(mainScene) {
209
+ 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, {
210
+ left: (sceneWidth - width) / 2,
211
+ top: (sceneHeight - height) / 2,
212
+ width,
213
+ height,
214
+ zIndex: 10
215
+ });
216
+ return slideComponent.enableSelectedClipElement(), mainScene.addObject(slideComponent), slideComponent;
217
+ }
218
+ _addBackgroundRect(scene, fill) {
219
+ const pageSize = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE).getPageSize(), { width: pageWidth = 0, height: pageHeight = 0 } = pageSize, page = new Rect("canvas", {
220
+ left: 0,
221
+ top: 0,
222
+ width: pageWidth,
223
+ height: pageHeight,
224
+ strokeWidth: 1,
225
+ stroke: "rgba(198,198,198,1)",
226
+ fill: getColorStyle(fill) || "rgba(255,255,255,1)",
227
+ zIndex: 0,
228
+ evented: !1
229
+ });
230
+ scene.addObject(page, 0);
231
+ }
232
+ _getCenterPositionViewPort(mainScene) {
233
+ if (!mainScene) return { left: 0, top: 0 };
234
+ const { width, height } = mainScene, engine = mainScene.getEngine(), canvasWidth = (engine == null ? void 0 : engine.width) || 0, canvasHeight = (engine == null ? void 0 : engine.height) || 0;
235
+ return {
236
+ left: (width - canvasWidth) / 2,
237
+ top: (height - canvasHeight) / 2
238
+ };
239
+ }
240
+ _thumbSceneRender(pageId, slide) {
241
+ const render2 = this._renderManagerService.getRenderById(pageId);
242
+ if (render2 == null)
243
+ return;
244
+ const { engine: thumbEngine } = render2;
245
+ if (thumbEngine == null)
246
+ return;
247
+ const { width, height } = slide, { width: pageWidth = width, height: pageHeight = height } = thumbEngine, thumbContext = thumbEngine.getCanvas().getContext();
248
+ slide.renderToThumb(thumbContext, pageId, pageWidth / width, pageHeight / height);
249
+ }
250
+ /**
251
+ * CreateScene by pages, and activate first one.
252
+ * @param slideDataModel
253
+ * @param slide
254
+ */
255
+ _createSlidePages(slideDataModel, slide) {
256
+ const pages = slideDataModel.getPages(), pageOrder = slideDataModel.getPageOrder();
257
+ if (!(!pages || !pageOrder) && pageOrder.length !== 0) {
258
+ for (let i = 0, len = pageOrder.length; i < len; i++) {
259
+ const pageId = pageOrder[i];
260
+ this.createPageScene(pageId, pages[pageId]), this._createThumb(pageId);
261
+ }
262
+ slide.activeFirstPage();
263
+ }
264
+ }
265
+ _createThumb(pageId) {
266
+ this._renderManagerService.createRender(pageId);
267
+ }
268
+ /**
269
+ * SlideDataModel is UnitModel
270
+ */
271
+ _getCurrUnitModel() {
272
+ return this._renderContext.unit;
273
+ }
274
+ activePage(_pageId) {
275
+ let pageId = _pageId;
276
+ const model = this._getCurrUnitModel();
277
+ let page;
278
+ if (pageId)
279
+ page = model.getPage(pageId);
280
+ else {
281
+ const pageElements = model.getPages(), pageOrder = model.getPageOrder();
282
+ if (pageOrder == null || pageElements == null)
283
+ return;
284
+ page = pageElements[pageOrder[0]], pageId = page.id;
285
+ }
286
+ const render2 = this._currentRender();
287
+ if (page == null || render2 == null || render2.mainComponent == null)
288
+ return;
289
+ const { id } = page, slide = render2.mainComponent;
290
+ if (model.setActivePage(page), slide != null && slide.hasPage(id)) {
291
+ slide.changePage(id);
292
+ return;
293
+ }
294
+ this.createPageScene(id, page);
295
+ }
296
+ createThumbs() {
297
+ const pageOrder = this._getCurrUnitModel().getPageOrder(), render2 = this._currentRender();
298
+ if (!(!pageOrder || !render2) && pageOrder.length !== 0)
299
+ for (let i = 0, len = pageOrder.length; i < len; i++) {
300
+ const pageId = pageOrder[i];
301
+ this._thumbSceneRender(pageId, render2.mainComponent);
302
+ }
303
+ }
304
+ /**
305
+ * Create scene by page and set to _sceneMap.
306
+ * @param pageId
307
+ * @param page
308
+ */
309
+ createPageScene(pageId, page) {
310
+ const render2 = this._renderContext;
311
+ if (!render2 || !this._objectProvider)
312
+ return;
313
+ const { scene: mainScene, mainComponent } = render2, slide = mainComponent, { width, height } = slide, pageScene = new Scene(pageId, slide, {
314
+ width,
315
+ height
316
+ });
317
+ new Viewport(`PageViewer_${pageId}`, pageScene, {
318
+ left: 0,
319
+ top: 0,
320
+ bottom: 0,
321
+ right: 0,
322
+ isRelativeX: !0,
323
+ isRelativeY: !0
324
+ }).closeClip();
325
+ const { pageElements, pageBackgroundFill } = page, objects = this._objectProvider.convertToRenderObjects(pageElements, mainScene);
326
+ if (!objects || !slide) return;
327
+ this._addBackgroundRect(pageScene, pageBackgroundFill), pageScene.addObjects(objects), pageScene.initTransformer(), objects.forEach((object) => {
328
+ pageScene.attachTransformerTo(object);
329
+ });
330
+ const transformer = pageScene.getTransformer();
331
+ return transformer == null || transformer.changeEnd$.subscribe(() => {
332
+ this._thumbSceneRender(pageId, slide);
333
+ }), transformer == null || transformer.clearControl$.subscribe(() => {
334
+ this._thumbSceneRender(pageId, slide);
335
+ }), slide.addPageScene(pageScene), pageScene;
336
+ }
337
+ /**
338
+ * Get pageScene from Slide.
339
+ * @param pageId
340
+ * @returns {Scene, Engine, UnitModel} scene & engine & unit from renderContext
341
+ */
342
+ getPageRenderUnit(pageId) {
343
+ const pageScene = this._renderContext.mainComponent.getSubScenes().get(pageId), { engine, unit } = this._renderContext;
344
+ return {
345
+ scene: pageScene,
346
+ engine,
347
+ unit
348
+ };
349
+ }
350
+ createObjectToPage(element2, pageID) {
351
+ const { scene } = this.getPageRenderUnit(pageID);
352
+ if (!scene || !this._objectProvider)
353
+ return;
354
+ const object = this._objectProvider.convertToRenderObject(element2, scene);
355
+ if (object)
356
+ return scene.addObject(object), scene.attachTransformerTo(object), scene.getLayer().makeDirty(), object;
357
+ }
358
+ setObjectActiveByPage(obj, pageID) {
359
+ const { scene } = this.getPageRenderUnit(pageID);
360
+ if (!scene) return;
361
+ const transformer = scene.getTransformer();
362
+ transformer == null || transformer.activeAnObject(obj);
363
+ }
364
+ removeObjectById(id, pageID) {
365
+ const { scene } = this.getPageRenderUnit(pageID);
366
+ if (!scene) return;
367
+ scene.removeObject(id);
368
+ const transformer = scene.getTransformer();
369
+ transformer == null || transformer.clearControls();
370
+ }
371
+ appendPage() {
372
+ const model = this._getCurrUnitModel(), page = model.getBlankPage(), render2 = this._currentRender();
373
+ if (page == null || render2 == null || render2.mainComponent == null)
374
+ return;
375
+ const { id: pageId } = page, slide = render2.mainComponent, scene = this.createPageScene(pageId, page);
376
+ slide && scene && slide.addPageScene(scene), model.appendPage(page), model.setActivePage(page);
377
+ }
378
+ }, __name(_a, "SlideRenderController"), _a);
379
+ SlideRenderController = __decorateClass$9([
380
+ __decorateParam$9(1, Inject(Injector)),
381
+ __decorateParam$9(2, IUniverInstanceService),
382
+ __decorateParam$9(3, IRenderManagerService)
383
+ ], SlideRenderController);
384
+ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
385
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
386
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
387
+ return kind && result && __defProp$8(target, key, result), result;
388
+ }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a2;
389
+ let CanvasView = (_a2 = class extends RxDisposable {
390
+ constructor(_renderManagerService) {
391
+ super(), this._renderManagerService = _renderManagerService;
392
+ }
393
+ _getSlideRenderControllerFromRenderUnit(unitId) {
394
+ return this._renderManagerService.getRenderById(unitId).with(SlideRenderController);
395
+ }
396
+ createThumbs(unitId) {
397
+ this._getSlideRenderControllerFromRenderUnit(unitId).createThumbs();
398
+ }
399
+ activePage(pageId, unitId) {
400
+ this._getSlideRenderControllerFromRenderUnit(unitId).activePage(pageId);
401
+ }
402
+ getRenderUnitByPageId(pageId, unitId) {
403
+ return this._getSlideRenderControllerFromRenderUnit(unitId).getPageRenderUnit(pageId);
404
+ }
405
+ createObjectToPage(element2, pageID, unitId) {
406
+ return this._getSlideRenderControllerFromRenderUnit(unitId).createObjectToPage(element2, pageID);
407
+ }
408
+ setObjectActiveByPage(obj, pageID, unitId) {
409
+ return this._getSlideRenderControllerFromRenderUnit(unitId).setObjectActiveByPage(obj, pageID);
410
+ }
411
+ removeObjectById(id, pageID, unitId) {
412
+ this._getSlideRenderControllerFromRenderUnit(unitId).removeObjectById(id, pageID);
413
+ }
414
+ /**
415
+ * append blank page
416
+ */
417
+ appendPage(unitId) {
418
+ this._getSlideRenderControllerFromRenderUnit(unitId).appendPage();
419
+ }
420
+ }, __name(_a2, "CanvasView"), _a2);
421
+ CanvasView = __decorateClass$8([
422
+ OnLifecycle(LifecycleStages.Ready, CanvasView),
423
+ __decorateParam$8(0, IRenderManagerService)
424
+ ], CanvasView);
142
425
  const ActivateSlidePageOperation = {
143
426
  id: "slide.operation.activate-slide",
144
427
  type: CommandType.OPERATION,
145
428
  handler: /* @__PURE__ */ __name((accessor, params) => {
146
- var _a9, _b;
147
- const canvasView = accessor.get(CanvasView), model = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), id = (_a9 = model == null ? void 0 : model.getActivePage()) == null ? void 0 : _a9.id;
148
- if (!id) return !1;
149
- const transformer = (_b = canvasView.getRenderUnitByPageId(id).scene) == null ? void 0 : _b.getTransformer();
150
- return transformer && transformer.clearControls(), canvasView.activePage(params.id), !0;
429
+ var _a11, _b;
430
+ 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;
431
+ if (!pageId) return !1;
432
+ const page = canvasView.getRenderUnitByPageId(pageId, unitId);
433
+ if (!page) return !1;
434
+ const transformer = (_b = page.scene) == null ? void 0 : _b.getTransformer();
435
+ return transformer && transformer.clearControls(), canvasView.activePage(params.id, unitId), !0;
151
436
  }, "handler")
152
437
  }, DeleteSlideElementOperation = {
153
438
  id: "slide.operation.delete-element",
154
439
  type: CommandType.OPERATION,
155
440
  handler: /* @__PURE__ */ __name((accessor, params) => {
156
441
  if (!(params != null && params.id)) return !1;
157
- const slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
442
+ const unitId = params.unitId, slideData = accessor.get(IUniverInstanceService).getUnit(unitId);
158
443
  if (!slideData) return !1;
159
444
  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;
445
+ return delete activePage.pageElements[params.id], slideData.updatePage(activePage.id, activePage), accessor.get(CanvasView).removeObjectById(params.id, activePage.id, unitId), !0;
161
446
  }, "handler")
162
447
  }, InsertSlideFloatImageOperation = {
163
448
  id: "slide.operation.insert-float-image",
164
449
  type: CommandType.OPERATION,
165
450
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
166
- var _a9;
451
+ var _a11;
167
452
  const imageIoService = accessor.get(IImageIoService);
168
- if (!((_a9 = params == null ? void 0 : params.files) != null && _a9.length)) return !1;
453
+ if (!((_a11 = params == null ? void 0 : params.files) != null && _a11.length)) return !1;
169
454
  const imageParam = await imageIoService.saveImage(params.files[0]);
170
455
  if (!imageParam) return !1;
171
- const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), data = {
456
+ const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), univerInstanceService = accessor.get(IUniverInstanceService), unitId = params.unitId, slideData = univerInstanceService.getUnit(unitId);
457
+ if (!slideData) return !1;
458
+ const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 20, data = {
172
459
  id: imageId,
173
- zIndex: 20,
460
+ zIndex: maxIndex + 1,
174
461
  left: 0,
175
462
  top: 0,
176
463
  width,
@@ -187,12 +474,10 @@ const ActivateSlidePageOperation = {
187
474
  image
188
475
  }
189
476
  }
190
- }, slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
191
- if (!slideData) return !1;
192
- const activePage = slideData.getActivePage();
477
+ };
193
478
  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;
479
+ const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(data, activePage.id, unitId);
480
+ return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
196
481
  }, "handler")
197
482
  };
198
483
  var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
@@ -223,7 +508,7 @@ const UpdateSlideElementOperation = {
223
508
  id: "slide.operation.update-element",
224
509
  type: CommandType.OPERATION,
225
510
  handler: /* @__PURE__ */ __name((accessor, params) => {
226
- const { oKey, props } = params, slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
511
+ const { oKey, props } = params, univerInstanceService = accessor.get(IUniverInstanceService), unitId = params == null ? void 0 : params.unitId, slideData = univerInstanceService.getUnit(unitId);
227
512
  if (!slideData) return !1;
228
513
  const activePage = slideData.getActivePage();
229
514
  return activePage.pageElements[oKey] = Tools.deepMerge(activePage.pageElements[oKey], props), slideData.updatePage(activePage.id, activePage), !0;
@@ -245,7 +530,7 @@ const UpdateSlideElementOperation = {
245
530
  slidePanelColorPicker
246
531
  };
247
532
  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;
533
+ 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
534
  if (!scene) return null;
250
535
  const transformer = scene.getTransformer();
251
536
  if (!transformer) return null;
@@ -260,6 +545,7 @@ function ArrangePanel$1(props) {
260
545
  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
546
  zIndex
262
547
  }), commandService.executeCommand(UpdateSlideElementOperation.id, {
548
+ unitId,
263
549
  oKey: object == null ? void 0 : object.oKey,
264
550
  props: {
265
551
  zIndex
@@ -312,7 +598,7 @@ function ArrangePanel$1(props) {
312
598
  }
313
599
  __name(ArrangePanel$1, "ArrangePanel$1");
314
600
  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;
601
+ 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
602
  if (!scene) return null;
317
603
  const transformer = scene.getTransformer();
318
604
  if (!transformer) return null;
@@ -346,6 +632,7 @@ function TransformPanel(props) {
346
632
  }, []);
347
633
  function handleWidthChange(val) {
348
634
  !val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
635
+ pageId,
349
636
  oKey: object.oKey,
350
637
  props: {
351
638
  width: val
@@ -355,6 +642,7 @@ function TransformPanel(props) {
355
642
  __name(handleWidthChange, "handleWidthChange");
356
643
  function handleHeightChange(val) {
357
644
  !val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
645
+ pageId,
358
646
  oKey: object.oKey,
359
647
  props: {
360
648
  height: val
@@ -364,6 +652,7 @@ function TransformPanel(props) {
364
652
  __name(handleHeightChange, "handleHeightChange");
365
653
  function handleXChange(val) {
366
654
  !val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
655
+ pageId,
367
656
  oKey: object.oKey,
368
657
  props: {
369
658
  left: val
@@ -373,6 +662,7 @@ function TransformPanel(props) {
373
662
  __name(handleXChange, "handleXChange");
374
663
  function handleYChange(val) {
375
664
  !val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
665
+ pageId,
376
666
  oKey: object.oKey,
377
667
  props: {
378
668
  right: val
@@ -382,6 +672,7 @@ function TransformPanel(props) {
382
672
  __name(handleYChange, "handleYChange");
383
673
  function handleChangeRotation(val) {
384
674
  !val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
675
+ pageId,
385
676
  oKey: object.oKey,
386
677
  props: {
387
678
  angle: val
@@ -476,18 +767,19 @@ function TransformPanel(props) {
476
767
  }
477
768
  __name(TransformPanel, "TransformPanel");
478
769
  function ArrangePanel(props) {
479
- var _a9, _b;
480
- const { unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(unitId), scene = page == null ? void 0 : page.scene;
770
+ var _a11, _b;
771
+ 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
772
  if (!scene) return null;
482
773
  const transformer = scene.getTransformer();
483
774
  if (!transformer) return null;
484
775
  const object = transformer.getSelectedObjectMap().values().next().value;
485
776
  if (!object) return null;
486
- const [color, setColor] = React.useState((_b = (_a9 = object.fill) == null ? void 0 : _a9.toString()) != null ? _b : "");
777
+ const [color, setColor] = React.useState((_b = (_a11 = object.fill) == null ? void 0 : _a11.toString()) != null ? _b : "");
487
778
  function handleChangeColor(color2) {
488
779
  object == null || object.setProps({
489
780
  fill: color2
490
781
  }), commandService.executeCommand(UpdateSlideElementOperation.id, {
782
+ unitId,
491
783
  oKey: object == null ? void 0 : object.oKey,
492
784
  props: {
493
785
  shape: {
@@ -546,26 +838,39 @@ const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "un
546
838
  imageCommonPanelInput
547
839
  }, COMPONENT_SLIDE_SIDEBAR = "COMPONENT_SLIDE_SIDEBAR";
548
840
  function RectSidebar() {
549
- var _a9, _b;
550
- const univerInstanceService = useDependency(IUniverInstanceService), canvasView = useDependency(CanvasView), currentSlide = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pageId = (_a9 = currentSlide == null ? void 0 : currentSlide.getActivePage()) == null ? void 0 : _a9.id;
841
+ var _a11, _b, _c;
842
+ 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
843
  if (!pageId) return null;
552
- const transformer = (_b = canvasView.getRenderUnitByPageId(pageId).scene) == null ? void 0 : _b.getTransformer();
844
+ const transformer = (_b = canvasView.getRenderUnitByPageId(pageId, pageId).scene) == null ? void 0 : _b.getTransformer();
553
845
  if (!transformer) return null;
554
846
  const object = transformer.getSelectedObjectMap().values().next().value;
555
- return object ? /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: styles$4.imageCommonPanel, children: [
556
- /* @__PURE__ */ jsxRuntimeExports.jsx(ArrangePanel$1, { unitId: pageId }),
557
- /* @__PURE__ */ jsxRuntimeExports.jsx(TransformPanel, { unitId: pageId }),
558
- object.objectType === ObjectType.RECT && /* @__PURE__ */ jsxRuntimeExports.jsx(ArrangePanel, { unitId: pageId })
559
- ] }) : null;
847
+ if (!object)
848
+ return null;
849
+ const unitId = ((_c = univerInstanceService.getFocusedUnit()) == null ? void 0 : _c.getUnitId()) || "";
850
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: styles$4.imageCommonPanel, children: [
851
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ArrangePanel$1, { pageId, unitId }),
852
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TransformPanel, { pageId, unitId }),
853
+ object.objectType === ObjectType.RECT && /* @__PURE__ */ jsxRuntimeExports.jsx(ArrangePanel, { pageId, unitId })
854
+ ] });
560
855
  }
561
856
  __name(RectSidebar, "RectSidebar");
562
- const InsertSlideShapeRectangleOperation = {
857
+ const InsertSlideShapeRectangleCommand = {
858
+ id: "slide.command.insert-float-shape",
859
+ type: CommandType.COMMAND,
860
+ handler: /* @__PURE__ */ __name(async (accessor) => {
861
+ var _a11;
862
+ const commandService = accessor.get(ICommandService), unitId = (_a11 = accessor.get(IUniverInstanceService).getFocusedUnit()) == null ? void 0 : _a11.getUnitId();
863
+ return commandService.executeCommand(InsertSlideShapeRectangleOperation.id, { unitId });
864
+ }, "handler")
865
+ }, InsertSlideShapeRectangleOperation = {
563
866
  id: "slide.operation.insert-float-shape",
564
867
  type: CommandType.OPERATION,
565
868
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
566
- const id = generateRandomId(6), data = {
869
+ const id = generateRandomId(6), univerInstanceService = accessor.get(IUniverInstanceService), unitId = params.unitId, slideData = univerInstanceService.getUnit(unitId);
870
+ if (!slideData) return !1;
871
+ const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 20, data = {
567
872
  id,
568
- zIndex: 20,
873
+ zIndex: maxIndex + 1,
569
874
  left: 378,
570
875
  top: 142,
571
876
  width: 250,
@@ -582,12 +887,10 @@ const InsertSlideShapeRectangleOperation = {
582
887
  }
583
888
  }
584
889
  }
585
- }, slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
586
- if (!slideData) return !1;
587
- const activePage = slideData.getActivePage();
890
+ };
588
891
  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;
892
+ const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(data, activePage.id, unitId);
893
+ return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
591
894
  }, "handler")
592
895
  }, ToggleSlideEditSidebarOperation = {
593
896
  id: "sidebar.operation.slide-shape",
@@ -603,13 +906,23 @@ const InsertSlideShapeRectangleOperation = {
603
906
  width: 360
604
907
  }) : sidebarService.close(), !0;
605
908
  }, "handler")
909
+ }, SlideAddTextCommand = {
910
+ id: "slide.command.add-text",
911
+ type: CommandType.COMMAND,
912
+ handler: /* @__PURE__ */ __name(async (accessor) => {
913
+ var _a11;
914
+ const commandService = accessor.get(ICommandService), unitId = (_a11 = accessor.get(IUniverInstanceService).getFocusedUnit()) == null ? void 0 : _a11.getUnitId();
915
+ return await commandService.executeCommand(SlideAddTextOperation.id, { unitId });
916
+ }, "handler")
606
917
  }, SlideAddTextOperation = {
607
918
  id: "slide.operation.add-text",
608
919
  type: CommandType.OPERATION,
609
920
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
610
- const elementId = Tools.generateRandomId(6), defaultWidth = 220, defaultheight = 40, left = 230, top = 142, textContent = (params == null ? void 0 : params.text) || "A New Text", elementData = {
921
+ 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);
922
+ if (!slideData) return !1;
923
+ const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 21, elementData = {
611
924
  id: elementId,
612
- zIndex: 2,
925
+ zIndex: maxIndex + 1,
613
926
  left,
614
927
  top,
615
928
  width: defaultWidth,
@@ -625,17 +938,15 @@ const InsertSlideShapeRectangleOperation = {
625
938
  },
626
939
  bl: 1
627
940
  }
628
- }, slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
629
- if (!slideData) return !1;
630
- const activePage = slideData.getActivePage();
941
+ };
631
942
  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;
943
+ const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(elementData, activePage.id, unitId);
944
+ return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
634
945
  }, "handler")
635
946
  }, SetSlidePageThumbOperation = {
636
947
  id: "slide.operation.set-slide-page-thumb",
637
948
  type: CommandType.OPERATION,
638
- handler: /* @__PURE__ */ __name((accessor) => (accessor.get(CanvasView).createThumbs(), !0), "handler")
949
+ handler: /* @__PURE__ */ __name((accessor, params) => (accessor.get(CanvasView).createThumbs(params.unitId), !0), "handler")
639
950
  }, SetTextEditArrowOperation = {
640
951
  id: "slide.operation.edit-arrow",
641
952
  type: CommandType.OPERATION,
@@ -649,8 +960,8 @@ const InsertSlideShapeRectangleOperation = {
649
960
  btnContainer,
650
961
  btnContainerExpand
651
962
  }, SlideImagePopupMenu = /* @__PURE__ */ __name((props) => {
652
- var _a9, _b;
653
- const menuItems = (_b = (_a9 = props.popup) == null ? void 0 : _a9.extraProps) == null ? void 0 : _b.menuItems;
963
+ var _a11, _b;
964
+ const menuItems = (_b = (_a11 = props.popup) == null ? void 0 : _a11.extraProps) == null ? void 0 : _b.menuItems;
654
965
  if (!menuItems)
655
966
  return null;
656
967
  const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [visible, setVisible] = useState(!1), [isHovered, setHovered] = useState(!1), handleMouseEnter = /* @__PURE__ */ __name(() => {
@@ -708,18 +1019,18 @@ const InsertSlideShapeRectangleOperation = {
708
1019
  }, "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
1020
  uploadFileMenu,
710
1021
  uploadFileMenuInput
711
- }, COMPONENT_UPLOAD_FILE_MENU = "COMPONENT_UPLOAD_FILE_MENU";
1022
+ }, COMPONENT_UPLOAD_FILE_MENU = "SLIDE_COMPONENT_UPLOAD_FILE_MENU";
712
1023
  var UploadFileType = /* @__PURE__ */ ((UploadFileType2) => (UploadFileType2[UploadFileType2.cellImage = 0] = "cellImage", UploadFileType2[UploadFileType2.floatImage = 1] = "floatImage", UploadFileType2))(UploadFileType || {});
713
1024
  const UploadFileMenu = /* @__PURE__ */ __name((props) => {
714
- const { type } = props, commandService = useDependency(ICommandService), fileInputRef = useRef(null), handleButtonClick = /* @__PURE__ */ __name(() => {
715
- var _a9;
716
- (_a9 = fileInputRef.current) == null || _a9.click();
1025
+ const { type } = props, commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), focused = useObservable(univerInstanceService.focused$), fileInputRef = useRef(null), handleButtonClick = /* @__PURE__ */ __name(() => {
1026
+ var _a11;
1027
+ (_a11 = fileInputRef.current) == null || _a11.click();
717
1028
  }, "handleButtonClick"), imageAccept = DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(","), handleFileChange = /* @__PURE__ */ __name((event) => {
718
1029
  const fileList = event.target.files;
719
1030
  if (fileList == null)
720
1031
  return;
721
1032
  const files = Array.from(fileList);
722
- type === UploadFileType.floatImage && commandService.executeCommand(InsertSlideFloatImageOperation.id, { files }), fileInputRef.current && (fileInputRef.current.value = "");
1033
+ type === UploadFileType.floatImage && commandService.executeCommand(InsertSlideFloatImageOperation.id, { files, unitId: focused }), fileInputRef.current && (fileInputRef.current.value = "");
723
1034
  }, "handleFileChange");
724
1035
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { onClick: handleButtonClick, className: styles$2.uploadFileMenu, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
725
1036
  "input",
@@ -770,7 +1081,7 @@ __name(_SlideEditorManagerService, "SlideEditorManagerService");
770
1081
  let SlideEditorManagerService = _SlideEditorManagerService;
771
1082
  const ISlideEditorManagerService = createIdentifier(
772
1083
  "univer.slide-editor-manager.service"
773
- ), slideEditorContainer = "univer-slide-editor-container", editorInput = "univer-editor-input", styles$1 = {
1084
+ ), SLIDE_EDITOR_ID = createInternalEditorID("SLIDE_EDITOR"), slideEditorContainer = "univer-slide-editor-container", editorInput = "univer-editor-input", styles$1 = {
774
1085
  slideEditorContainer,
775
1086
  editorInput
776
1087
  }, HIDDEN_EDITOR_POSITION$1 = -1e3, EDITOR_DEFAULT_POSITION = {
@@ -778,7 +1089,7 @@ const ISlideEditorManagerService = createIdentifier(
778
1089
  height: 0,
779
1090
  top: HIDDEN_EDITOR_POSITION$1,
780
1091
  left: HIDDEN_EDITOR_POSITION$1
781
- }, EditorContainer = /* @__PURE__ */ __name(() => {
1092
+ }, SlideEditorContainer = /* @__PURE__ */ __name(() => {
782
1093
  const [state, setState] = useState({
783
1094
  ...EDITOR_DEFAULT_POSITION
784
1095
  }), slideEditorManagerService = useDependency(ISlideEditorManagerService), editorService = useDependency(IEditorService), contextService = useDependency(IContextService), disableAutoFocus = useObservable(
@@ -787,7 +1098,7 @@ const ISlideEditorManagerService = createIdentifier(
787
1098
  void 0,
788
1099
  [contextService, DISABLE_AUTO_FOCUS_KEY]
789
1100
  ), snapshot = {
790
- id: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
1101
+ id: SLIDE_EDITOR_ID,
791
1102
  body: {
792
1103
  dataStream: `${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
793
1104
  textRuns: [],
@@ -823,7 +1134,7 @@ const ISlideEditorManagerService = createIdentifier(
823
1134
  left: startX + FIX_ONE_PIXEL_BLUR_OFFSET,
824
1135
  top: startY + FIX_ONE_PIXEL_BLUR_OFFSET
825
1136
  });
826
- const editor = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
1137
+ const editor = editorService.getEditor(SLIDE_EDITOR_ID);
827
1138
  if (editor == null)
828
1139
  return;
829
1140
  const { left, top, width, height } = editor.getBoundingClientRect();
@@ -845,7 +1156,7 @@ const ISlideEditorManagerService = createIdentifier(
845
1156
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
846
1157
  TextEditor,
847
1158
  {
848
- id: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
1159
+ id: SLIDE_EDITOR_ID,
849
1160
  className: styles$1.editorInput,
850
1161
  snapshot,
851
1162
  cancelDefaultResizeListener: !1,
@@ -855,12 +1166,12 @@ const ISlideEditorManagerService = createIdentifier(
855
1166
  )
856
1167
  }
857
1168
  );
858
- }, "EditorContainer"), AppendSlideOperation = {
1169
+ }, "SlideEditorContainer"), AppendSlideOperation = {
859
1170
  id: "slide.operation.append-slide",
860
1171
  type: CommandType.OPERATION,
861
- handler: /* @__PURE__ */ __name((accessor) => {
862
- const univerInstanceService = accessor.get(IUniverInstanceService), canvasView = accessor.get(CanvasView);
863
- return univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE) ? (canvasView.appendPage(), !0) : !1;
1172
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1173
+ const unitId = params.unitId;
1174
+ return accessor.get(IUniverInstanceService).getUnit(unitId) ? (accessor.get(CanvasView).appendPage(unitId), !0) : !1;
864
1175
  }, "handler")
865
1176
  }, 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
1177
  slideBar,
@@ -872,17 +1183,17 @@ const ISlideEditorManagerService = createIdentifier(
872
1183
  slideAddButton
873
1184
  };
874
1185
  function SlideSideBar() {
875
- var _a9, _b;
1186
+ var _a11, _b;
876
1187
  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
1188
  if (!pages || !pageOrder)
878
1189
  return null;
879
- const slideList = pageOrder.map((id) => pages[id]), [divRefs, setDivRefs] = useState([]), [activatePageId, setActivatePageId] = useState((_b = (_a9 = currentSlide == null ? void 0 : currentSlide.getActivePage()) == null ? void 0 : _a9.id) != null ? _b : null);
1190
+ 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
1191
  useEffect(() => {
881
1192
  setDivRefs(slideList.map((_) => React.createRef()));
882
1193
  }, [slideList.length]), useEffect(() => {
883
1194
  const subscriber = currentSlide == null ? void 0 : currentSlide.activePage$.subscribe((page) => {
884
- var _a10;
885
- const id = (_a10 = page == null ? void 0 : page.id) != null ? _a10 : null;
1195
+ var _a12;
1196
+ const id = (_a12 = page == null ? void 0 : page.id) != null ? _a12 : null;
886
1197
  id && setActivatePageId(id);
887
1198
  });
888
1199
  return () => {
@@ -890,18 +1201,18 @@ function SlideSideBar() {
890
1201
  };
891
1202
  }, []), useEffect(() => {
892
1203
  divRefs.forEach((ref, index) => {
893
- var _a10;
1204
+ var _a12;
894
1205
  if (ref.current) {
895
1206
  const slide = slideList[index];
896
- (_a10 = renderManagerService.getRenderById(slide.id)) == null || _a10.engine.setContainer(ref.current);
1207
+ (_a12 = renderManagerService.getRenderById(slide.id)) == null || _a12.engine.setContainer(ref.current);
897
1208
  }
898
- }), divRefs.length > 0 && commandService.syncExecuteCommand(SetSlidePageThumbOperation.id);
899
- }, [divRefs]);
1209
+ }), divRefs.length > 0 && commandService.syncExecuteCommand(SetSlidePageThumbOperation.id, { unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1210
+ }, [divRefs, slideList, renderManagerService, commandService, currentSlide]);
900
1211
  const activatePage = useCallback((page) => {
901
- commandService.syncExecuteCommand(ActivateSlidePageOperation.id, { id: page });
902
- }, [commandService]), handleAppendSlide = useCallback(() => {
903
- commandService.syncExecuteCommand(AppendSlideOperation.id);
904
- }, [commandService]);
1212
+ commandService.syncExecuteCommand(ActivateSlidePageOperation.id, { id: page, unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1213
+ }, [commandService, currentSlide]), handleAppendSlide = useCallback(() => {
1214
+ commandService.syncExecuteCommand(AppendSlideOperation.id, { unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1215
+ }, [commandService, currentSlide]);
905
1216
  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
1217
  /* @__PURE__ */ jsxRuntimeExports.jsx("header", { className: styles.slideBarContentHeader, children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: handleAppendSlide, children: localeService.t("slide.append") }) }),
907
1218
  slideList.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -967,7 +1278,7 @@ function SlideShapeMenuFactory(accessor) {
967
1278
  __name(SlideShapeMenuFactory, "SlideShapeMenuFactory");
968
1279
  function UploadSlideFloatShapeMenuFactory(_accessor) {
969
1280
  return {
970
- id: InsertSlideShapeRectangleOperation.id,
1281
+ id: InsertSlideShapeRectangleCommand.id,
971
1282
  title: "slide.shape.insert.rectangle",
972
1283
  type: MenuItemType.BUTTON,
973
1284
  positions: [SHAPE_MENU_ID],
@@ -1024,7 +1335,7 @@ const EditorDeleteLeftShortcut = {
1024
1335
  }, TEXT_ICON_ID = "text-single";
1025
1336
  function SlideAddTextMenuItemFactory(_accessor) {
1026
1337
  return {
1027
- id: SlideAddTextOperation.id,
1338
+ id: SlideAddTextCommand.id,
1028
1339
  group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
1029
1340
  type: MenuItemType.BUTTON,
1030
1341
  icon: TEXT_ICON_ID,
@@ -1038,8 +1349,8 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
1038
1349
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1039
1350
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1040
1351
  return kind && result && __defProp$7(target, key, result), result;
1041
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a;
1042
- let SlidesUIController = (_a = class extends Disposable {
1352
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a3;
1353
+ let SlidesUIController = (_a3 = class extends Disposable {
1043
1354
  constructor(_config, _injector, _menuService, _componentManager, _uiPartsService, _commandService, _shortcutService) {
1044
1355
  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
1356
  }
@@ -1066,7 +1377,9 @@ let SlidesUIController = (_a = class extends Disposable {
1066
1377
  SetSlidePageThumbOperation,
1067
1378
  InsertSlideFloatImageOperation,
1068
1379
  SlideAddTextOperation,
1380
+ SlideAddTextCommand,
1069
1381
  InsertSlideShapeRectangleOperation,
1382
+ InsertSlideShapeRectangleCommand,
1070
1383
  ToggleSlideEditSidebarOperation,
1071
1384
  DeleteSlideElementOperation,
1072
1385
  UpdateSlideElementOperation,
@@ -1078,7 +1391,7 @@ let SlidesUIController = (_a = class extends Disposable {
1078
1391
  this.disposeWithMe(
1079
1392
  this._uiPartsService.registerComponent(BuiltInUIPart.LEFT_SIDEBAR, () => connectInjector(SlideSideBar, this._injector))
1080
1393
  ), this.disposeWithMe(
1081
- this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(EditorContainer, this._injector))
1394
+ this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(SlideEditorContainer, this._injector))
1082
1395
  );
1083
1396
  }
1084
1397
  _initShortcuts() {
@@ -1089,7 +1402,7 @@ let SlidesUIController = (_a = class extends Disposable {
1089
1402
  this.disposeWithMe(this._shortcutService.registerShortcut(item));
1090
1403
  });
1091
1404
  }
1092
- }, __name(_a, "SlidesUIController"), _a);
1405
+ }, __name(_a3, "SlidesUIController"), _a3);
1093
1406
  SlidesUIController = __decorateClass$7([
1094
1407
  OnLifecycle(LifecycleStages.Ready, SlidesUIController),
1095
1408
  __decorateParam$7(1, Inject(Injector)),
@@ -1104,170 +1417,6 @@ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPrope
1104
1417
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1105
1418
  return kind && result && __defProp$6(target, key, result), result;
1106
1419
  }, "__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
1420
  function transformBound2OffsetBound(originBound, scene) {
1272
1421
  const topLeft = transformPosition2Offset(originBound.left, originBound.top, scene), bottomRight = transformPosition2Offset(originBound.right, originBound.bottom, scene);
1273
1422
  return {
@@ -1299,8 +1448,8 @@ let SlideCanvasPopMangerService = (_a4 = class extends Disposable {
1299
1448
  }
1300
1449
  _createObjectPositionObserver(targetObject, currentRender) {
1301
1450
  const position = (/* @__PURE__ */ __name(() => {
1302
- var _a9, _b, _c, _d;
1303
- const { scene, engine } = currentRender, { left, top, width, height } = targetObject, horizontalOffset = (scene.width - ((_b = (_a9 = currentRender.mainComponent) == null ? void 0 : _a9.width) != null ? _b : 0)) / 2, verticalOffset = (scene.height - ((_d = (_c = currentRender.mainComponent) == null ? void 0 : _c.height) != null ? _d : 0)) / 2, bound = {
1451
+ var _a11, _b, _c, _d;
1452
+ 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
1453
  left,
1305
1454
  right: left + width,
1306
1455
  top,
@@ -1331,7 +1480,8 @@ let SlideCanvasPopMangerService = (_a4 = class extends Disposable {
1331
1480
  unitId,
1332
1481
  subUnitId: "default",
1333
1482
  anchorRect: position,
1334
- anchorRect$: position$
1483
+ anchorRect$: position$,
1484
+ canvasElement: currentRender.engine.getCanvasElement()
1335
1485
  });
1336
1486
  return {
1337
1487
  dispose: /* @__PURE__ */ __name(() => {
@@ -1340,17 +1490,17 @@ let SlideCanvasPopMangerService = (_a4 = class extends Disposable {
1340
1490
  };
1341
1491
  }
1342
1492
  }, __name(_a4, "SlideCanvasPopMangerService"), _a4);
1343
- SlideCanvasPopMangerService = __decorateClass$4([
1344
- __decorateParam$4(0, Inject(ICanvasPopupService)),
1345
- __decorateParam$4(1, IRenderManagerService),
1346
- __decorateParam$4(2, IUniverInstanceService),
1347
- __decorateParam$4(3, ICommandService)
1493
+ SlideCanvasPopMangerService = __decorateClass$6([
1494
+ __decorateParam$6(0, Inject(ICanvasPopupService)),
1495
+ __decorateParam$6(1, IRenderManagerService),
1496
+ __decorateParam$6(2, IUniverInstanceService),
1497
+ __decorateParam$6(3, ICommandService)
1348
1498
  ], SlideCanvasPopMangerService);
1349
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1350
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1499
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1500
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1351
1501
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1352
- return kind && result && __defProp$3(target, key, result), result;
1353
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a5;
1502
+ return kind && result && __defProp$5(target, key, result), result;
1503
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a5;
1354
1504
  let SlidePopupMenuController = (_a5 = class extends RxDisposable {
1355
1505
  constructor(_canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _canvasView, _sidebarService, _commandService) {
1356
1506
  super();
@@ -1370,12 +1520,13 @@ let SlidePopupMenuController = (_a5 = class extends RxDisposable {
1370
1520
  }
1371
1521
  _hasCropObject(scene) {
1372
1522
  }
1523
+ // eslint-disable-next-line max-lines-per-function
1373
1524
  _popupMenuListener(unitId) {
1374
- var _a9;
1375
- const model = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = (_a9 = model == null ? void 0 : model.getPages()) != null ? _a9 : {};
1525
+ var _a11;
1526
+ const model = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = (_a11 = model == null ? void 0 : model.getPages()) != null ? _a11 : {};
1376
1527
  Object.keys(pages).forEach((pageId) => {
1377
- var _a10;
1378
- const transformer = (_a10 = this._canvasView.getRenderUnitByPageId(pageId).scene) == null ? void 0 : _a10.getTransformer();
1528
+ var _a12;
1529
+ const transformer = (_a12 = this._canvasView.getRenderUnitByPageId(pageId, unitId).scene) == null ? void 0 : _a12.getTransformer();
1379
1530
  if (!transformer) return;
1380
1531
  let singletonPopupDisposer;
1381
1532
  this.disposeWithMe(
@@ -1410,6 +1561,22 @@ let SlidePopupMenuController = (_a5 = class extends RxDisposable {
1410
1561
  ), this.disposeWithMe(
1411
1562
  transformer.changing$.subscribe(() => {
1412
1563
  singletonPopupDisposer == null || singletonPopupDisposer.dispose();
1564
+ const selectedObjects = transformer.getSelectedObjectMap();
1565
+ if (selectedObjects.size > 1) {
1566
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose();
1567
+ return;
1568
+ }
1569
+ const object = selectedObjects.values().next().value;
1570
+ object && this._commandService.executeCommand(UpdateSlideElementOperation.id, {
1571
+ unitId,
1572
+ oKey: object.oKey,
1573
+ props: {
1574
+ width: object.width,
1575
+ height: object.height,
1576
+ left: object.left,
1577
+ top: object.top
1578
+ }
1579
+ });
1413
1580
  })
1414
1581
  );
1415
1582
  });
@@ -1429,81 +1596,238 @@ let SlidePopupMenuController = (_a5 = class extends RxDisposable {
1429
1596
  index: 5,
1430
1597
  commandId: DeleteSlideElementOperation.id,
1431
1598
  commandParams: {
1432
- id: oKey
1599
+ id: oKey,
1600
+ unitId
1433
1601
  },
1434
1602
  disable: !1
1435
1603
  }];
1436
1604
  }
1437
1605
  }, __name(_a5, "SlidePopupMenuController"), _a5);
1438
- SlidePopupMenuController = __decorateClass$3([
1606
+ SlidePopupMenuController = __decorateClass$5([
1439
1607
  OnLifecycle(LifecycleStages.Steady, SlidePopupMenuController),
1440
- __decorateParam$3(0, Inject(SlideCanvasPopMangerService)),
1441
- __decorateParam$3(1, IRenderManagerService),
1442
- __decorateParam$3(2, IUniverInstanceService),
1443
- __decorateParam$3(3, IContextService),
1444
- __decorateParam$3(4, Inject(CanvasView)),
1445
- __decorateParam$3(5, ISidebarService),
1446
- __decorateParam$3(6, ICommandService)
1608
+ __decorateParam$5(0, Inject(SlideCanvasPopMangerService)),
1609
+ __decorateParam$5(1, IRenderManagerService),
1610
+ __decorateParam$5(2, IUniverInstanceService),
1611
+ __decorateParam$5(3, IContextService),
1612
+ __decorateParam$5(4, Inject(CanvasView)),
1613
+ __decorateParam$5(5, ISidebarService),
1614
+ __decorateParam$5(6, ICommandService)
1447
1615
  ], SlidePopupMenuController);
1448
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1449
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1616
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1617
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1450
1618
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1451
- return kind && result && __defProp$2(target, key, result), result;
1452
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a6;
1453
- let SlideEditorBridgeRenderController = (_a6 = class extends RxDisposable {
1454
- constructor(_renderContext, _contextService, _instanceSrv, _commandService, _editorBridgeService, _textSelectionManagerService, _textSelectionRenderManager, _canvasView) {
1619
+ return kind && result && __defProp$4(target, key, result), result;
1620
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
1621
+ const ISlideEditorBridgeService = createIdentifier("univer.slide-editor-bridge.service");
1622
+ var _a6;
1623
+ let SlideEditorBridgeService = (_a6 = class extends Disposable {
1624
+ constructor(_editorService, _contextService, _renderManagerService) {
1625
+ super();
1626
+ __publicField(this, "_editorUnitId", SLIDE_EDITOR_ID);
1627
+ __publicField(this, "_isForceKeepVisible", !1);
1628
+ __publicField(this, "_editorIsDirty", !1);
1629
+ __publicField(this, "_currentEditRectState", null);
1630
+ __publicField(this, "_currentEditRectState$", new BehaviorSubject(null));
1631
+ __publicField(this, "currentEditRectState$", this._currentEditRectState$.asObservable());
1632
+ __publicField(this, "_visibleParam", {
1633
+ visible: !1,
1634
+ eventType: DeviceInputEventType.Dblclick,
1635
+ unitId: ""
1636
+ });
1637
+ __publicField(this, "_visible$", new BehaviorSubject(this._visibleParam));
1638
+ __publicField(this, "visible$", this._visible$.asObservable());
1639
+ __publicField(this, "_afterVisible$", new BehaviorSubject(this._visibleParam));
1640
+ __publicField(this, "afterVisible$", this._afterVisible$.asObservable());
1641
+ __publicField(this, "endEditing$", new Subject());
1642
+ __publicField(this, "_currentEditRectInfo");
1643
+ this._editorService = _editorService, this._contextService = _contextService, this._renderManagerService = _renderManagerService;
1644
+ }
1645
+ dispose() {
1646
+ super.dispose();
1647
+ }
1648
+ getEditorRect() {
1649
+ return this._currentEditRectInfo;
1650
+ }
1651
+ /**
1652
+ * 1st part of startEditing.
1653
+ * @editorInfo editorInfo
1654
+ */
1655
+ setEditorRect(editorInfo) {
1656
+ 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));
1657
+ const editRectState = this.getEditRectState();
1658
+ this._currentEditRectState = editRectState, this._currentEditRectState$.next(editRectState);
1659
+ }
1660
+ changeVisible(param) {
1661
+ this._visibleParam = param, param.visible && (this._editorIsDirty = !1), this._visible$.next(this._visibleParam), this._afterVisible$.next(this._visibleParam);
1662
+ }
1663
+ /**
1664
+ * get info from _currentEditRectInfo
1665
+ *
1666
+ * invoked by slide-editing.render-controller.ts@_handleEditorVisible
1667
+ * && this@setEditorRect
1668
+ */
1669
+ getEditRectState() {
1670
+ const editorUnitId = SLIDE_EDITOR_ID, editorRectInfo = this._currentEditRectInfo, unitId = editorRectInfo.unitId, docData = editorRectInfo.richTextObj.documentData;
1671
+ docData.id = editorUnitId, docData.documentStyle = {
1672
+ ...docData.documentStyle,
1673
+ pageSize: { width: editorRectInfo.richTextObj.width, height: 1 / 0 }
1674
+ };
1675
+ const documentLayoutObject = {
1676
+ documentModel: new DocumentDataModel(docData),
1677
+ fontString: "document",
1678
+ textRotation: { a: 0, v: 0 },
1679
+ wrapStrategy: 0,
1680
+ verticalAlign: VerticalAlign.TOP,
1681
+ horizontalAlign: HorizontalAlign.LEFT,
1682
+ paddingData: { t: 0, b: 1, l: 2, r: 2 }
1683
+ }, editorWidth = editorRectInfo.richTextObj.width, editorHeight = editorRectInfo.richTextObj.height, left = editorRectInfo.richTextObj.left, top = editorRectInfo.richTextObj.top, canvasOffset = {
1684
+ left: 0,
1685
+ top: 0
1686
+ }, 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 = {
1687
+ x: (slideMainRect == null ? void 0 : slideMainRect.left) || 0,
1688
+ y: (slideMainRect == null ? void 0 : slideMainRect.top) || 0
1689
+ }, scrollX = (mainViewport == null ? void 0 : mainViewport.viewportScrollX) || 0, scrollY = (mainViewport == null ? void 0 : mainViewport.viewportScrollY) || 0;
1690
+ return canvasOffset.left = slidePos.x - scrollX, canvasOffset.top = slidePos.y - scrollY, {
1691
+ position: {
1692
+ startX: left,
1693
+ startY: top,
1694
+ endX: left + editorWidth,
1695
+ endY: top + editorHeight
1696
+ },
1697
+ scaleX: 1,
1698
+ scaleY: 1,
1699
+ slideCardOffset: canvasOffset,
1700
+ unitId,
1701
+ editorUnitId,
1702
+ documentLayoutObject
1703
+ };
1704
+ }
1705
+ changeEditorDirty(dirtyStatus) {
1706
+ this._editorIsDirty = dirtyStatus;
1707
+ }
1708
+ isVisible() {
1709
+ return this._visibleParam.visible;
1710
+ }
1711
+ getEditorDirty() {
1712
+ return this._editorIsDirty;
1713
+ }
1714
+ getCurrentEditorId() {
1715
+ return this._editorUnitId;
1716
+ }
1717
+ /**
1718
+ * @deprecated
1719
+ */
1720
+ genDocData(target) {
1721
+ const editorUnitId = this.getCurrentEditorId(), content = target.text, fontSize = target.fs;
1722
+ return {
1723
+ id: editorUnitId,
1724
+ body: {
1725
+ dataStream: `${content}\r
1726
+ `,
1727
+ textRuns: [{ st: 0, ed: content.length }],
1728
+ paragraphs: [{
1729
+ paragraphStyle: {
1730
+ // no use
1731
+ // textStyle: { fs: 30 },
1732
+ // horizontalAlign: HorizontalAlign.CENTER,
1733
+ // verticalAlign: VerticalAlign.MIDDLE,
1734
+ },
1735
+ startIndex: content.length + 1
1736
+ }],
1737
+ sectionBreaks: [{ startIndex: content.length + 2 }]
1738
+ },
1739
+ documentStyle: {
1740
+ marginBottom: 0,
1741
+ marginLeft: 0,
1742
+ marginRight: 0,
1743
+ marginTop: 0,
1744
+ pageSize: { width: 1 / 0, height: 1 / 0 },
1745
+ textStyle: { fs: fontSize },
1746
+ renderConfig: {
1747
+ // horizontalAlign: HorizontalAlign.CENTER,
1748
+ verticalAlign: VerticalAlign.MIDDLE,
1749
+ centerAngle: 0,
1750
+ vertexAngle: 0,
1751
+ wrapStrategy: 0
1752
+ }
1753
+ },
1754
+ drawings: {},
1755
+ drawingsOrder: [],
1756
+ settings: { zoomRatio: 1 }
1757
+ };
1758
+ }
1759
+ }, __name(_a6, "SlideEditorBridgeService"), _a6);
1760
+ SlideEditorBridgeService = __decorateClass$4([
1761
+ __decorateParam$4(0, IEditorService),
1762
+ __decorateParam$4(1, IContextService),
1763
+ __decorateParam$4(2, IRenderManagerService)
1764
+ ], SlideEditorBridgeService);
1765
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1766
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1767
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1768
+ return kind && result && __defProp$3(target, key, result), result;
1769
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a7;
1770
+ let SlideEditorBridgeRenderController = (_a7 = class extends RxDisposable {
1771
+ constructor(_renderContext, _instanceSrv, _commandService, _editorBridgeService) {
1455
1772
  super();
1456
1773
  /**
1457
1774
  * It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
1458
1775
  */
1459
- __publicField(this, "_cursorChange", 0);
1776
+ // private _cursorChange: CursorChange = CursorChange.InitialState;
1460
1777
  /** If the corresponding unit is active and prepared for editing. */
1461
- __publicField(this, "_isUnitEditing", !1);
1778
+ // private _isUnitEditing = false;
1462
1779
  __publicField(this, "setSlideTextEditor$", new Subject());
1463
1780
  __publicField(this, "_curRichText", null);
1464
- this._renderContext = _renderContext, this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._commandService = _commandService, this._editorBridgeService = _editorBridgeService, this._textSelectionManagerService = _textSelectionManagerService, this._textSelectionRenderManager = _textSelectionRenderManager, this._canvasView = _canvasView, Promise.resolve().then(() => this._init());
1781
+ __publicField(this, "_d");
1782
+ this._renderContext = _renderContext, this._instanceSrv = _instanceSrv, this._commandService = _commandService, this._editorBridgeService = _editorBridgeService, this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
1783
+ slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId ? this._d = this._init() : this._disposeCurrent();
1784
+ }));
1465
1785
  }
1466
1786
  _init() {
1467
1787
  const d = new DisposableCollection();
1468
- return this._initSubjectListener(d), this._initEventListener(d), d;
1788
+ return this._initEventListener(d), d;
1469
1789
  }
1470
- _initSubjectListener(d) {
1790
+ _disposeCurrent() {
1791
+ var _a11;
1792
+ (_a11 = this._d) == null || _a11.dispose(), this._d = null;
1471
1793
  }
1472
- _setEditorRect(targetObject) {
1794
+ _setEditorRect(pageId, targetObject) {
1473
1795
  this._curRichText = targetObject;
1474
1796
  const { scene, engine } = this._renderContext, unitId = this._renderContext.unitId, setEditorRect = {
1475
1797
  scene,
1476
1798
  engine,
1477
1799
  unitId,
1478
- pageId: "",
1800
+ pageId,
1479
1801
  richTextObj: targetObject
1480
1802
  };
1481
1803
  this._editorBridgeService.setEditorRect(setEditorRect);
1482
1804
  }
1483
1805
  _initEventListener(d) {
1484
- var _a9;
1485
- const model = this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pagesMap = (_a9 = model == null ? void 0 : model.getPages()) != null ? _a9 : {}, pages = Object.values(pagesMap);
1486
- for (let i = 0; i < pages.length; i++) {
1487
- const page = pages[i], { scene } = this._canvasView.getRenderUnitByPageId(page.id);
1488
- if (!scene) break;
1806
+ const listenersForPageScene = /* @__PURE__ */ __name((scene) => {
1489
1807
  const transformer = scene.getTransformer();
1490
- if (!transformer) break;
1491
- d.add(transformer.clearControl$.subscribe(() => {
1492
- this.setEditorVisible(!1);
1808
+ transformer && (d.add(transformer.clearControl$.subscribe(() => {
1809
+ this.setEditorVisible(!1), this.pickOtherObjects();
1493
1810
  })), d.add(transformer.createControl$.subscribe(() => {
1494
1811
  this.setEditorVisible(!1);
1495
- })), d.add(transformer.changeStart$.subscribe((param) => {
1496
- const target = param.target;
1497
- target && (target === this._curRichText || this.pickOtherObjects());
1498
1812
  })), d.add(scene.onDblclick$.subscribeEvent(() => {
1499
1813
  transformer.clearControls();
1500
1814
  const object = transformer.getSelectedObjectMap().values().next().value;
1501
- object && (object.objectType !== ObjectType.RICH_TEXT ? this.pickOtherObjects() : this.startEditing(object));
1502
- }));
1815
+ object && (object.objectType !== ObjectType.RICH_TEXT ? this.pickOtherObjects() : this.startEditing(scene.sceneKey, object));
1816
+ })), d.add(this._instanceSrv.focused$.subscribe((fc) => {
1817
+ this.endEditing();
1818
+ })));
1819
+ }, "listenersForPageScene"), { mainComponent } = this._renderContext;
1820
+ mainComponent.subSceneChanged$.subscribeEvent((pageScene) => {
1821
+ listenersForPageScene(pageScene);
1822
+ });
1823
+ const pageSceneList = Array.from(mainComponent.getSubScenes().values());
1824
+ for (let i = 0; i < pageSceneList.length; i++) {
1825
+ const pageScene = pageSceneList[i];
1826
+ listenersForPageScene(pageScene);
1503
1827
  }
1504
1828
  }
1505
1829
  pickOtherObjects() {
1506
- this.setEditorVisible(!1), this.endEditing();
1830
+ this.endEditing();
1507
1831
  }
1508
1832
  /**
1509
1833
  * invoked when picking other object.
@@ -1511,10 +1835,28 @@ let SlideEditorBridgeRenderController = (_a6 = class extends RxDisposable {
1511
1835
  * save editing state to curr richText.
1512
1836
  */
1513
1837
  endEditing() {
1838
+ var _a11;
1514
1839
  if (!this._curRichText) return;
1840
+ this.setEditorVisible(!1);
1515
1841
  const curRichText = this._curRichText;
1516
1842
  if (!this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE)) return !1;
1517
- curRichText.refreshDocumentByDocData(), curRichText.resizeToContentSize(), this._curRichText = null;
1843
+ curRichText.refreshDocumentByDocData(), curRichText.resizeToContentSize(), this._editorBridgeService.endEditing$.next(curRichText);
1844
+ const richText = {
1845
+ bl: 1,
1846
+ fs: curRichText.fs,
1847
+ text: curRichText.text
1848
+ }, textRuns = (_a11 = curRichText.documentData.body) == null ? void 0 : _a11.textRuns;
1849
+ if (textRuns && textRuns.length) {
1850
+ const ts = textRuns[0].ts;
1851
+ richText.cl = ts == null ? void 0 : ts.cl;
1852
+ }
1853
+ this._commandService.executeCommand(UpdateSlideElementOperation.id, {
1854
+ unitId: this._renderContext.unitId,
1855
+ oKey: curRichText == null ? void 0 : curRichText.oKey,
1856
+ props: {
1857
+ richText
1858
+ }
1859
+ }), this._curRichText = null;
1518
1860
  }
1519
1861
  /**
1520
1862
  * TODO calling twice ????
@@ -1523,55 +1865,59 @@ let SlideEditorBridgeRenderController = (_a6 = class extends RxDisposable {
1523
1865
  * TODO @lumixraku need scale param
1524
1866
  * @param target
1525
1867
  */
1526
- startEditing(target) {
1527
- this._setEditorRect(target), this.setEditorVisible(!0);
1868
+ startEditing(pageId, target) {
1869
+ this._setEditorRect(pageId, target), this.setEditorVisible(!0);
1528
1870
  }
1529
1871
  setEditorVisible(visible) {
1530
- var _a9, _b;
1531
- visible ? (_a9 = this._curRichText) == null || _a9.hide() : (_b = this._curRichText) == null || _b.show();
1872
+ var _a11, _b;
1873
+ visible ? (_a11 = this._curRichText) == null || _a11.hide() : (_b = this._curRichText) == null || _b.show();
1532
1874
  const { unitId } = this._renderContext;
1533
- this._editorBridgeService.changeVisible({ visible, eventType: 3, unitId });
1534
- }
1535
- }, __name(_a6, "SlideEditorBridgeRenderController"), _a6);
1536
- SlideEditorBridgeRenderController = __decorateClass$2([
1537
- __decorateParam$2(1, IContextService),
1538
- __decorateParam$2(2, IUniverInstanceService),
1539
- __decorateParam$2(3, ICommandService),
1540
- __decorateParam$2(4, Inject(ISlideEditorBridgeService)),
1541
- __decorateParam$2(5, Inject(TextSelectionManagerService)),
1542
- __decorateParam$2(6, ITextSelectionRenderManager),
1543
- __decorateParam$2(7, Inject(CanvasView))
1875
+ this._editorBridgeService.changeVisible({ visible, eventType: DeviceInputEventType.PointerDown, unitId });
1876
+ }
1877
+ }, __name(_a7, "SlideEditorBridgeRenderController"), _a7);
1878
+ SlideEditorBridgeRenderController = __decorateClass$3([
1879
+ __decorateParam$3(1, IUniverInstanceService),
1880
+ __decorateParam$3(2, ICommandService),
1881
+ __decorateParam$3(3, ISlideEditorBridgeService)
1544
1882
  ], SlideEditorBridgeRenderController);
1545
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1546
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1883
+ 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) => {
1884
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1547
1885
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1548
- return kind && result && __defProp$1(target, key, result), result;
1549
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
1886
+ return kind && result && __defProp$2(target, key, result), result;
1887
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
1550
1888
  const HIDDEN_EDITOR_POSITION = -1e3, EDITOR_INPUT_SELF_EXTEND_GAP = 5, EDITOR_BORDER_SIZE = 2;
1551
- var _a7;
1552
- let SlideEditingRenderController = (_a7 = class extends Disposable {
1553
- constructor(_renderContext, _layoutService, _undoRedoService, _contextService, _instanceSrv, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _textSelectionRenderManager, _textSelectionManagerService, _commandService, _localService, _editorService, _resourceLoaderService) {
1889
+ var _a8;
1890
+ let SlideEditingRenderController = (_a8 = class extends Disposable {
1891
+ constructor(_renderContext, _layoutService, _undoRedoService, _contextService, _instanceSrv, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _textSelectionRenderManager, _textSelectionManagerService, _commandService, _localService, _editorService) {
1554
1892
  super();
1555
1893
  /**
1556
1894
  * It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
1557
1895
  */
1558
- __publicField(this, "_cursorChange", 0);
1896
+ __publicField(this, "_cursorChange", CursorChange.InitialState);
1559
1897
  /** If the corresponding unit is active and prepared for editing. */
1560
1898
  __publicField(this, "_isUnitEditing", !1);
1561
- // private _workbookSelections: WorkbookSelections;
1562
1899
  __publicField(this, "_d");
1563
- this._renderContext = _renderContext, this._layoutService = _layoutService, this._undoRedoService = _undoRedoService, this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._editorBridgeService = _editorBridgeService, this._cellEditorManagerService = _cellEditorManagerService, this._textSelectionRenderManager = _textSelectionRenderManager, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, this._localService = _localService, this._editorService = _editorService, this._resourceLoaderService = _resourceLoaderService, this._d = this._init(), this._initEditorVisibilityListener();
1900
+ 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) => {
1901
+ slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId ? this._d = this._init() : (this._disposeCurrent(), this._isUnitEditing && (this._handleEditorInvisible({
1902
+ visible: !1,
1903
+ eventType: DeviceInputEventType.Keyboard,
1904
+ keycode: KeyCode.ESC,
1905
+ unitId: this._renderContext.unitId
1906
+ }), this._isUnitEditing = !1));
1907
+ })), this._initEditorVisibilityListener();
1564
1908
  }
1565
1909
  dispose() {
1566
1910
  super.dispose(), this._disposeCurrent();
1567
1911
  }
1568
1912
  _disposeCurrent() {
1569
- var _a9;
1570
- (_a9 = this._d) == null || _a9.dispose(), this._d = null;
1913
+ var _a11;
1914
+ (_a11 = this._d) == null || _a11.dispose(), this._d = null;
1571
1915
  }
1572
1916
  _init() {
1573
1917
  const d = new DisposableCollection();
1574
- return this._subscribeToCurrentCell(d), this._initialKeyboardListener(d), this._initialCursorSync(d), this._listenEditorFocus(d), this._commandExecutedListener(d), this._cursorStateListener(d), d;
1918
+ return this._subscribeToCurrentCell(d), this._initialKeyboardListener(d), this._initialCursorSync(d), this._listenEditorFocus(d), this._commandExecutedListener(d), setTimeout(() => {
1919
+ this._cursorStateListener(d);
1920
+ }, 1e3), d;
1575
1921
  }
1576
1922
  _initEditorVisibilityListener() {
1577
1923
  this.disposeWithMe(this._editorBridgeService.visible$.subscribe((param) => {
@@ -1584,12 +1930,12 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1584
1930
  }));
1585
1931
  }
1586
1932
  _getEditorSkeleton(editorId) {
1587
- var _a9;
1588
- return (_a9 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a9.with(DocSkeletonManagerService).getSkeleton();
1933
+ var _a11;
1934
+ return (_a11 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a11.with(DocSkeletonManagerService).getSkeleton();
1589
1935
  }
1590
1936
  _getEditorViewModel(editorId) {
1591
- var _a9;
1592
- return (_a9 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a9.with(DocSkeletonManagerService).getViewModel();
1937
+ var _a11;
1938
+ return (_a11 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a11.with(DocSkeletonManagerService).getViewModel();
1593
1939
  }
1594
1940
  _initialCursorSync(d) {
1595
1941
  d.add(this._cellEditorManagerService.focus$.pipe(filter((f2) => !!f2)).subscribe(() => {
@@ -1617,16 +1963,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1617
1963
  }));
1618
1964
  }
1619
1965
  /**
1620
- * set size and pos of editing area
1621
- * invoked by _handleEditorVisible
1622
- *
1623
- * size & pos derives from slide-editor-bridge.service.ts@getEditRectState.position
1624
- *
1625
- * set pos of editing area
1626
- * EditorContainer.tsx cellEditorManagerService.setFocus(true) -->
1627
- * _focus$.next --> editingRenderController -->
1628
- * _textSelectionRenderManager.sync() --> _updateInputPosition --> activate(left, top)
1629
- *
1966
+ * Set size and pos of editing area.
1630
1967
  * @param positionFromEditRectState
1631
1968
  * @param canvasOffset
1632
1969
  * @param documentSkeleton
@@ -1686,7 +2023,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1686
2023
  */
1687
2024
  // eslint-disable-next-line max-lines-per-function
1688
2025
  _editAreaProcessing(editorWidth, editorHeight, positionFromEditRectState, canvasOffset, fill, scaleX = 1, scaleY = 1) {
1689
- var _a9;
2026
+ var _a11;
1690
2027
  const editorObject = this._getEditorObject();
1691
2028
  if (editorObject == null)
1692
2029
  return;
@@ -1699,7 +2036,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1699
2036
  startX += canvasOffset.left, startY += canvasOffset.top;
1700
2037
  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
2038
  let physicHeight = editorHeight, scrollBar = viewportMain == null ? void 0 : viewportMain.getScrollBar();
1702
- physicHeight > clientHeight ? (physicHeight = clientHeight, scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { enableHorizontal: !1, barSize: 8 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll()) : (scrollBar = null, (_a9 = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _a9.dispose()), editorWidth += (scrollBar == null ? void 0 : scrollBar.barSize) || 0, editorWidth = Math.min(editorWidth, clientWidth), startX -= FIX_ONE_PIXEL_BLUR_OFFSET, startY -= FIX_ONE_PIXEL_BLUR_OFFSET, this._addBackground(editorScene, editorWidth / scaleX, editorHeight / scaleY, fill);
2039
+ 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
2040
  const { scaleX: precisionScaleX, scaleY: precisionScaleY } = editorScene.getPrecisionScale();
1704
2041
  editorScene.transformByState({
1705
2042
  width: editorWidth * scaleAdjust / scaleX,
@@ -1744,18 +2081,17 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1744
2081
  })));
1745
2082
  }
1746
2083
  /**
1747
- * show input area, resize input area and then place input to right place.
1748
- * invoked when this._editorBridgeService.visible$ param.visible = true
1749
- *
1750
- * handleVisible is the 2nd part of editing.
1751
- * startEditing --> _updateEditor
1752
- * startEditing --> changeVisible --> slide-editor-bridge.render-controller.ts@changeVisible --> _editorBridgeService.changeVisible
2084
+ * Show input area, resize input area and then place input to right place.
2085
+ * @TODO why do resize in show input area?
1753
2086
  * @param param
1754
2087
  */
2088
+ // handleVisible is the 2nd part of editing.
2089
+ // first part: startEditing --> _updateEditor
2090
+ // 2nd part: startEditing --> changeVisible --> slide-editor-bridge.render-controller.ts@changeVisible --> _editorBridgeService.changeVisible
1755
2091
  _handleEditorVisible(param) {
1756
- var _a9, _b;
1757
- const { eventType, keycode } = param;
1758
- this._cursorChange = [DeviceInputEventType.PointerDown, DeviceInputEventType.Dblclick].includes(eventType) ? 2 : 1;
2092
+ var _a11, _b;
2093
+ const { eventType } = param;
2094
+ this._cursorChange = [DeviceInputEventType.PointerDown, DeviceInputEventType.Dblclick].includes(eventType) ? CursorChange.CursorChange : CursorChange.StartEditor;
1759
2095
  const editCellState = this._editorBridgeService.getEditRectState();
1760
2096
  if (editCellState == null)
1761
2097
  return;
@@ -1777,7 +2113,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1777
2113
  return;
1778
2114
  this._fitTextSize(position, canvasOffset, skeleton, documentLayoutObject, scaleX, scaleY);
1779
2115
  const cursor = documentDataModel.getBody().dataStream.length - 2 || 0;
1780
- (_a9 = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN)) == null || _a9.scrollToViewportPos({
2116
+ (_a11 = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN)) == null || _a11.scrollToViewportPos({
1781
2117
  viewportScrollX: Number.POSITIVE_INFINITY
1782
2118
  }), this._textSelectionManagerService.replaceTextRanges([
1783
2119
  {
@@ -1806,12 +2142,12 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1806
2142
  _commandExecutedListener(d) {
1807
2143
  const moveCursorOP = [SetTextEditArrowOperation.id], editedMutations = [RichTextEditingMutation.id];
1808
2144
  d.add(this._commandService.onCommandExecuted((command) => {
1809
- moveCursorOP.includes(command.id) && this._moveCursorCmdHandler(command), editedMutations.includes(command.id) && this._editingChangedHandler();
2145
+ this._editorService.getFocusId() === SLIDE_EDITOR_ID && (moveCursorOP.includes(command.id) && this._moveCursorCmdHandler(command), editedMutations.includes(command.id) && this._editorBridgeService.isVisible() && this._editingChangedHandler());
1810
2146
  }));
1811
2147
  }
1812
2148
  _moveCursorCmdHandler(command) {
1813
2149
  const params = command.params, { keycode, isShift } = params;
1814
- keycode != null && this._cursorChange === 2 ? this._moveInEditor(keycode, isShift) : this._editorBridgeService.changeVisible(params);
2150
+ keycode != null && this._cursorChange === CursorChange.CursorChange ? this._moveInEditor(keycode, isShift) : this._editorBridgeService.changeVisible(params);
1815
2151
  }
1816
2152
  _editingChangedHandler() {
1817
2153
  const editRect = this._editorBridgeService.getEditorRect();
@@ -1832,7 +2168,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1832
2168
  }
1833
2169
  async _handleEditorInvisible(param) {
1834
2170
  const { keycode } = param;
1835
- if (this._setOpenForCurrent(null, null), this._cursorChange = 0, this._exitInput(param), this._editorBridgeService.getEditRectState() == null)
2171
+ if (this._setOpenForCurrent(null, null), this._cursorChange = CursorChange.InitialState, this._exitInput(param), this._editorBridgeService.getEditRectState() == null)
1836
2172
  return;
1837
2173
  if (this._editorBridgeService.getEditorDirty() === !1) {
1838
2174
  this._moveCursor(keycode);
@@ -1841,11 +2177,11 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1841
2177
  this._moveCursor(keycode);
1842
2178
  }
1843
2179
  _exitInput(param) {
1844
- this._contextService.setContextValue(FOCUSING_EDITOR_INPUT_FORMULA, !1), this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._contextService.setContextValue(FOCUSING_EDITOR_BUT_HIDDEN, !1), this._contextService.setContextValue(FORMULA_EDITOR_ACTIVATED, !1), this._cellEditorManagerService.setState({
2180
+ this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._cellEditorManagerService.setState({
1845
2181
  show: param.visible
1846
2182
  });
1847
2183
  const editorUnitId = this._editorBridgeService.getCurrentEditorId();
1848
- editorUnitId != null && (this._undoRedoService.clearUndoRedo(editorUnitId), this._undoRedoService.clearUndoRedo(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY));
2184
+ editorUnitId != null && this._undoRedoService.clearUndoRedo(editorUnitId);
1849
2185
  }
1850
2186
  _moveCursor(keycode) {
1851
2187
  if (keycode != null)
@@ -1877,7 +2213,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1877
2213
  _cursorStateListener(d) {
1878
2214
  const editorObject = this._getEditorObject(), { document: documentComponent } = editorObject;
1879
2215
  d.add(toDisposable(documentComponent.onPointerDown$.subscribeEvent(() => {
1880
- this._cursorChange === 1 && (this._cursorChange = 2);
2216
+ this._cursorChange === CursorChange.StartEditor && (this._cursorChange = CursorChange.CursorChange);
1881
2217
  })));
1882
2218
  }
1883
2219
  // TODO: @JOCS, is it necessary to move these commands MoveSelectionOperation\MoveCursorOperation to shortcut? and use multi-commands?
@@ -1889,21 +2225,20 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
1889
2225
  direction
1890
2226
  });
1891
2227
  }
1892
- }, __name(_a7, "SlideEditingRenderController"), _a7);
1893
- SlideEditingRenderController = __decorateClass$1([
1894
- __decorateParam$1(1, ILayoutService),
1895
- __decorateParam$1(2, IUndoRedoService),
1896
- __decorateParam$1(3, IContextService),
1897
- __decorateParam$1(4, IUniverInstanceService),
1898
- __decorateParam$1(5, IRenderManagerService),
1899
- __decorateParam$1(6, ISlideEditorBridgeService),
1900
- __decorateParam$1(7, ISlideEditorManagerService),
1901
- __decorateParam$1(8, ITextSelectionRenderManager),
1902
- __decorateParam$1(9, Inject(TextSelectionManagerService)),
1903
- __decorateParam$1(10, ICommandService),
1904
- __decorateParam$1(11, Inject(LocaleService)),
1905
- __decorateParam$1(12, IEditorService),
1906
- __decorateParam$1(13, IResourceLoaderService)
2228
+ }, __name(_a8, "SlideEditingRenderController"), _a8);
2229
+ SlideEditingRenderController = __decorateClass$2([
2230
+ __decorateParam$2(1, ILayoutService),
2231
+ __decorateParam$2(2, IUndoRedoService),
2232
+ __decorateParam$2(3, IContextService),
2233
+ __decorateParam$2(4, IUniverInstanceService),
2234
+ __decorateParam$2(5, IRenderManagerService),
2235
+ __decorateParam$2(6, ISlideEditorBridgeService),
2236
+ __decorateParam$2(7, ISlideEditorManagerService),
2237
+ __decorateParam$2(8, ITextSelectionRenderManager),
2238
+ __decorateParam$2(9, Inject(TextSelectionManagerService)),
2239
+ __decorateParam$2(10, ICommandService),
2240
+ __decorateParam$2(11, Inject(LocaleService)),
2241
+ __decorateParam$2(12, IEditorService)
1907
2242
  ], SlideEditingRenderController);
1908
2243
  function getEditorObject(unitId, renderManagerService) {
1909
2244
  if (unitId == null)
@@ -1920,19 +2255,56 @@ function getEditorObject(unitId, renderManagerService) {
1920
2255
  };
1921
2256
  }
1922
2257
  __name(getEditorObject, "getEditorObject");
2258
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2259
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2260
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2261
+ return kind && result && __defProp$1(target, key, result), result;
2262
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a9;
2263
+ let SlideRenderService = (_a9 = class extends RxDisposable {
2264
+ // private _skeletonChangeMutations = new Set<string>();
2265
+ constructor(_contextService, _instanceSrv, _renderManagerService) {
2266
+ super(), this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, Promise.resolve().then(() => this._init());
2267
+ }
2268
+ _init() {
2269
+ this._initSlideDataListener(), this._initContextListener();
2270
+ }
2271
+ _initSlideDataListener() {
2272
+ this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SLIDE).pipe(takeUntil(this.dispose$)).subscribe((slideModel) => {
2273
+ this._createRenderer(slideModel == null ? void 0 : slideModel.getUnitId());
2274
+ }), this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SLIDE).forEach((slideModel) => {
2275
+ this._createRenderer(slideModel.getUnitId());
2276
+ }), this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SLIDE).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._disposeRenderer(workbook));
2277
+ }
2278
+ _createRenderer(unitId) {
2279
+ unitId == null || this._instanceSrv.getUnit(unitId, UniverInstanceType.UNIVER_SLIDE) == null || (this._renderManagerService.createRender(unitId), this._renderManagerService.setCurrent(unitId));
2280
+ }
2281
+ _disposeRenderer(workbook) {
2282
+ const unitId = workbook.getUnitId();
2283
+ this._renderManagerService.removeRender(unitId);
2284
+ }
2285
+ _initContextListener() {
2286
+ }
2287
+ }, __name(_a9, "SlideRenderService"), _a9);
2288
+ SlideRenderService = __decorateClass$1([
2289
+ OnLifecycle(LifecycleStages.Ready, SlideRenderService),
2290
+ __decorateParam$1(0, IContextService),
2291
+ __decorateParam$1(1, IUniverInstanceService),
2292
+ __decorateParam$1(2, IRenderManagerService)
2293
+ ], SlideRenderService);
1923
2294
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1924
2295
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1925
2296
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1926
2297
  return kind && result && __defProp2(target, key, result), result;
1927
2298
  }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
1928
2299
  const SLIDE_UI_PLUGIN_NAME = "SLIDE_UI";
1929
- var _a8;
1930
- let UniverSlidesUIPlugin = (_a8 = class extends Plugin {
2300
+ var _a10;
2301
+ let UniverSlidesUIPlugin = (_a10 = class extends Plugin {
1931
2302
  constructor(_config = {}, _injector, _renderManagerService, _univerInstanceService) {
1932
2303
  super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService;
1933
2304
  }
1934
2305
  onStarting() {
1935
2306
  mergeOverrideWithDependencies([
2307
+ [SlideRenderService],
1936
2308
  [ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }],
1937
2309
  // used by SlideUIController --> EditorContainer
1938
2310
  [ISlideEditorManagerService, { useClass: SlideEditorManagerService }],
@@ -1940,23 +2312,28 @@ let UniverSlidesUIPlugin = (_a8 = class extends Plugin {
1940
2312
  ], this._config.override).forEach((d) => this._injector.add(d));
1941
2313
  }
1942
2314
  onReady() {
1943
- mergeOverrideWithDependencies([
2315
+ [
2316
+ // SlideRenderService will be init in ready stage, and then calling RenderManagerService@createRender --> init all deps in this rendering register block.
2317
+ [SlideRenderController]
2318
+ ].forEach((m2) => {
2319
+ this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SLIDE, m2));
2320
+ }), mergeOverrideWithDependencies([
2321
+ [CanvasView],
1944
2322
  // cannot register in _renderManagerService now.
1945
2323
  // [ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }],
1946
2324
  // // used by SlideUIController --> EditorContainer
1947
2325
  // [ISlideEditorManagerService, { useClass: SlideEditorManagerService }],
1948
- // This controller should be registered in Ready stage.
1949
- // this controller would add a new RenderUnit (__INTERNAL_EDITOR__DOCS_NORMAL)
1950
- // so this new RenderUnit does not have ISlideEditorBridgeService & ISlideEditorManagerService if
2326
+ // SlidesUIController controller should be registered in Ready stage.
2327
+ // SlidesUIController controller would add a new RenderUnit (__INTERNAL_EDITOR__DOCS_NORMAL)
1951
2328
  [SlidesUIController, {
1952
2329
  useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SlidesUIController, this._config), "useFactory")
1953
2330
  }],
1954
- // editor service were create in renderManagerService
2331
+ // editor service was create in renderManagerService
1955
2332
  [SlideRenderController],
1956
2333
  [SlidePopupMenuController]
1957
2334
  ], this._config.override).forEach((m2) => {
1958
2335
  this._injector.add(m2);
1959
- });
2336
+ }), this._injector.get(CanvasView);
1960
2337
  }
1961
2338
  onRendered() {
1962
2339
  [
@@ -1971,12 +2348,12 @@ let UniverSlidesUIPlugin = (_a8 = class extends Plugin {
1971
2348
  _markSlideAsFocused() {
1972
2349
  const currentService = this._univerInstanceService;
1973
2350
  try {
1974
- const slide = currentService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
1975
- currentService.focusUnit(slide.getUnitId());
2351
+ const slideDataModel = currentService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
2352
+ currentService.focusUnit(slideDataModel.getUnitId());
1976
2353
  } catch {
1977
2354
  }
1978
2355
  }
1979
- }, __name(_a8, "UniverSlidesUIPlugin"), __publicField(_a8, "pluginName", SLIDE_UI_PLUGIN_NAME), __publicField(_a8, "type", UniverInstanceType.UNIVER_SLIDE), _a8);
2356
+ }, __name(_a10, "UniverSlidesUIPlugin"), __publicField(_a10, "pluginName", SLIDE_UI_PLUGIN_NAME), __publicField(_a10, "type", UniverInstanceType.UNIVER_SLIDE), _a10);
1980
2357
  UniverSlidesUIPlugin = __decorateClass([
1981
2358
  __decorateParam(1, Inject(Injector)),
1982
2359
  __decorateParam(2, IRenderManagerService),
@@ -1985,13 +2362,22 @@ UniverSlidesUIPlugin = __decorateClass([
1985
2362
  export {
1986
2363
  ActivateSlidePageOperation,
1987
2364
  AppendSlideOperation,
1988
- EditorContainer,
2365
+ CanvasView,
2366
+ DeleteSlideElementOperation,
1989
2367
  IMAGE_MENU_ID,
2368
+ ISlideEditorBridgeService,
2369
+ InsertSlideFloatImageOperation,
2370
+ InsertSlideShapeRectangleCommand,
2371
+ InsertSlideShapeRectangleOperation,
1990
2372
  SHAPE_MENU_ID,
2373
+ SLIDE_EDITOR_ID,
1991
2374
  SetSlidePageThumbOperation,
2375
+ SlideAddTextCommand,
1992
2376
  SlideAddTextOperation,
1993
2377
  SlideCanvasPopMangerService,
2378
+ SlideEditorContainer,
1994
2379
  SlideSideBar,
1995
2380
  SlidesUIController,
1996
- UniverSlidesUIPlugin
2381
+ UniverSlidesUIPlugin,
2382
+ UpdateSlideElementOperation
1997
2383
  };