@univerjs/docs-drawing-ui 0.8.2-nightly.202506261607 → 0.8.3-nightly.202506271607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  var An = Object.defineProperty;
2
2
  var Pn = (i, e, t) => e in i ? An(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
3
  var ve = (i, e, t) => Pn(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommandType as q, ICommandService as j, IUniverInstanceService as z, TextX as _t, JSONX as $, MemoryCursor as xn, TextXActionType as Y, IUndoRedoService as Kt, BuildTextUtils as Nn, ArrangeTypeEnum as Ze, Tools as Me, Inject as Z, IContextService as Yt, LocaleService as lt, Disposable as Ne, WrapTextType as ze, PositionedObjectLayoutType as k, BooleanNumber as oe, DrawingTypeEnum as xe, ObjectRelativeFromV as W, ObjectRelativeFromH as J, FOCUSING_COMMON_DRAWINGS as nt, UniverInstanceType as we, Direction as he, DocumentFlavor as pt, DOCS_ZEN_EDITOR_UNIT_ID_KEY as St, FOCUSING_UNIVER_EDITOR as Un, UndoCommand as Ln, RedoCommand as Bn, DisposableCollection as Fn, toDisposable as Se, fromEventSubject as Zt, generateRandomId as kn, Injector as Qt, DOC_DRAWING_PRINTING_COMPONENT_KEY as Wn, throttle as Et, COLORS as Gn, RxDisposable as Hn, LifecycleService as jn, LifecycleStages as Rt, DependentOn as Vn, IConfigService as $n, Plugin as zn, merge as Xn } from "@univerjs/core";
4
+ import { CommandType as q, ICommandService as j, IUniverInstanceService as z, TextX as _t, JSONX as $, MemoryCursor as xn, TextXActionType as Y, IUndoRedoService as Kt, BuildTextUtils as Nn, ArrangeTypeEnum as Ze, Tools as Me, Inject as Z, IContextService as Yt, LocaleService as lt, Disposable as Ne, WrapTextType as ze, PositionedObjectLayoutType as k, BooleanNumber as oe, DrawingTypeEnum as xe, ObjectRelativeFromV as W, ObjectRelativeFromH as J, FOCUSING_COMMON_DRAWINGS as nt, UniverInstanceType as we, Direction as he, DisposableCollection as Un, toDisposable as Se, fromEventSubject as Zt, generateRandomId as Ln, DocumentFlavor as pt, DOCS_ZEN_EDITOR_UNIT_ID_KEY as St, FOCUSING_UNIVER_EDITOR as Bn, UndoCommand as Fn, RedoCommand as kn, Injector as Qt, DOC_DRAWING_PRINTING_COMPONENT_KEY as Wn, throttle as Et, COLORS as Gn, RxDisposable as Hn, LifecycleService as jn, LifecycleStages as Rt, DependentOn as Vn, IConfigService as $n, Plugin as zn, merge as Xn } from "@univerjs/core";
5
5
  import { IDocDrawingService as Ue, UniverDocsDrawingPlugin as qn } from "@univerjs/docs-drawing";
6
- import { IImageIoService as Kn, IDrawingManagerService as fe, DRAWING_IMAGE_ALLOW_IMAGE_LIST as Yn, DRAWING_IMAGE_COUNT_LIMIT as At, ImageUploadStatusType as mt, DRAWING_IMAGE_ALLOW_SIZE as Zn, getImageSize as Qn, getDrawingShapeKeyByDrawingSearch as Jn, DRAWING_IMAGE_WIDTH_LIMIT as Pt, DRAWING_IMAGE_HEIGHT_LIMIT as xt, UniverDrawingPlugin as er } from "@univerjs/drawing";
7
- import { DrawingCommonPanel as tr, DrawingRenderService as Jt, ImageCropperObject as nr, COMPONENT_IMAGE_POPUP_MENU as rr, OpenImageCropOperation as ir, ImageResetSizeOperation as or, UniverDrawingUIPlugin as sr } from "@univerjs/drawing-ui";
8
- import { IRenderManagerService as Q, DocumentEditArea as ke, getCurrentTypeOfRenderer as ar, CURSOR_TYPE as Nt, Liquid as en, PageLayoutType as Ut, DocumentSkeletonPageType as Lt, Vector2 as cr, Rect as dr, getColor as gr, TRANSFORM_CHANGE_OBSERVABLE_TYPE as lr } from "@univerjs/engine-render";
9
- import { IMessageService as ur, ILocalFileService as hr, ISidebarService as fr, useDependency as me, getMenuHiddenObservable as tn, MenuItemType as nn, RibbonInsertGroup as pr, KeyCode as We, ComponentManager as rn, IMenuManagerService as mr, IShortcutService as wr, CanvasFloatDomService as vr, PrintFloatDomSingle as Ir, connectInjector as _r, UniverUIPlugin as Sr } from "@univerjs/ui";
10
6
  import { RichTextEditingMutation as ee, DocSelectionManagerService as Dt, DocSkeletonManagerService as te } from "@univerjs/docs";
11
- import { DocSelectionRenderService as be, getRichTextEditPath as Xe, getCustomBlockIdsInSelections as Dr, docDrawingPositionToTransform as on, VIEWPORT_KEY as sn, SetDocZoomRatioOperation as an, DocPrintInterceptorService as Or, NodePositionConvertToCursor as Bt, getOneTextSelectionRange as Ft, getAnchorBounding as Tr, TEXT_RANGE_LAYER_INDEX as yr, getDocObject as Mr, DocCanvasPopManagerService as br, IEditorService as Cr } from "@univerjs/docs-ui";
12
- import { MessageType as kt, clsx as cn, InputNumber as Fe, Select as Wt, Checkbox as Er, RadioGroup as Gt, Radio as ye, render as Rr, unmount as Ar } from "@univerjs/design";
13
- import { BehaviorSubject as Ot, debounceTime as dn, Observable as Pr, map as Ht, switchMap as xr, of as Nr, takeUntil as jt, filter as Vt } from "rxjs";
7
+ import { DocSelectionRenderService as be, getRichTextEditPath as Xe, getCustomBlockIdsInSelections as Kn, docDrawingPositionToTransform as Jt, VIEWPORT_KEY as en, SetDocZoomRatioOperation as tn, DocPrintInterceptorService as Yn, NodePositionConvertToCursor as At, getOneTextSelectionRange as Pt, getAnchorBounding as Zn, TEXT_RANGE_LAYER_INDEX as Qn, getDocObject as Jn, DocCanvasPopManagerService as er, IEditorService as tr } from "@univerjs/docs-ui";
8
+ import { IRenderManagerService as Q, DocumentEditArea as ke, getCurrentTypeOfRenderer as nr, CURSOR_TYPE as xt, Liquid as nn, PageLayoutType as Nt, DocumentSkeletonPageType as Ut, Vector2 as rr, Rect as ir, getColor as or, TRANSFORM_CHANGE_OBSERVABLE_TYPE as sr } from "@univerjs/engine-render";
9
+ import { MessageType as Lt, clsx as rn, InputNumber as Fe, Select as Bt, Checkbox as ar, RadioGroup as Ft, Radio as ye, render as cr, unmount as dr } from "@univerjs/design";
10
+ import { IImageIoService as gr, IDrawingManagerService as fe, DRAWING_IMAGE_ALLOW_IMAGE_LIST as lr, DRAWING_IMAGE_COUNT_LIMIT as kt, ImageUploadStatusType as mt, DRAWING_IMAGE_ALLOW_SIZE as ur, getImageSize as hr, getDrawingShapeKeyByDrawingSearch as fr, DRAWING_IMAGE_WIDTH_LIMIT as Wt, DRAWING_IMAGE_HEIGHT_LIMIT as Gt, UniverDrawingPlugin as pr } from "@univerjs/drawing";
11
+ import { IMessageService as mr, ILocalFileService as wr, ISidebarService as vr, CanvasFloatDomService as Ir, useDependency as me, getMenuHiddenObservable as on, MenuItemType as sn, RibbonInsertGroup as _r, KeyCode as We, ComponentManager as an, IMenuManagerService as Sr, IShortcutService as Dr, PrintFloatDomSingle as Or, connectInjector as Tr, UniverUIPlugin as yr } from "@univerjs/ui";
12
+ import { BehaviorSubject as Ot, debounceTime as cn, map as Ht, switchMap as Mr, of as br, Observable as Cr, takeUntil as jt, filter as Vt } from "rxjs";
13
+ import { DrawingRenderService as dn, DrawingCommonPanel as Er, ImageCropperObject as Rr, COMPONENT_IMAGE_POPUP_MENU as Ar, OpenImageCropOperation as Pr, ImageResetSizeOperation as xr, UniverDrawingUIPlugin as Nr } from "@univerjs/drawing-ui";
14
14
  import { jsxs as X, jsx as y } from "react/jsx-runtime";
15
15
  import { useState as ie, useEffect as Tt, useMemo as Ur } from "react";
16
- const Lr = "docs-drawing-ui.config", $t = {}, yt = {
16
+ const yt = {
17
17
  id: "doc.command.remove-doc-image",
18
18
  type: q.COMMAND,
19
19
  // eslint-disable-next-line max-lines-per-function
@@ -116,7 +116,7 @@ const Lr = "docs-drawing-ui.config", $t = {}, yt = {
116
116
  else {
117
117
  const v = Nn.selection.delete([o], l, 0, null, !1);
118
118
  f.push(...v);
119
- const N = Dr(l, [o]), G = (L = s.getDrawings()) != null ? L : {}, x = (R = s.getDrawingsOrder()) != null ? R : [], H = N.sort((I, _) => x.indexOf(I) > x.indexOf(_) ? -1 : x.indexOf(I) < x.indexOf(_) ? 1 : 0);
119
+ const N = Kn(l, [o]), G = (L = s.getDrawings()) != null ? L : {}, x = (R = s.getDrawingsOrder()) != null ? R : [], H = N.sort((I, _) => x.indexOf(I) > x.indexOf(_) ? -1 : x.indexOf(I) < x.indexOf(_) ? 1 : 0);
120
120
  if (H.length > 0)
121
121
  for (const I of H) {
122
122
  const _ = G[I], E = x.indexOf(I);
@@ -206,8 +206,8 @@ class ut {
206
206
  this._refreshDrawings$.next(e);
207
207
  }
208
208
  }
209
- var Br = Object.getOwnPropertyDescriptor, Fr = (i, e, t, n) => {
210
- for (var r = n > 1 ? void 0 : n ? Br(e, t) : e, o = i.length - 1, s; o >= 0; o--)
209
+ var Lr = Object.getOwnPropertyDescriptor, Br = (i, e, t, n) => {
210
+ for (var r = n > 1 ? void 0 : n ? Lr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
211
211
  (s = i[o]) && (r = s(r) || r);
212
212
  return r;
213
213
  }, le = (i, e) => (t, n) => e(t, n, i);
@@ -218,11 +218,11 @@ let rt = class extends Ne {
218
218
  async insertDocImage() {
219
219
  const i = await this._fileOpenerService.openFile({
220
220
  multiple: !0,
221
- accept: Yn.map((t) => `.${t.replace("image/", "")}`).join(",")
221
+ accept: lr.map((t) => `.${t.replace("image/", "")}`).join(",")
222
222
  }), e = i.length;
223
- return e > At ? (this._messageService.show({
224
- type: kt.Error,
225
- content: this._localeService.t("update-status.exceedMaxCount", String(At))
223
+ return e > kt ? (this._messageService.show({
224
+ type: Lt.Error,
225
+ content: this._localeService.t("update-status.exceedMaxCount", String(kt))
226
226
  }), !1) : e === 0 ? !1 : (await this._insertFloatImages(i), !0);
227
227
  }
228
228
  // eslint-disable-next-line max-lines-per-function
@@ -235,7 +235,7 @@ let rt = class extends Ne {
235
235
  let s = "";
236
236
  switch (o) {
237
237
  case mt.ERROR_EXCEED_SIZE:
238
- s = this._localeService.t("update-status.exceedMaxSize", String(Zn / (1024 * 1024)));
238
+ s = this._localeService.t("update-status.exceedMaxSize", String(ur / (1024 * 1024)));
239
239
  break;
240
240
  case mt.ERROR_IMAGE_TYPE:
241
241
  s = this._localeService.t("update-status.invalidImageType");
@@ -245,7 +245,7 @@ let rt = class extends Ne {
245
245
  break;
246
246
  }
247
247
  this._messageService.show({
248
- type: kt.Error,
248
+ type: Lt.Error,
249
249
  content: s
250
250
  });
251
251
  }
@@ -255,11 +255,11 @@ let rt = class extends Ne {
255
255
  for (const r of e) {
256
256
  if (r == null)
257
257
  continue;
258
- const { imageId: o, imageSourceType: s, source: c, base64Cache: d } = r, { width: a, height: g, image: u } = await Qn(d || "");
258
+ const { imageId: o, imageSourceType: s, source: c, base64Cache: d } = r, { width: a, height: g, image: u } = await hr(d || "");
259
259
  this._imageIoService.addImageSourceCache(o, s, u);
260
260
  let l = 1;
261
- if (a > Pt || g > xt) {
262
- const p = Pt / a, w = xt / g;
261
+ if (a > Wt || g > Gt) {
262
+ const p = Wt / a, w = Gt / g;
263
263
  l = Math.min(p, w);
264
264
  }
265
265
  const f = this._getImagePosition(a * l, g * l);
@@ -272,7 +272,7 @@ let rt = class extends Ne {
272
272
  drawingType: xe.DRAWING_IMAGE,
273
273
  imageSourceType: s,
274
274
  source: c,
275
- transform: on(f),
275
+ transform: Jt(f),
276
276
  docTransform: f,
277
277
  behindDoc: oe.FALSE,
278
278
  title: "",
@@ -345,7 +345,7 @@ let rt = class extends Ne {
345
345
  _transformDrawingListener() {
346
346
  const i = this._getCurrentSceneAndTransformer();
347
347
  if (i && i.transformer)
348
- this.disposeWithMe(i.transformer.changeEnd$.pipe(dn(30)).subscribe((e) => {
348
+ this.disposeWithMe(i.transformer.changeEnd$.pipe(cn(30)).subscribe((e) => {
349
349
  this._docSelectionManagerService.refreshSelection();
350
350
  }));
351
351
  else
@@ -393,7 +393,7 @@ let rt = class extends Ne {
393
393
  return;
394
394
  const r = i.getSnapshot(), { drawings: o = {} } = r, s = n.getEditArea() === ke.BODY;
395
395
  for (const d of Object.keys(o)) {
396
- const a = o[d], g = Jn({ unitId: t, drawingId: a.drawingId, subUnitId: t }), u = e.fuzzyMathObjects(g, !0);
396
+ const a = o[d], g = fr({ unitId: t, drawingId: a.drawingId, subUnitId: t }), u = e.fuzzyMathObjects(g, !0);
397
397
  if (u.length)
398
398
  for (const l of u) {
399
399
  e.detachTransformerFrom(l);
@@ -439,19 +439,19 @@ let rt = class extends Ne {
439
439
  this._docSelectionManagerService.replaceDocRanges(n);
440
440
  }
441
441
  };
442
- rt = Fr([
442
+ rt = Br([
443
443
  le(1, j),
444
444
  le(2, Z(Dt)),
445
445
  le(3, Q),
446
- le(4, Kn),
446
+ le(4, gr),
447
447
  le(5, Ue),
448
448
  le(6, fe),
449
449
  le(7, Yt),
450
- le(8, ur),
450
+ le(8, mr),
451
451
  le(9, Z(lt)),
452
452
  le(10, Z(be)),
453
453
  le(11, Z(ut)),
454
- le(12, hr)
454
+ le(12, wr)
455
455
  ], rt);
456
456
  const fn = {
457
457
  id: "doc.command.insert-float-image",
@@ -459,11 +459,11 @@ const fn = {
459
459
  handler: (i) => {
460
460
  var n, r;
461
461
  const e = i.get(z), t = i.get(Q);
462
- return (r = (n = ar(we.UNIVER_DOC, e, t)) == null ? void 0 : n.with(rt).insertDocImage()) != null ? r : !1;
462
+ return (r = (n = nr(we.UNIVER_DOC, e, t)) == null ? void 0 : n.with(rt).insertDocImage()) != null ? r : !1;
463
463
  }
464
464
  };
465
465
  var ue = /* @__PURE__ */ ((i) => (i.INLINE = "inline", i.BEHIND_TEXT = "behindText", i.IN_FRONT_OF_TEXT = "inFrontOfText", i.WRAP_SQUARE = "wrapSquare", i.WRAP_TOP_AND_BOTTOM = "wrapTopAndBottom", i))(ue || {});
466
- const kr = {
466
+ const Fr = {
467
467
  inline: k.INLINE,
468
468
  wrapSquare: k.WRAP_SQUARE,
469
469
  wrapTopAndBottom: k.WRAP_TOP_AND_BOTTOM,
@@ -560,7 +560,7 @@ const mn = {
560
560
  return !1;
561
561
  const f = g.getEditArea(), h = u.getTransformerByCreate(), { pages: m, skeHeaders: p, skeFooters: w } = a, D = $.getInstance(), S = [], { drawings: O = {} } = l.getSnapshot();
562
562
  for (const R of t) {
563
- const { drawingId: v } = R, N = O[v].layoutType, G = kr[n];
563
+ const { drawingId: v } = R, N = O[v].layoutType, G = Fr[n];
564
564
  if (N !== G) {
565
565
  const _ = D.replaceOp(["drawings", v, "layoutType"], N, G);
566
566
  S.push(_);
@@ -850,7 +850,7 @@ const mn = {
850
850
  });
851
851
  return u.refreshControls(), !!h;
852
852
  }
853
- }, Wr = {
853
+ }, kr = {
854
854
  id: "doc.operation.clear-drawing-transformer",
855
855
  type: q.MUTATION,
856
856
  handler: (i, e) => {
@@ -864,7 +864,7 @@ const mn = {
864
864
  id: "sidebar.operation.doc-image",
865
865
  type: q.COMMAND,
866
866
  handler: async (i, e) => {
867
- const t = i.get(fr), n = i.get(lt), r = i.get(fe);
867
+ const t = i.get(vr), n = i.get(lt), r = i.get(fe);
868
868
  switch (e.value) {
869
869
  case "open":
870
870
  t.open({
@@ -890,7 +890,225 @@ const mn = {
890
890
  const t = i.get(fe), n = i.get(j);
891
891
  return e == null ? !1 : (t.focusDrawing([e]), n.executeCommand(Dn.id, { value: "open" }), !0);
892
892
  }
893
- }, zt = -1e3, Xt = 1e3, Gr = (i) => {
893
+ };
894
+ var Wr = Object.getOwnPropertyDescriptor, Gr = (i, e, t, n) => {
895
+ for (var r = n > 1 ? void 0 : n ? Wr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
896
+ (s = i[o]) && (r = s(r) || r);
897
+ return r;
898
+ }, Be = (i, e) => (t, n) => e(t, n, i);
899
+ function Tn(i, e, t = 1, n = 0) {
900
+ const { top: r, left: o, bottom: s, right: c } = i, d = c - o, a = s - r, g = e.getViewport(en.VIEW_MAIN), { viewportScrollX: u, viewportScrollY: l } = g, { scaleX: f, scaleY: h } = e.getAncestorScale();
901
+ return {
902
+ startX: (o - u) * f,
903
+ startY: (r - l) * h,
904
+ endX: (o + d - u) * f,
905
+ endY: (r + a - l) * h,
906
+ width: d * f,
907
+ height: a * h,
908
+ rotate: n,
909
+ absolute: {
910
+ left: !1,
911
+ top: !1
912
+ },
913
+ opacity: t != null ? t : 1
914
+ };
915
+ }
916
+ function wt(i, e) {
917
+ const { top: t, left: n, width: r, height: o, angle: s, opacity: c } = i;
918
+ return Tn({ top: t, left: n, bottom: t + o, right: n + r }, e.scene, c, s);
919
+ }
920
+ let it = class extends Ne {
921
+ constructor(e, t, n, r, o, s) {
922
+ super();
923
+ ve(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
924
+ this._renderManagerService = e, this._drawingManagerService = t, this._drawingRenderService = n, this._canvasFloatDomService = r, this._univerInstanceService = o, this._commandService = s, this._initialize();
925
+ }
926
+ dispose() {
927
+ super.dispose();
928
+ }
929
+ _initialize() {
930
+ this._drawingAddRemoveListener(), this._initScrollAndZoomEvent();
931
+ }
932
+ _getSceneAndTransformerByDrawingSearch(e) {
933
+ if (e == null)
934
+ return;
935
+ const t = this._renderManagerService.getRenderById(e);
936
+ if (t == null)
937
+ return null;
938
+ const n = t.scene, r = n.getTransformerByCreate();
939
+ return { scene: n, transformer: r, renderUnit: t, canvas: t.engine.getCanvasElement() };
940
+ }
941
+ _drawingAddRemoveListener() {
942
+ this.disposeWithMe(
943
+ this._drawingManagerService.add$.subscribe((e) => {
944
+ this._insertRects(e);
945
+ })
946
+ ), this.disposeWithMe(
947
+ this._drawingManagerService.remove$.subscribe((e) => {
948
+ e.forEach((t) => {
949
+ this._removeDom(t.drawingId);
950
+ });
951
+ })
952
+ );
953
+ }
954
+ _insertRects(e) {
955
+ e.forEach(async (t) => {
956
+ const { unitId: n } = t;
957
+ if (!this._univerInstanceService.getUnit(n, we.UNIVER_DOC))
958
+ return;
959
+ const o = this._getSceneAndTransformerByDrawingSearch(n);
960
+ if (o == null)
961
+ return;
962
+ const s = this._drawingManagerService.getDrawingByParam(t);
963
+ if (s == null)
964
+ return;
965
+ const c = await this._drawingRenderService.renderFloatDom(s, o.scene);
966
+ if (!(c == null || c.length === 0))
967
+ for (const d of c) {
968
+ this._addHoverForRect(d);
969
+ const a = new Un(), g = wt(d, o.renderUnit), u = new Ot(g), l = o.canvas, f = s.data, h = {
970
+ dispose: a,
971
+ rect: d,
972
+ position$: u,
973
+ unitId: n
974
+ };
975
+ this._canvasFloatDomService.addFloatDom({
976
+ position$: u,
977
+ id: s.drawingId,
978
+ componentKey: s.componentKey,
979
+ onPointerDown: (p) => {
980
+ l.dispatchEvent(new PointerEvent(p.type, p));
981
+ },
982
+ onPointerMove: (p) => {
983
+ l.dispatchEvent(new PointerEvent(p.type, p));
984
+ },
985
+ onPointerUp: (p) => {
986
+ l.dispatchEvent(new PointerEvent(p.type, p));
987
+ },
988
+ onWheel: (p) => {
989
+ l.dispatchEvent(new WheelEvent(p.type, p));
990
+ },
991
+ data: f,
992
+ unitId: n
993
+ });
994
+ const m = d.onTransformChange$.subscribeEvent(() => {
995
+ const p = wt(d, o.renderUnit);
996
+ u.next(
997
+ p
998
+ );
999
+ });
1000
+ a.add(() => {
1001
+ this._canvasFloatDomService.removeFloatDom(s.drawingId);
1002
+ }), m && a.add(m), this._domLayerInfoMap.set(s.drawingId, h);
1003
+ }
1004
+ });
1005
+ }
1006
+ _addHoverForRect(e) {
1007
+ this.disposeWithMe(
1008
+ Se(
1009
+ e.onPointerEnter$.subscribeEvent(() => {
1010
+ e.cursor = xt.GRAB;
1011
+ })
1012
+ )
1013
+ ), this.disposeWithMe(
1014
+ Se(
1015
+ e.onPointerLeave$.subscribeEvent(() => {
1016
+ e.cursor = xt.DEFAULT;
1017
+ })
1018
+ )
1019
+ );
1020
+ }
1021
+ _removeDom(e) {
1022
+ const t = this._domLayerInfoMap.get(e);
1023
+ if (!t)
1024
+ return;
1025
+ const { unitId: n } = t;
1026
+ this._domLayerInfoMap.delete(e), t.dispose.dispose();
1027
+ const r = this._getSceneAndTransformerByDrawingSearch(n);
1028
+ r && r.scene.removeObject(t.rect);
1029
+ }
1030
+ _initScrollAndZoomEvent() {
1031
+ const e = (t) => {
1032
+ const n = this._getSceneAndTransformerByDrawingSearch(t);
1033
+ n && this._domLayerInfoMap.forEach((r) => {
1034
+ if (r.unitId !== t) return;
1035
+ const o = wt(r.rect, n.renderUnit);
1036
+ r.position$.next(o);
1037
+ });
1038
+ };
1039
+ this.disposeWithMe(
1040
+ this._univerInstanceService.getCurrentTypeOfUnit$(we.UNIVER_DOC).pipe(
1041
+ Ht((t) => {
1042
+ if (!t) return null;
1043
+ const n = t.getUnitId(), r = this._renderManagerService.getRenderById(n);
1044
+ return r ? { render: r, unitId: n } : null;
1045
+ }),
1046
+ Mr(
1047
+ (t) => t ? Zt(t.render.scene.getViewport(en.VIEW_MAIN).onScrollAfter$).pipe(Ht(() => ({ unitId: t.unitId }))) : br(null)
1048
+ )
1049
+ ).subscribe((t) => {
1050
+ if (!t) return;
1051
+ const { unitId: n } = t;
1052
+ e(n);
1053
+ })
1054
+ ), this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
1055
+ if (t.id === tn.id) {
1056
+ const n = t.params, { unitId: r } = n;
1057
+ e(r);
1058
+ }
1059
+ }));
1060
+ }
1061
+ insertFloatDom(e, t) {
1062
+ var m, p, w;
1063
+ const n = this._univerInstanceService.getCurrentUnitOfType(we.UNIVER_DOC);
1064
+ if (!n) return !1;
1065
+ const r = this._getSceneAndTransformerByDrawingSearch(n.getUnitId());
1066
+ if (!r) return !1;
1067
+ const c = (m = r.renderUnit.with(te).getSkeleton().getSkeletonData()) == null ? void 0 : m.pages[0];
1068
+ if (!c) return !1;
1069
+ const { pageWidth: d, marginLeft: a, marginRight: g } = c, u = d - a - g, l = {
1070
+ size: {
1071
+ width: (p = t.width) != null ? p : u,
1072
+ height: t.height
1073
+ },
1074
+ positionH: {
1075
+ relativeFrom: J.PAGE,
1076
+ posOffset: 0
1077
+ },
1078
+ positionV: {
1079
+ relativeFrom: W.PAGE,
1080
+ posOffset: 0
1081
+ },
1082
+ angle: 0
1083
+ }, f = (w = t.drawingId) != null ? w : Ln(), h = {
1084
+ unitId: n.getUnitId(),
1085
+ drawings: [
1086
+ {
1087
+ drawingId: f,
1088
+ drawingType: xe.DRAWING_DOM,
1089
+ subUnitId: n.getUnitId(),
1090
+ unitId: n.getUnitId(),
1091
+ ...e,
1092
+ title: "",
1093
+ description: "",
1094
+ docTransform: l,
1095
+ layoutType: k.INLINE,
1096
+ transform: Jt(l)
1097
+ }
1098
+ ]
1099
+ };
1100
+ return this._commandService.syncExecuteCommand(Mt.id, h), f;
1101
+ }
1102
+ };
1103
+ it = Gr([
1104
+ Be(0, Q),
1105
+ Be(1, fe),
1106
+ Be(2, Z(dn)),
1107
+ Be(3, Z(Ir)),
1108
+ Be(4, z),
1109
+ Be(5, j)
1110
+ ], it);
1111
+ const Hr = "docs-drawing-ui.config", $t = {}, zt = -1e3, Xt = 1e3, jr = (i) => {
894
1112
  const e = me(j), t = me(lt), n = me(fe), r = me(Q), o = me(z), { drawings: s } = i, c = s[0];
895
1113
  if (c == null)
896
1114
  return;
@@ -1049,7 +1267,7 @@ const mn = {
1049
1267
  }, []), /* @__PURE__ */ X(
1050
1268
  "div",
1051
1269
  {
1052
- className: cn("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
1270
+ className: rn("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
1053
1271
  "univer-hidden": !L
1054
1272
  }),
1055
1273
  children: [
@@ -1094,7 +1312,7 @@ const mn = {
1094
1312
  /* @__PURE__ */ X("div", { children: [
1095
1313
  /* @__PURE__ */ y("span", { children: t.t("image-position.toTheRightOf") }),
1096
1314
  /* @__PURE__ */ y(
1097
- Wt,
1315
+ Bt,
1098
1316
  {
1099
1317
  value: String(D.relativeFrom),
1100
1318
  disabled: p,
@@ -1140,7 +1358,7 @@ const mn = {
1140
1358
  /* @__PURE__ */ X("div", { children: [
1141
1359
  /* @__PURE__ */ y("span", { children: t.t("image-position.bellow") }),
1142
1360
  /* @__PURE__ */ y(
1143
- Wt,
1361
+ Bt,
1144
1362
  {
1145
1363
  disabled: p,
1146
1364
  value: String(O.relativeFrom),
@@ -1160,7 +1378,7 @@ const mn = {
1160
1378
  }
1161
1379
  ),
1162
1380
  /* @__PURE__ */ y("div", { children: /* @__PURE__ */ y(
1163
- Er,
1381
+ ar,
1164
1382
  {
1165
1383
  disabled: p,
1166
1384
  checked: M,
@@ -1171,7 +1389,7 @@ const mn = {
1171
1389
  ]
1172
1390
  }
1173
1391
  );
1174
- }, Qe = 0, Je = 100, Hr = (i) => {
1392
+ }, Qe = 0, Je = 100, Vr = (i) => {
1175
1393
  const e = me(j), t = me(lt), n = me(fe), r = me(Q), o = me(z), { drawings: s } = i, c = s[0];
1176
1394
  if (c == null)
1177
1395
  return null;
@@ -1297,7 +1515,7 @@ const mn = {
1297
1515
  }, []), /* @__PURE__ */ X(
1298
1516
  "div",
1299
1517
  {
1300
- className: cn("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
1518
+ className: rn("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
1301
1519
  "univer-hidden": !L
1302
1520
  }),
1303
1521
  children: [
@@ -1315,7 +1533,7 @@ const mn = {
1315
1533
  children: /* @__PURE__ */ y("div", { children: t.t("image-text-wrap.wrappingStyle") })
1316
1534
  }
1317
1535
  ),
1318
- /* @__PURE__ */ y("div", { children: /* @__PURE__ */ X(Gt, { value: D, onChange: v, direction: "vertical", children: [
1536
+ /* @__PURE__ */ y("div", { children: /* @__PURE__ */ X(Ft, { value: D, onChange: v, direction: "vertical", children: [
1319
1537
  /* @__PURE__ */ y(ye, { value: ue.INLINE, children: t.t("image-text-wrap.inline") }),
1320
1538
  /* @__PURE__ */ y(ye, { value: ue.WRAP_SQUARE, children: t.t("image-text-wrap.square") }),
1321
1539
  /* @__PURE__ */ y(ye, { value: ue.WRAP_TOP_AND_BOTTOM, children: t.t("image-text-wrap.topAndBottom") }),
@@ -1329,7 +1547,7 @@ const mn = {
1329
1547
  children: /* @__PURE__ */ y("div", { children: t.t("image-text-wrap.wrapText") })
1330
1548
  }
1331
1549
  ),
1332
- /* @__PURE__ */ y("div", { children: /* @__PURE__ */ X(Gt, { disabled: l, value: O, onChange: N, direction: "horizontal", children: [
1550
+ /* @__PURE__ */ y("div", { children: /* @__PURE__ */ X(Ft, { disabled: l, value: O, onChange: N, direction: "horizontal", children: [
1333
1551
  /* @__PURE__ */ y(ye, { value: ze.BOTH_SIDES, children: t.t("image-text-wrap.bothSide") }),
1334
1552
  /* @__PURE__ */ y(ye, { value: ze.LEFT, children: t.t("image-text-wrap.leftOnly") }),
1335
1553
  /* @__PURE__ */ y(ye, { value: ze.RIGHT, children: t.t("image-text-wrap.rightOnly") })
@@ -1424,7 +1642,7 @@ const mn = {
1424
1642
  ]
1425
1643
  }
1426
1644
  );
1427
- }, jr = () => {
1645
+ }, $r = () => {
1428
1646
  const i = me(fe), e = i.getFocusDrawings(), [t, n] = ie(e);
1429
1647
  return Tt(() => {
1430
1648
  const r = i.focus$.subscribe((o) => {
@@ -1434,13 +1652,13 @@ const mn = {
1434
1652
  r.unsubscribe();
1435
1653
  };
1436
1654
  }, []), !!(t != null && t.length) && /* @__PURE__ */ X("div", { className: "univer-text-sm", children: [
1437
- /* @__PURE__ */ y(tr, { drawings: t, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }),
1438
- /* @__PURE__ */ y(Hr, { drawings: t }),
1439
- /* @__PURE__ */ y(Gr, { drawings: t })
1655
+ /* @__PURE__ */ y(Er, { drawings: t, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }),
1656
+ /* @__PURE__ */ y(Vr, { drawings: t }),
1657
+ /* @__PURE__ */ y(jr, { drawings: t })
1440
1658
  ] });
1441
- }, Tn = "doc.menu.image", yn = fn.id, Vr = (i) => {
1659
+ }, yn = "doc.menu.image", Mn = fn.id, zr = (i) => {
1442
1660
  const e = i.get(Dt), t = i.get(z);
1443
- return new Pr((n) => {
1661
+ return new Cr((n) => {
1444
1662
  const r = e.textSelection$.subscribe(() => {
1445
1663
  var s;
1446
1664
  const o = e.getActiveTextRange();
@@ -1462,40 +1680,40 @@ const mn = {
1462
1680
  return () => r.unsubscribe();
1463
1681
  });
1464
1682
  };
1465
- function $r(i) {
1683
+ function Xr(i) {
1466
1684
  return {
1467
- id: Tn,
1468
- type: nn.SUBITEMS,
1685
+ id: yn,
1686
+ type: sn.SUBITEMS,
1469
1687
  icon: "AddImageIcon",
1470
1688
  tooltip: "docImage.title",
1471
- disabled$: Vr(i),
1472
- hidden$: tn(i, we.UNIVER_DOC, void 0, St)
1689
+ disabled$: zr(i),
1690
+ hidden$: on(i, we.UNIVER_DOC, void 0, St)
1473
1691
  };
1474
1692
  }
1475
- function zr(i) {
1693
+ function qr(i) {
1476
1694
  return {
1477
- id: yn,
1695
+ id: Mn,
1478
1696
  title: "docImage.upload.float",
1479
- type: nn.BUTTON,
1480
- hidden$: tn(i, we.UNIVER_DOC, void 0, St)
1697
+ type: sn.BUTTON,
1698
+ hidden$: on(i, we.UNIVER_DOC, void 0, St)
1481
1699
  };
1482
1700
  }
1483
- const Xr = {
1484
- [pr.MEDIA]: {
1485
- [Tn]: {
1701
+ const Kr = {
1702
+ [_r.MEDIA]: {
1703
+ [yn]: {
1486
1704
  order: 0,
1487
- menuItemFactory: $r,
1488
- [yn]: {
1705
+ menuItemFactory: Xr,
1706
+ [Mn]: {
1489
1707
  order: 0,
1490
- menuItemFactory: zr
1708
+ menuItemFactory: qr
1491
1709
  }
1492
1710
  }
1493
1711
  }
1494
1712
  };
1495
1713
  function Ye(i) {
1496
- return i.getContextValue(Un) && i.getContextValue(nt);
1714
+ return i.getContextValue(Bn) && i.getContextValue(nt);
1497
1715
  }
1498
- const qr = {
1716
+ const Yr = {
1499
1717
  id: Ke.id,
1500
1718
  description: "shortcut.drawing-move-down",
1501
1719
  group: "4_drawing-view",
@@ -1505,7 +1723,7 @@ const qr = {
1505
1723
  staticParameters: {
1506
1724
  direction: he.DOWN
1507
1725
  }
1508
- }, Kr = {
1726
+ }, Zr = {
1509
1727
  id: Ke.id,
1510
1728
  description: "shortcut.drawing-move-up",
1511
1729
  group: "4_drawing-view",
@@ -1515,7 +1733,7 @@ const qr = {
1515
1733
  staticParameters: {
1516
1734
  direction: he.UP
1517
1735
  }
1518
- }, Yr = {
1736
+ }, Qr = {
1519
1737
  id: Ke.id,
1520
1738
  description: "shortcut.drawing-move-left",
1521
1739
  group: "4_drawing-view",
@@ -1525,7 +1743,7 @@ const qr = {
1525
1743
  staticParameters: {
1526
1744
  direction: he.LEFT
1527
1745
  }
1528
- }, Zr = {
1746
+ }, Jr = {
1529
1747
  id: Ke.id,
1530
1748
  description: "shortcut.drawing-move-right",
1531
1749
  group: "4_drawing-view",
@@ -1535,7 +1753,7 @@ const qr = {
1535
1753
  staticParameters: {
1536
1754
  direction: he.RIGHT
1537
1755
  }
1538
- }, Qr = {
1756
+ }, ei = {
1539
1757
  id: gn.id,
1540
1758
  description: "shortcut.drawing-delete",
1541
1759
  group: "4_drawing-view",
@@ -1544,21 +1762,21 @@ const qr = {
1544
1762
  binding: We.DELETE,
1545
1763
  mac: We.BACKSPACE
1546
1764
  };
1547
- var Jr = Object.getOwnPropertyDescriptor, ei = (i, e, t, n) => {
1548
- for (var r = n > 1 ? void 0 : n ? Jr(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1765
+ var ti = Object.getOwnPropertyDescriptor, ni = (i, e, t, n) => {
1766
+ for (var r = n > 1 ? void 0 : n ? ti(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1549
1767
  (s = i[o]) && (r = s(r) || r);
1550
1768
  return r;
1551
1769
  }, et = (i, e) => (t, n) => e(t, n, i);
1552
- let it = class extends Ne {
1770
+ let ot = class extends Ne {
1553
1771
  constructor(i, e, t, n) {
1554
1772
  super(), this._componentManager = i, this._menuManagerService = e, this._commandService = t, this._shortcutService = n, this._init();
1555
1773
  }
1556
1774
  _initCustomComponents() {
1557
1775
  const i = this._componentManager;
1558
- this.disposeWithMe(i.register(Sn, jr));
1776
+ this.disposeWithMe(i.register(Sn, $r));
1559
1777
  }
1560
1778
  _initMenus() {
1561
- this._menuManagerService.mergeMenu(Xr);
1779
+ this._menuManagerService.mergeMenu(Kr);
1562
1780
  }
1563
1781
  _initCommands() {
1564
1782
  [
@@ -1572,7 +1790,7 @@ let it = class extends Ne {
1572
1790
  _n,
1573
1791
  yt,
1574
1792
  Dn,
1575
- Wr,
1793
+ kr,
1576
1794
  On,
1577
1795
  ln,
1578
1796
  hn,
@@ -1584,11 +1802,11 @@ let it = class extends Ne {
1584
1802
  _initShortcuts() {
1585
1803
  [
1586
1804
  // sheet drawing shortcuts
1587
- qr,
1588
- Kr,
1589
1805
  Yr,
1590
1806
  Zr,
1591
- Qr
1807
+ Qr,
1808
+ Jr,
1809
+ ei
1592
1810
  ].forEach((i) => {
1593
1811
  this.disposeWithMe(this._shortcutService.registerShortcut(i));
1594
1812
  });
@@ -1597,18 +1815,18 @@ let it = class extends Ne {
1597
1815
  this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
1598
1816
  }
1599
1817
  };
1600
- it = ei([
1601
- et(0, Z(rn)),
1602
- et(1, mr),
1818
+ ot = ni([
1819
+ et(0, Z(an)),
1820
+ et(1, Sr),
1603
1821
  et(2, j),
1604
- et(3, wr)
1605
- ], it);
1606
- var ti = Object.getOwnPropertyDescriptor, ni = (i, e, t, n) => {
1607
- for (var r = n > 1 ? void 0 : n ? ti(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1822
+ et(3, Dr)
1823
+ ], ot);
1824
+ var ri = Object.getOwnPropertyDescriptor, ii = (i, e, t, n) => {
1825
+ for (var r = n > 1 ? void 0 : n ? ri(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1608
1826
  (s = i[o]) && (r = s(r) || r);
1609
1827
  return r;
1610
1828
  }, je = (i, e) => (t, n) => e(t, n, i);
1611
- function ri(i) {
1829
+ function oi(i) {
1612
1830
  var n, r, o, s;
1613
1831
  if ($.isNoop(i) || !Array.isArray(i))
1614
1832
  return null;
@@ -1631,7 +1849,7 @@ function ri(i) {
1631
1849
  });
1632
1850
  return t;
1633
1851
  }
1634
- function ii(i) {
1852
+ function si(i) {
1635
1853
  if (!Array.isArray(i) || i.length < 3 || i[0] !== "drawingsOrder")
1636
1854
  return [];
1637
1855
  const e = [];
@@ -1646,7 +1864,7 @@ function ii(i) {
1646
1864
  }
1647
1865
  return e;
1648
1866
  }
1649
- let ot = class extends Ne {
1867
+ let st = class extends Ne {
1650
1868
  constructor(i, e, t, n, r) {
1651
1869
  super(), this._univerInstanceService = i, this._commandService = e, this._drawingManagerService = t, this._docDrawingService = n, this._renderManagerService = r, this._initialize();
1652
1870
  }
@@ -1658,7 +1876,7 @@ let ot = class extends Ne {
1658
1876
  this._commandService.beforeCommandExecuted((i) => {
1659
1877
  if (i.id !== ee.id)
1660
1878
  return;
1661
- const e = i.params, { unitId: t, actions: n } = e, r = ri(n);
1879
+ const e = i.params, { unitId: t, actions: n } = e, r = oi(n);
1662
1880
  if (r != null)
1663
1881
  for (const { type: o, drawingId: s, drawing: c } of r)
1664
1882
  o === "add" ? this._addDrawings(t, [c]) : this._removeDrawings(t, [s]);
@@ -1668,12 +1886,12 @@ let ot = class extends Ne {
1668
1886
  if (i.id !== ee.id)
1669
1887
  return;
1670
1888
  const e = i.params, { unitId: t, actions: n } = e;
1671
- ii(n).length > 0 && this._updateDrawingsOrder(t);
1889
+ si(n).length > 0 && this._updateDrawingsOrder(t);
1672
1890
  })
1673
1891
  ), this.disposeWithMe(
1674
1892
  this._commandService.onCommandExecuted((i) => {
1675
1893
  var s;
1676
- if (i.id !== Ln.id && i.id !== Bn.id)
1894
+ if (i.id !== Fn.id && i.id !== kn.id)
1677
1895
  return;
1678
1896
  const e = (s = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : s.getUnitId(), t = this._drawingManagerService.getFocusDrawings();
1679
1897
  if (e == null || t.length === 0)
@@ -1714,233 +1932,16 @@ let ot = class extends Ne {
1714
1932
  n.orderNotification(o), r.orderNotification(o);
1715
1933
  }
1716
1934
  };
1717
- ot = ni([
1935
+ st = ii([
1718
1936
  je(0, z),
1719
1937
  je(1, j),
1720
1938
  je(2, fe),
1721
1939
  je(3, Ue),
1722
1940
  je(4, Q)
1723
- ], ot);
1724
- var oi = Object.getOwnPropertyDescriptor, si = (i, e, t, n) => {
1725
- for (var r = n > 1 ? void 0 : n ? oi(e, t) : e, o = i.length - 1, s; o >= 0; o--)
1726
- (s = i[o]) && (r = s(r) || r);
1727
- return r;
1728
- }, Be = (i, e) => (t, n) => e(t, n, i);
1729
- function Mn(i, e, t = 1, n = 0) {
1730
- const { top: r, left: o, bottom: s, right: c } = i, d = c - o, a = s - r, g = e.getViewport(sn.VIEW_MAIN), { viewportScrollX: u, viewportScrollY: l } = g, { scaleX: f, scaleY: h } = e.getAncestorScale();
1731
- return {
1732
- startX: (o - u) * f,
1733
- startY: (r - l) * h,
1734
- endX: (o + d - u) * f,
1735
- endY: (r + a - l) * h,
1736
- width: d * f,
1737
- height: a * h,
1738
- rotate: n,
1739
- absolute: {
1740
- left: !1,
1741
- top: !1
1742
- },
1743
- opacity: t != null ? t : 1
1744
- };
1745
- }
1746
- function wt(i, e) {
1747
- const { top: t, left: n, width: r, height: o, angle: s, opacity: c } = i;
1748
- return Mn({ top: t, left: n, bottom: t + o, right: n + r }, e.scene, c, s);
1749
- }
1750
- let st = class extends Ne {
1751
- constructor(e, t, n, r, o, s) {
1752
- super();
1753
- ve(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
1754
- this._renderManagerService = e, this._drawingManagerService = t, this._drawingRenderService = n, this._canvasFloatDomService = r, this._univerInstanceService = o, this._commandService = s, this._initialize();
1755
- }
1756
- dispose() {
1757
- super.dispose();
1758
- }
1759
- _initialize() {
1760
- this._drawingAddRemoveListener(), this._initScrollAndZoomEvent();
1761
- }
1762
- _getSceneAndTransformerByDrawingSearch(e) {
1763
- if (e == null)
1764
- return;
1765
- const t = this._renderManagerService.getRenderById(e);
1766
- if (t == null)
1767
- return null;
1768
- const n = t.scene, r = n.getTransformerByCreate();
1769
- return { scene: n, transformer: r, renderUnit: t, canvas: t.engine.getCanvasElement() };
1770
- }
1771
- _drawingAddRemoveListener() {
1772
- this.disposeWithMe(
1773
- this._drawingManagerService.add$.subscribe((e) => {
1774
- this._insertRects(e);
1775
- })
1776
- ), this.disposeWithMe(
1777
- this._drawingManagerService.remove$.subscribe((e) => {
1778
- e.forEach((t) => {
1779
- this._removeDom(t.drawingId);
1780
- });
1781
- })
1782
- );
1783
- }
1784
- _insertRects(e) {
1785
- e.forEach(async (t) => {
1786
- const { unitId: n } = t;
1787
- if (!this._univerInstanceService.getUnit(n, we.UNIVER_DOC))
1788
- return;
1789
- const o = this._getSceneAndTransformerByDrawingSearch(n);
1790
- if (o == null)
1791
- return;
1792
- const s = this._drawingManagerService.getDrawingByParam(t);
1793
- if (s == null)
1794
- return;
1795
- const c = await this._drawingRenderService.renderFloatDom(s, o.scene);
1796
- if (!(c == null || c.length === 0))
1797
- for (const d of c) {
1798
- this._addHoverForRect(d);
1799
- const a = new Fn(), g = wt(d, o.renderUnit), u = new Ot(g), l = o.canvas, f = s.data, h = {
1800
- dispose: a,
1801
- rect: d,
1802
- position$: u,
1803
- unitId: n
1804
- };
1805
- this._canvasFloatDomService.addFloatDom({
1806
- position$: u,
1807
- id: s.drawingId,
1808
- componentKey: s.componentKey,
1809
- onPointerDown: (p) => {
1810
- l.dispatchEvent(new PointerEvent(p.type, p));
1811
- },
1812
- onPointerMove: (p) => {
1813
- l.dispatchEvent(new PointerEvent(p.type, p));
1814
- },
1815
- onPointerUp: (p) => {
1816
- l.dispatchEvent(new PointerEvent(p.type, p));
1817
- },
1818
- onWheel: (p) => {
1819
- l.dispatchEvent(new WheelEvent(p.type, p));
1820
- },
1821
- data: f,
1822
- unitId: n
1823
- });
1824
- const m = d.onTransformChange$.subscribeEvent(() => {
1825
- const p = wt(d, o.renderUnit);
1826
- u.next(
1827
- p
1828
- );
1829
- });
1830
- a.add(() => {
1831
- this._canvasFloatDomService.removeFloatDom(s.drawingId);
1832
- }), m && a.add(m), this._domLayerInfoMap.set(s.drawingId, h);
1833
- }
1834
- });
1835
- }
1836
- _addHoverForRect(e) {
1837
- this.disposeWithMe(
1838
- Se(
1839
- e.onPointerEnter$.subscribeEvent(() => {
1840
- e.cursor = Nt.GRAB;
1841
- })
1842
- )
1843
- ), this.disposeWithMe(
1844
- Se(
1845
- e.onPointerLeave$.subscribeEvent(() => {
1846
- e.cursor = Nt.DEFAULT;
1847
- })
1848
- )
1849
- );
1850
- }
1851
- _removeDom(e) {
1852
- const t = this._domLayerInfoMap.get(e);
1853
- if (!t)
1854
- return;
1855
- const { unitId: n } = t;
1856
- this._domLayerInfoMap.delete(e), t.dispose.dispose();
1857
- const r = this._getSceneAndTransformerByDrawingSearch(n);
1858
- r && r.scene.removeObject(t.rect);
1859
- }
1860
- _initScrollAndZoomEvent() {
1861
- const e = (t) => {
1862
- const n = this._getSceneAndTransformerByDrawingSearch(t);
1863
- n && this._domLayerInfoMap.forEach((r) => {
1864
- if (r.unitId !== t) return;
1865
- const o = wt(r.rect, n.renderUnit);
1866
- r.position$.next(o);
1867
- });
1868
- };
1869
- this.disposeWithMe(
1870
- this._univerInstanceService.getCurrentTypeOfUnit$(we.UNIVER_DOC).pipe(
1871
- Ht((t) => {
1872
- if (!t) return null;
1873
- const n = t.getUnitId(), r = this._renderManagerService.getRenderById(n);
1874
- return r ? { render: r, unitId: n } : null;
1875
- }),
1876
- xr(
1877
- (t) => t ? Zt(t.render.scene.getViewport(sn.VIEW_MAIN).onScrollAfter$).pipe(Ht(() => ({ unitId: t.unitId }))) : Nr(null)
1878
- )
1879
- ).subscribe((t) => {
1880
- if (!t) return;
1881
- const { unitId: n } = t;
1882
- e(n);
1883
- })
1884
- ), this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
1885
- if (t.id === an.id) {
1886
- const n = t.params, { unitId: r } = n;
1887
- e(r);
1888
- }
1889
- }));
1890
- }
1891
- insertFloatDom(e, t) {
1892
- var m, p, w;
1893
- const n = this._univerInstanceService.getCurrentUnitOfType(we.UNIVER_DOC);
1894
- if (!n) return !1;
1895
- const r = this._getSceneAndTransformerByDrawingSearch(n.getUnitId());
1896
- if (!r) return !1;
1897
- const c = (m = r.renderUnit.with(te).getSkeleton().getSkeletonData()) == null ? void 0 : m.pages[0];
1898
- if (!c) return !1;
1899
- const { pageWidth: d, marginLeft: a, marginRight: g } = c, u = d - a - g, l = {
1900
- size: {
1901
- width: (p = t.width) != null ? p : u,
1902
- height: t.height
1903
- },
1904
- positionH: {
1905
- relativeFrom: J.PAGE,
1906
- posOffset: 0
1907
- },
1908
- positionV: {
1909
- relativeFrom: W.PAGE,
1910
- posOffset: 0
1911
- },
1912
- angle: 0
1913
- }, f = (w = t.drawingId) != null ? w : kn(), h = {
1914
- unitId: n.getUnitId(),
1915
- drawings: [
1916
- {
1917
- drawingId: f,
1918
- drawingType: xe.DRAWING_DOM,
1919
- subUnitId: n.getUnitId(),
1920
- unitId: n.getUnitId(),
1921
- ...e,
1922
- title: "",
1923
- description: "",
1924
- docTransform: l,
1925
- layoutType: k.INLINE,
1926
- transform: on(l)
1927
- }
1928
- ]
1929
- };
1930
- return this._commandService.syncExecuteCommand(Mt.id, h), f;
1931
- }
1932
- };
1933
- st = si([
1934
- Be(0, Q),
1935
- Be(1, fe),
1936
- Be(2, Z(Jt)),
1937
- Be(3, Z(vr)),
1938
- Be(4, z),
1939
- Be(5, j)
1940
1941
  ], st);
1941
1942
  const ai = (i) => {
1942
1943
  const { floatDomInfos: e, scene: t, offset: n, bound: r } = i, o = r.right - r.left, s = r.bottom - r.top, c = Ur(() => e.map((d) => {
1943
- const { width: a = 0, height: g = 0, left: u = 0, top: l = 0 } = d.transform, h = Mn(
1944
+ const { width: a = 0, height: g = 0, left: u = 0, top: l = 0 } = d.transform, h = Tn(
1944
1945
  {
1945
1946
  left: u,
1946
1947
  right: u + a,
@@ -1966,7 +1967,7 @@ const ai = (i) => {
1966
1967
  };
1967
1968
  return [d.drawingId, m];
1968
1969
  }).filter(([d, a]) => !(a.position.endX < 0 || a.position.endY < 0 || a.position.startX > o || a.position.startY > s)), [e, t, n, o, s]);
1969
- return /* @__PURE__ */ y("div", { className: "univer-absolute univer-left-0 univer-top-0", children: c.map(([d, a]) => /* @__PURE__ */ y(Ir, { layer: a, id: d, position: a.position }, d)) });
1970
+ return /* @__PURE__ */ y("div", { className: "univer-absolute univer-left-0 univer-top-0", children: c.map(([d, a]) => /* @__PURE__ */ y(Or, { layer: a, id: d, position: a.position }, d)) });
1970
1971
  };
1971
1972
  var ci = Object.getOwnPropertyDescriptor, di = (i, e, t, n) => {
1972
1973
  for (var r = n > 1 ? void 0 : n ? ci(e, t) : e, o = i.length - 1, s; o >= 0; o--)
@@ -2016,8 +2017,8 @@ let at = class extends Ne {
2016
2017
  };
2017
2018
  }
2018
2019
  return null;
2019
- }).filter(Boolean), c = _r(ai, this._injector);
2020
- return Rr(
2020
+ }).filter(Boolean), c = Tr(ai, this._injector);
2021
+ return cr(
2021
2022
  /* @__PURE__ */ y(
2022
2023
  c,
2023
2024
  {
@@ -2031,7 +2032,7 @@ let at = class extends Ne {
2031
2032
  ),
2032
2033
  e.root
2033
2034
  ), i == null || i.add(() => {
2034
- Ar(e.root);
2035
+ dr(e.root);
2035
2036
  }), t(i);
2036
2037
  }
2037
2038
  }
@@ -2041,10 +2042,10 @@ let at = class extends Ne {
2041
2042
  }
2042
2043
  };
2043
2044
  at = di([
2044
- Ve(0, Z(Or)),
2045
- Ve(1, Z(Jt)),
2045
+ Ve(0, Z(Yn)),
2046
+ Ve(1, Z(dn)),
2046
2047
  Ve(2, fe),
2047
- Ve(3, Z(rn)),
2048
+ Ve(3, Z(an)),
2048
2049
  Ve(4, Z(Qt))
2049
2050
  ], at);
2050
2051
  var gi = Object.getOwnPropertyDescriptor, li = (i, e, t, n) => {
@@ -2060,7 +2061,7 @@ function qt(i) {
2060
2061
  let ct = class extends Ne {
2061
2062
  constructor(e, t, n, r) {
2062
2063
  super();
2063
- ve(this, "_liquid", new en());
2064
+ ve(this, "_liquid", new nn());
2064
2065
  ve(this, "_listenerOnImageMap", /* @__PURE__ */ new Set());
2065
2066
  // Use to cache the drawings is under transforming or scaling.
2066
2067
  ve(this, "_transformerCache", /* @__PURE__ */ new Map());
@@ -2233,7 +2234,7 @@ let ct = class extends Ne {
2233
2234
  if (r == null)
2234
2235
  return;
2235
2236
  const { mainComponent: s, scene: c } = r, d = s, a = c.getViewports()[0], {
2236
- pageLayoutType: g = Ut.VERTICAL,
2237
+ pageLayoutType: g = Nt.VERTICAL,
2237
2238
  pageMarginLeft: u,
2238
2239
  pageMarginTop: l
2239
2240
  } = d.getOffsetConfig();
@@ -2261,7 +2262,7 @@ let ct = class extends Ne {
2261
2262
  const A = {
2262
2263
  ...C,
2263
2264
  isBack: h
2264
- }, L = M.document.getOffsetConfig(), R = new Bt(L, o), { cursorList: v, contentBoxPointGroup: N } = R.getRangePointData(A, A), { startOffset: G } = (H = Ft(v)) != null ? H : {};
2265
+ }, L = M.document.getOffsetConfig(), R = new At(L, o), { cursorList: v, contentBoxPointGroup: N } = R.getRangePointData(A, A), { startOffset: G } = (H = Pt(v)) != null ? H : {};
2265
2266
  if (G != null)
2266
2267
  return { offset: G, contentBoxPointGroup: N, segmentId: p, segmentPage: m };
2267
2268
  }
@@ -2271,7 +2272,7 @@ let ct = class extends Ne {
2271
2272
  const n = this._renderManagerService.getRenderById(e.unitId), r = n == null ? void 0 : n.with(te).getSkeleton(), o = r == null ? void 0 : r.getSkeletonData();
2272
2273
  if (o == null || n == null)
2273
2274
  return;
2274
- const { pages: s, skeHeaders: c, skeFooters: d } = o, { mainComponent: a, scene: g } = n, u = a, l = g.getViewports()[0], { pageLayoutType: f = Ut.VERTICAL, pageMarginLeft: h, pageMarginTop: m, docsLeft: p, docsTop: w } = u.getOffsetConfig(), { left: D, top: S, angle: O } = t;
2275
+ const { pages: s, skeHeaders: c, skeFooters: d } = o, { mainComponent: a, scene: g } = n, u = a, l = g.getViewports()[0], { pageLayoutType: f = Nt.VERTICAL, pageMarginLeft: h, pageMarginTop: m, docsLeft: p, docsTop: w } = u.getOffsetConfig(), { left: D, top: S, angle: O } = t;
2275
2276
  let { width: C, height: M } = t;
2276
2277
  const { positionV: A, positionH: L } = e.docTransform, { width: R, height: v } = this._getPageContentSize(e);
2277
2278
  C = Math.min(C, R), M = Math.min(M, v);
@@ -2309,7 +2310,7 @@ let ct = class extends Ne {
2309
2310
  const { headerId: ht, footerId: ft, pageHeight: Cn, pageWidth: bt, marginLeft: Ct, marginBottom: En } = pe, Rn = s.indexOf(pe);
2310
2311
  if (x > -1 && Rn === x) {
2311
2312
  switch (K) {
2312
- case Lt.HEADER: {
2313
+ case Ut.HEADER: {
2313
2314
  const He = (Oe = c.get(ht)) == null ? void 0 : Oe.get(bt);
2314
2315
  if (He)
2315
2316
  this._liquid.translatePagePadding({
@@ -2320,7 +2321,7 @@ let ct = class extends Ne {
2320
2321
  throw new Error("header skeleton not found");
2321
2322
  break;
2322
2323
  }
2323
- case Lt.FOOTER: {
2324
+ case Ut.FOOTER: {
2324
2325
  const He = (Ee = d.get(ft)) == null ? void 0 : Ee.get(bt);
2325
2326
  if (He)
2326
2327
  this._liquid.translatePagePadding({
@@ -2376,7 +2377,7 @@ let ct = class extends Ne {
2376
2377
  const Ce = {
2377
2378
  ...se,
2378
2379
  isBack: H
2379
- }, Ge = Le.document.getOffsetConfig(), ae = new Bt(Ge, r), { cursorList: ne } = ae.getRangePointData(Ce, Ce), { startOffset: re } = (Ae = Ft(ne)) != null ? Ae : {};
2380
+ }, Ge = Le.document.getOffsetConfig(), ae = new At(Ge, r), { cursorList: ne } = ae.getRangePointData(Ce, Ce), { startOffset: re } = (Ae = Pt(ne)) != null ? Ae : {};
2380
2381
  if (re != null)
2381
2382
  return { offset: re, docTransform: I, segmentId: G, segmentPage: x };
2382
2383
  }
@@ -2478,7 +2479,7 @@ let ct = class extends Ne {
2478
2479
  return { scene: n, transformer: r };
2479
2480
  }
2480
2481
  _getTransformCoordForDocumentOffset(e, t, n, r) {
2481
- const { documentTransform: o } = e.getOffsetConfig(), s = t.transformVector2SceneCoord(cr.FromArray([n, r]));
2482
+ const { documentTransform: o } = e.getOffsetConfig(), s = t.transformVector2SceneCoord(rr.FromArray([n, r]));
2482
2483
  if (s)
2483
2484
  return o.clone().invert().applyPoint(s);
2484
2485
  }
@@ -2489,23 +2490,23 @@ let ct = class extends Ne {
2489
2490
  const { mainComponent: r, scene: o } = n, s = r, {
2490
2491
  docsLeft: c,
2491
2492
  docsTop: d
2492
- } = s.getOffsetConfig(), a = Tr(t), { left: g, top: u, height: l } = a, f = g + c, h = u + d;
2493
+ } = s.getOffsetConfig(), a = Zn(t), { left: g, top: u, height: l } = a, f = g + c, h = u + d;
2493
2494
  if (this._anchorShape) {
2494
2495
  this._anchorShape.transformByState({ left: f, top: h, height: l }), this._anchorShape.show();
2495
2496
  return;
2496
2497
  }
2497
- const m = 6, p = new dr(ui + Me.generateRandomId(m), {
2498
+ const m = 6, p = new ir(ui + Me.generateRandomId(m), {
2498
2499
  left: f,
2499
2500
  top: h,
2500
2501
  height: l,
2501
2502
  strokeWidth: 2,
2502
- stroke: gr(Gn.darkGray, 1),
2503
+ stroke: or(Gn.darkGray, 1),
2503
2504
  evented: !1
2504
2505
  });
2505
- this._anchorShape = p, o.addObject(p, yr);
2506
+ this._anchorShape = p, o.addObject(p, Qn);
2506
2507
  }
2507
2508
  _getDocObject() {
2508
- return Mr(this._univerInstanceService, this._renderManagerService);
2509
+ return Jn(this._univerInstanceService, this._renderManagerService);
2509
2510
  }
2510
2511
  _getPageContentSize(e) {
2511
2512
  const t = this._renderManagerService.getRenderById(e.unitId), n = t == null ? void 0 : t.with(te).getSkeleton(), r = 500, o = 500, s = n == null ? void 0 : n.getSkeletonData();
@@ -2569,7 +2570,7 @@ let dt = class extends Hn {
2569
2570
  _hasCropObject(e) {
2570
2571
  const t = e.getAllObjects();
2571
2572
  for (const n of t)
2572
- if (n instanceof nr)
2573
+ if (n instanceof Rr)
2573
2574
  return !0;
2574
2575
  return !1;
2575
2576
  }
@@ -2600,7 +2601,7 @@ let dt = class extends Hn {
2600
2601
  const { unitId: g, subUnitId: u, drawingId: l, drawingType: f } = a, h = this._canvasPopManagerService.attachPopupToObject(
2601
2602
  c,
2602
2603
  {
2603
- componentKey: rr,
2604
+ componentKey: Ar,
2604
2605
  direction: "horizontal",
2605
2606
  offset: [2, 0],
2606
2607
  extraProps: {
@@ -2656,7 +2657,7 @@ let dt = class extends Hn {
2656
2657
  {
2657
2658
  label: "image-popup.crop",
2658
2659
  index: 2,
2659
- commandId: ir.id,
2660
+ commandId: Pr.id,
2660
2661
  commandParams: { unitId: e, subUnitId: t, drawingId: n },
2661
2662
  disable: !0
2662
2663
  // TODO: @JOCS, feature is not ready.
@@ -2664,7 +2665,7 @@ let dt = class extends Hn {
2664
2665
  {
2665
2666
  label: "image-popup.reset",
2666
2667
  index: 3,
2667
- commandId: or.id,
2668
+ commandId: xr.id,
2668
2669
  commandParams: [{ unitId: e, subUnitId: t, drawingId: n }],
2669
2670
  disable: !0
2670
2671
  // TODO: @JOCS, feature is not ready.
@@ -2674,7 +2675,7 @@ let dt = class extends Hn {
2674
2675
  };
2675
2676
  dt = fi([
2676
2677
  $e(0, fe),
2677
- $e(1, Z(br)),
2678
+ $e(1, Z(er)),
2678
2679
  $e(2, Q),
2679
2680
  $e(3, z),
2680
2681
  $e(4, Yt)
@@ -2687,7 +2688,7 @@ var pi = Object.getOwnPropertyDescriptor, mi = (i, e, t, n) => {
2687
2688
  let It = class extends Ne {
2688
2689
  constructor(e, t, n, r, o, s, c, d) {
2689
2690
  super();
2690
- ve(this, "_liquid", new en());
2691
+ ve(this, "_liquid", new nn());
2691
2692
  this._context = e, this._docSkeletonManagerService = t, this._commandService = n, this._editorService = r, this._drawingManagerService = o, this._docRefreshDrawingsService = s, this._univerInstanceService = c, this._lifecycleService = d, this._initialize(), this._commandExecutedListener();
2692
2693
  }
2693
2694
  _initialize() {
@@ -2701,7 +2702,7 @@ let It = class extends Ne {
2701
2702
  });
2702
2703
  }
2703
2704
  _commandExecutedListener() {
2704
- const e = [ee.id, an.id];
2705
+ const e = [ee.id, tn.id];
2705
2706
  this.disposeWithMe(
2706
2707
  this._commandService.onCommandExecuted((t) => {
2707
2708
  if (e.includes(t.id)) {
@@ -2723,8 +2724,8 @@ let It = class extends Ne {
2723
2724
  _initResize() {
2724
2725
  this.disposeWithMe(
2725
2726
  Zt(this._context.engine.onTransformChange$).pipe(
2726
- Vt((e) => e.type === lr.resize),
2727
- dn(16)
2727
+ Vt((e) => e.type === sr.resize),
2728
+ cn(16)
2728
2729
  ).subscribe(() => {
2729
2730
  var n;
2730
2731
  const e = this._docSkeletonManagerService.getSkeleton(), { scene: t } = this._context;
@@ -2821,7 +2822,7 @@ let It = class extends Ne {
2821
2822
  It = mi([
2822
2823
  Pe(1, Z(te)),
2823
2824
  Pe(2, j),
2824
- Pe(3, Cr),
2825
+ Pe(3, tr),
2825
2826
  Pe(4, fe),
2826
2827
  Pe(5, Z(ut)),
2827
2828
  Pe(6, z),
@@ -2841,16 +2842,16 @@ let gt = class extends zn {
2841
2842
  $t,
2842
2843
  this._config
2843
2844
  );
2844
- this._configService.setConfig(Lr, r);
2845
+ this._configService.setConfig(Hr, r);
2845
2846
  }
2846
2847
  onStarting() {
2847
2848
  [
2848
- [it],
2849
+ [ot],
2849
2850
  [dt],
2850
2851
  [ct],
2851
- [ot],
2852
- [ut],
2853
2852
  [st],
2853
+ [ut],
2854
+ [it],
2854
2855
  [at]
2855
2856
  ].forEach((e) => this._injector.add(e));
2856
2857
  }
@@ -2858,25 +2859,25 @@ let gt = class extends zn {
2858
2859
  [
2859
2860
  [rt],
2860
2861
  [It]
2861
- ].forEach((i) => this._renderManagerSrv.registerRenderModule(we.UNIVER_DOC, i)), this._injector.get(ot), this._injector.get(it), this._injector.get(ct), this._injector.get(at);
2862
+ ].forEach((i) => this._renderManagerSrv.registerRenderModule(we.UNIVER_DOC, i)), this._injector.get(st), this._injector.get(ot), this._injector.get(ct), this._injector.get(at);
2862
2863
  }
2863
2864
  onRendered() {
2864
- this._injector.get(dt), this._injector.get(st);
2865
+ this._injector.get(dt), this._injector.get(it);
2865
2866
  }
2866
2867
  };
2867
2868
  bn(gt, "type", we.UNIVER_DOC);
2868
2869
  bn(gt, "pluginName", Si);
2869
2870
  gt = _i([
2870
- Vn(sr, er, qn, Sr),
2871
+ Vn(Nr, pr, qn, yr),
2871
2872
  vt(1, Z(Qt)),
2872
2873
  vt(2, Q),
2873
2874
  vt(3, $n)
2874
2875
  ], gt);
2875
2876
  export {
2876
- Wr as ClearDocDrawingTransformerOperation,
2877
- Tn as DOCS_IMAGE_MENU_ID,
2877
+ kr as ClearDocDrawingTransformerOperation,
2878
+ yn as DOCS_IMAGE_MENU_ID,
2878
2879
  gn as DeleteDocDrawingsCommand,
2879
- st as DocFloatDomController,
2880
+ it as DocFloatDomController,
2880
2881
  On as EditDocDrawingOperation,
2881
2882
  ln as GroupDocDrawingCommand,
2882
2883
  Mt as InsertDocDrawingCommand,