@univerjs/docs-drawing-ui 0.4.2 → 0.5.0-nightly.202411091605

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,1741 +1,1805 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { CommandType, ICommandService, IUniverInstanceService, TextX, JSONX, MemoryCursor, TextXActionType, IUndoRedoService, BuildTextUtils, Tools, Inject, LocaleService, Disposable, BooleanNumber, PositionedObjectLayoutType, WrapTextType, ObjectRelativeFromH, ObjectRelativeFromV, FOCUSING_COMMON_DRAWINGS, IContextService, UniverInstanceType, Direction, useDependency, DocumentFlavor, FOCUSING_UNIVER_EDITOR, UndoCommand, RedoCommand, toDisposable, throttle, COLORS, RxDisposable, LifecycleService, fromEventSubject, LifecycleStages, DependentOn, Injector, Plugin, IConfigService } from "@univerjs/core";
6
- import { IDocDrawingService, UniverDocsDrawingPlugin } from "@univerjs/docs-drawing";
7
- import { ArrangeTypeEnum, DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DrawingTypeEnum, getDrawingShapeKeyByDrawingSearch, IImageIoService, IDrawingManagerService, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, UniverDrawingPlugin } from "@univerjs/drawing";
8
- import { DrawingCommonPanel, ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
9
- import { IRenderManagerService, DocumentEditArea, Liquid, PageLayoutType, DocumentSkeletonPageType, Vector2, Rect, getColor, TRANSFORM_CHANGE_OBSERVABLE_TYPE } from "@univerjs/engine-render";
10
- import { IMessageService, ILocalFileService, ISidebarService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, KeyCode, ComponentManager, IMenuManagerService, IShortcutService, UniverUIPlugin } from "@univerjs/ui";
11
- import { RichTextEditingMutation, DocSelectionManagerService, DocSkeletonManagerService } from "@univerjs/docs";
12
- import { DocSelectionRenderService, getRichTextEditPath, getCustomBlockIdsInSelections, docDrawingPositionToTransform, NodePositionConvertToCursor, getOneTextSelectionRange, getAnchorBounding, TEXT_RANGE_LAYER_INDEX, getDocObject, DocCanvasPopManagerService, IEditorService, SetDocZoomRatioOperation } from "@univerjs/docs-ui";
13
- import { MessageType, InputNumber, Select, Checkbox, RadioGroup, Radio } from "@univerjs/design";
14
- import { BehaviorSubject, Observable, takeUntil, filter, debounceTime } from "rxjs";
15
- import React, { forwardRef, useRef, createElement, useState, useEffect } from "react";
16
- const PLUGIN_CONFIG_KEY = "docs-drawing-ui.config", defaultPluginConfig = {};
17
- var __assign = function() {
18
- return __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
1
+ var Dt = Object.defineProperty;
2
+ var Ot = (i, e, n) => e in i ? Dt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
+ var Se = (i, e, n) => Ot(i, typeof e != "symbol" ? e + "" : e, n);
4
+ import { CommandType as X, ICommandService as z, IUniverInstanceService as Z, TextX as vn, JSONX as q, MemoryCursor as xt, TextXActionType as Y, IUndoRedoService as Hn, BuildTextUtils as Pt, Tools as Pe, Inject as we, LocaleService as dn, Disposable as qe, BooleanNumber as re, PositionedObjectLayoutType as k, WrapTextType as Ve, ObjectRelativeFromH as ee, ObjectRelativeFromV as G, FOCUSING_COMMON_DRAWINGS as nn, IContextService as Wn, UniverInstanceType as Te, Direction as ue, useDependency as pe, DocumentFlavor as fn, FOCUSING_UNIVER_EDITOR as Tt, UndoCommand as yt, RedoCommand as bt, toDisposable as Ee, throttle as On, COLORS as Mt, RxDisposable as Rt, LifecycleService as Nt, fromEventSubject as At, LifecycleStages as xn, DependentOn as Et, Injector as jt, Plugin as Lt, IConfigService as Bt } from "@univerjs/core";
5
+ import { IDocDrawingService as je, UniverDocsDrawingPlugin as Ut } from "@univerjs/docs-drawing";
6
+ import { ArrangeTypeEnum as Ye, DRAWING_IMAGE_ALLOW_IMAGE_LIST as Ft, DRAWING_IMAGE_COUNT_LIMIT as Pn, ImageUploadStatusType as hn, DRAWING_IMAGE_ALLOW_SIZE as kt, getImageSize as Ht, DrawingTypeEnum as Wt, getDrawingShapeKeyByDrawingSearch as Gt, IImageIoService as Vt, IDrawingManagerService as ve, DRAWING_IMAGE_WIDTH_LIMIT as Tn, DRAWING_IMAGE_HEIGHT_LIMIT as yn, UniverDrawingPlugin as $t } from "@univerjs/drawing";
7
+ import { DrawingCommonPanel as zt, ImageCropperObject as qt, COMPONENT_IMAGE_POPUP_MENU as Xt, OpenImageCropOperation as Kt, ImageResetSizeOperation as Yt, UniverDrawingUIPlugin as Zt } from "@univerjs/drawing-ui";
8
+ import { IRenderManagerService as Q, DocumentEditArea as Ue, Liquid as Gn, PageLayoutType as bn, DocumentSkeletonPageType as Mn, Vector2 as Jt, Rect as Qt, getColor as ei, TRANSFORM_CHANGE_OBSERVABLE_TYPE as ni } from "@univerjs/engine-render";
9
+ import { IMessageService as ti, ILocalFileService as ii, ISidebarService as ri, MenuItemType as Vn, getMenuHiddenObservable as $n, RibbonStartGroup as oi, KeyCode as Fe, ComponentManager as si, IMenuManagerService as ai, IShortcutService as ci, UniverUIPlugin as di } from "@univerjs/ui";
10
+ import { RichTextEditingMutation as J, DocSelectionManagerService as In, DocSkeletonManagerService as oe } from "@univerjs/docs";
11
+ import { DocSelectionRenderService as ye, getRichTextEditPath as $e, getCustomBlockIdsInSelections as li, docDrawingPositionToTransform as gi, NodePositionConvertToCursor as Rn, getOneTextSelectionRange as Nn, getAnchorBounding as mi, TEXT_RANGE_LAYER_INDEX as ui, getDocObject as fi, DocCanvasPopManagerService as hi, IEditorService as pi, SetDocZoomRatioOperation as wi } from "@univerjs/docs-ui";
12
+ import { MessageType as An, InputNumber as Be, Select as En, Checkbox as vi, RadioGroup as jn, Radio as xe } from "@univerjs/design";
13
+ import { BehaviorSubject as Ii, Observable as _i, takeUntil as Ln, filter as Bn, debounceTime as Si } from "rxjs";
14
+ import Ci, { forwardRef as zn, useRef as Di, createElement as qn, useState as ie, useEffect as _n } from "react";
15
+ const Oi = "docs-drawing-ui.config", xi = {};
16
+ var fe = function() {
17
+ return fe = Object.assign || function(i) {
18
+ for (var e, n = 1, t = arguments.length; n < t; n++) {
19
+ e = arguments[n];
20
+ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
22
21
  }
23
- return t;
24
- }, __assign.apply(this, arguments);
25
- }, __rest = function(s, e) {
26
- var t = {};
27
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
28
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
29
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
30
- e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
31
- return t;
32
- }, IconBase = forwardRef(function(props, ref) {
33
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
34
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
22
+ return i;
23
+ }, fe.apply(this, arguments);
24
+ }, Pi = function(i, e) {
25
+ var n = {};
26
+ for (var t in i) Object.prototype.hasOwnProperty.call(i, t) && e.indexOf(t) < 0 && (n[t] = i[t]);
27
+ if (i != null && typeof Object.getOwnPropertySymbols == "function")
28
+ for (var r = 0, t = Object.getOwnPropertySymbols(i); r < t.length; r++)
29
+ e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, t[r]) && (n[t[r]] = i[t[r]]);
30
+ return n;
31
+ }, Xn = zn(function(i, e) {
32
+ var n = i.icon, t = i.id, r = i.className, o = i.extend, s = Pi(i, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), d = Di("_".concat(bi()));
33
+ return Kn(n, "".concat(t), { defIds: n.defIds, idSuffix: d.current }, fe({ ref: e, className: a }, s), o);
35
34
  });
36
- function render(node, id, runtimeProps, rootProps, extend) {
37
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
38
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
35
+ function Kn(i, e, n, t, r) {
36
+ return qn(i.tag, fe(fe({ key: e }, Ti(i, n, r)), t), (yi(i, n).children || []).map(function(o, s) {
37
+ return Kn(o, "".concat(e, "-").concat(i.tag, "-").concat(s), n, void 0, r);
39
38
  }));
40
39
  }
41
- __name(render, "render");
42
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
43
- var attrs = __assign({}, node.attrs);
44
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
45
- var defIds = runtimeProps.defIds;
46
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a8) {
47
- var key = _a8[0], value = _a8[1];
48
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
49
- })), attrs;
40
+ function Ti(i, e, n) {
41
+ var t = fe({}, i.attrs);
42
+ n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
43
+ var r = e.defIds;
44
+ return !r || r.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(o) {
45
+ var s = o[0], a = o[1];
46
+ typeof a == "string" && (t[s] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
47
+ })), t;
50
48
  }
51
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
52
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
53
- var _a8, defIds = runtimeProps.defIds;
54
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a8 = node.children) === null || _a8 === void 0) && _a8.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
55
- 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;
56
- }) }) : node;
49
+ function yi(i, e) {
50
+ var n, t = e.defIds;
51
+ return !t || t.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? fe(fe({}, i), { children: i.children.map(function(r) {
52
+ return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? fe(fe({}, r), { attrs: fe(fe({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
53
+ }) }) : i;
57
54
  }
58
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
59
- function generateShortUuid() {
55
+ function bi() {
60
56
  return Math.random().toString(36).substring(2, 8);
61
57
  }
62
- __name(generateShortUuid, "generateShortUuid");
63
- IconBase.displayName = "UniverIcon";
64
- var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, AddImageSingle = forwardRef(function(props, ref) {
65
- return createElement(IconBase, Object.assign({}, props, {
58
+ Xn.displayName = "UniverIcon";
59
+ var Mi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, Yn = zn(function(i, e) {
60
+ return qn(Xn, Object.assign({}, i, {
66
61
  id: "add-image-single",
67
- ref,
68
- icon: element
62
+ ref: e,
63
+ icon: Mi
69
64
  }));
70
65
  });
71
- AddImageSingle.displayName = "AddImageSingle";
72
- const RemoveDocDrawingCommand = {
66
+ Yn.displayName = "AddImageSingle";
67
+ const Sn = {
73
68
  id: "doc.command.remove-doc-image",
74
- type: CommandType.COMMAND,
69
+ type: X.COMMAND,
75
70
  // eslint-disable-next-line max-lines-per-function
76
- handler: /* @__PURE__ */ __name((accessor, params) => {
77
- var _a8, _b, _c, _d;
78
- const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderManagerService = accessor.get(IRenderManagerService), documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
79
- if (params == null || documentDataModel == null)
71
+ handler: (i, e) => {
72
+ var b, T, N, B;
73
+ const n = i.get(z), t = i.get(Z), r = i.get(Q), o = t.getCurrentUniverDocInstance();
74
+ if (e == null || o == null)
80
75
  return !1;
81
- const docSelectionRenderService = renderManagerService.getRenderById(params.unitId).with(DocSelectionRenderService), { drawings: removeDrawings } = params, segmentId = (_a8 = docSelectionRenderService.getSegment()) != null ? _a8 : "", textX = new TextX(), jsonX = JSONX.getInstance(), customBlocks = (_c = (_b = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b.customBlocks) != null ? _c : [], removeCustomBlocks = removeDrawings.map((drawing) => customBlocks.find((customBlock) => customBlock.blockId === drawing.drawingId)).filter((block) => !!block).sort((a, b) => a.startIndex > b.startIndex ? 1 : -1), unitId = removeDrawings[0].unitId, memoryCursor = new MemoryCursor();
82
- memoryCursor.reset();
83
- const cursorIndex = removeCustomBlocks[0].startIndex, textRanges = [
76
+ const s = r.getRenderById(e.unitId).with(ye), { drawings: a } = e, d = (b = s.getSegment()) != null ? b : "", c = new vn(), g = q.getInstance(), f = (N = (T = o.getSelfOrHeaderFooterModel(d).getBody()) == null ? void 0 : T.customBlocks) != null ? N : [], m = a.map((R) => f.find((I) => I.blockId === R.drawingId)).filter((R) => !!R).sort((R, I) => R.startIndex > I.startIndex ? 1 : -1), p = a[0].unitId, h = new xt();
77
+ h.reset();
78
+ const v = m[0].startIndex, w = [
84
79
  {
85
- startOffset: cursorIndex,
86
- endOffset: cursorIndex
80
+ startOffset: v,
81
+ endOffset: v
87
82
  }
88
- ], doMutation = {
89
- id: RichTextEditingMutation.id,
83
+ ], S = {
84
+ id: J.id,
90
85
  params: {
91
- unitId,
86
+ unitId: p,
92
87
  actions: [],
93
- textRanges
88
+ textRanges: w
94
89
  }
95
- }, rawActions = [];
96
- for (const block of removeCustomBlocks) {
97
- const { startIndex } = block;
98
- startIndex > memoryCursor.cursor && textX.push({
99
- t: TextXActionType.RETAIN,
100
- len: startIndex - memoryCursor.cursor
101
- }), textX.push({
102
- t: TextXActionType.DELETE,
90
+ }, O = [];
91
+ for (const R of m) {
92
+ const { startIndex: I } = R;
93
+ I > h.cursor && c.push({
94
+ t: Y.RETAIN,
95
+ len: I - h.cursor
96
+ }), c.push({
97
+ t: Y.DELETE,
103
98
  len: 1
104
- }), memoryCursor.moveCursorTo(startIndex + 1);
99
+ }), h.moveCursorTo(I + 1);
105
100
  }
106
- const path = getRichTextEditPath(documentDataModel, segmentId);
107
- rawActions.push(jsonX.editOp(textX.serialize(), path));
108
- for (const block of removeCustomBlocks) {
109
- const { blockId } = block, drawing = ((_d = documentDataModel.getDrawings()) != null ? _d : {})[blockId], drawingIndex = documentDataModel.getDrawingsOrder().indexOf(blockId), removeDrawingAction = jsonX.removeOp(["drawings", blockId], drawing), removeDrawingOrderAction = jsonX.removeOp(["drawingsOrder", drawingIndex], blockId);
110
- rawActions.push(removeDrawingAction), rawActions.push(removeDrawingOrderAction);
101
+ const D = $e(o, d);
102
+ O.push(g.editOp(c.serialize(), D));
103
+ for (const R of m) {
104
+ const { blockId: I } = R, j = ((B = o.getDrawings()) != null ? B : {})[I], E = o.getDrawingsOrder().indexOf(I), W = g.removeOp(["drawings", I], j), _ = g.removeOp(["drawingsOrder", E], I);
105
+ O.push(W), O.push(_);
111
106
  }
112
- return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
113
- }, "handler")
114
- }, DeleteDocDrawingsCommand = {
107
+ return S.params.actions = O.reduce((R, I) => q.compose(R, I), null), !!n.syncExecuteCommand(S.id, S.params);
108
+ }
109
+ }, Zn = {
115
110
  id: "doc.command.delete-drawing",
116
- type: CommandType.COMMAND,
117
- handler: /* @__PURE__ */ __name((accessor) => {
118
- const commandService = accessor.get(ICommandService), drawings = accessor.get(IDocDrawingService).getFocusDrawings();
119
- if (drawings.length === 0)
111
+ type: X.COMMAND,
112
+ handler: (i) => {
113
+ const e = i.get(z), t = i.get(je).getFocusDrawings();
114
+ if (t.length === 0)
120
115
  return !1;
121
- const { unitId } = drawings[0], newDrawings = drawings.map((drawing) => {
122
- const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawing;
116
+ const { unitId: r } = t[0], o = t.map((s) => {
117
+ const { unitId: a, subUnitId: d, drawingId: c, drawingType: g } = s;
123
118
  return {
124
- unitId: unitId2,
125
- subUnitId,
126
- drawingId,
127
- drawingType
119
+ unitId: a,
120
+ subUnitId: d,
121
+ drawingId: c,
122
+ drawingType: g
128
123
  };
129
124
  });
130
- return commandService.executeCommand(RemoveDocDrawingCommand.id, {
131
- unitId,
132
- drawings: newDrawings
125
+ return e.executeCommand(Sn.id, {
126
+ unitId: r,
127
+ drawings: o
133
128
  });
134
- }, "handler")
135
- }, GroupDocDrawingCommand = {
129
+ }
130
+ }, Jn = {
136
131
  id: "doc.command.group-doc-image",
137
- type: CommandType.COMMAND,
138
- handler: /* @__PURE__ */ __name((accessor, params) => {
139
- accessor.get(ICommandService), accessor.get(IUndoRedoService);
140
- const docDrawingService = accessor.get(IDocDrawingService);
141
- if (!params) return !1;
142
- const unitIds = [];
143
- return params.forEach(({ parent, children }) => {
144
- unitIds.push(parent.unitId), children.forEach((child) => {
145
- unitIds.push(child.unitId);
132
+ type: X.COMMAND,
133
+ handler: (i, e) => {
134
+ i.get(z), i.get(Hn);
135
+ const n = i.get(je);
136
+ if (!e) return !1;
137
+ const t = [];
138
+ return e.forEach(({ parent: r, children: o }) => {
139
+ t.push(r.unitId), o.forEach((s) => {
140
+ t.push(s.unitId);
146
141
  });
147
- }), docDrawingService.getGroupDrawingOp(params), !1;
148
- }, "handler")
149
- }, InsertDocDrawingCommand = {
142
+ }), n.getGroupDrawingOp(e), !1;
143
+ }
144
+ }, Qn = {
150
145
  id: "doc.command.insert-doc-image",
151
- type: CommandType.COMMAND,
146
+ type: X.COMMAND,
152
147
  // eslint-disable-next-line max-lines-per-function
153
- handler: /* @__PURE__ */ __name((accessor, params) => {
154
- var _a8, _b, _c, _d;
155
- if (params == null)
148
+ handler: (i, e) => {
149
+ var T, N, B, R;
150
+ if (e == null)
156
151
  return !1;
157
- const commandService = accessor.get(ICommandService), docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), activeTextRange = docSelectionManagerService.getActiveTextRange(), documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
158
- if (activeTextRange == null || documentDataModel == null)
152
+ const n = i.get(z), t = i.get(In), r = i.get(Z), o = t.getActiveTextRange(), s = r.getCurrentUniverDocInstance();
153
+ if (o == null || s == null)
159
154
  return !1;
160
- const unitId = documentDataModel.getUnitId(), { drawings } = params, { collapsed, startOffset, segmentId } = activeTextRange, body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
161
- if (body == null)
155
+ const a = s.getUnitId(), { drawings: d } = e, { collapsed: c, startOffset: g, segmentId: f } = o, m = s.getSelfOrHeaderFooterModel(f).getBody();
156
+ if (m == null)
162
157
  return !1;
163
- const textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [], drawingOrderLength = (_b = (_a8 = documentDataModel.getSnapshot().drawingsOrder) == null ? void 0 : _a8.length) != null ? _b : 0;
164
- let removeDrawingLen = 0;
165
- if (collapsed)
166
- startOffset > 0 && textX.push({
167
- t: TextXActionType.RETAIN,
168
- len: startOffset
158
+ const p = new vn(), h = q.getInstance(), v = [], w = (N = (T = s.getSnapshot().drawingsOrder) == null ? void 0 : T.length) != null ? N : 0;
159
+ let S = 0;
160
+ if (c)
161
+ g > 0 && p.push({
162
+ t: Y.RETAIN,
163
+ len: g
169
164
  });
170
165
  else {
171
- const { dos } = BuildTextUtils.selection.getDeleteActions(activeTextRange, segmentId, 0, body);
172
- textX.push(...dos);
173
- const removedCustomBlockIds = getCustomBlockIdsInSelections(body, [activeTextRange]), drawings2 = (_c = documentDataModel.getDrawings()) != null ? _c : {}, drawingOrder = (_d = documentDataModel.getDrawingsOrder()) != null ? _d : [], sortedRemovedCustomBlockIds = removedCustomBlockIds.sort((a, b) => drawingOrder.indexOf(a) > drawingOrder.indexOf(b) ? -1 : drawingOrder.indexOf(a) < drawingOrder.indexOf(b) ? 1 : 0);
174
- if (sortedRemovedCustomBlockIds.length > 0)
175
- for (const blockId of sortedRemovedCustomBlockIds) {
176
- const drawing = drawings2[blockId], drawingIndex = drawingOrder.indexOf(blockId);
177
- if (drawing == null || drawingIndex < 0)
166
+ const I = Pt.selection.delete([o], m, 0, null, !1);
167
+ p.push(...I);
168
+ const j = li(m, [o]), H = (B = s.getDrawings()) != null ? B : {}, E = (R = s.getDrawingsOrder()) != null ? R : [], W = j.sort((_, C) => E.indexOf(_) > E.indexOf(C) ? -1 : E.indexOf(_) < E.indexOf(C) ? 1 : 0);
169
+ if (W.length > 0)
170
+ for (const _ of W) {
171
+ const C = H[_], M = E.indexOf(_);
172
+ if (C == null || M < 0)
178
173
  continue;
179
- const removeDrawingAction = jsonX.removeOp(["drawings", blockId], drawing), removeDrawingOrderAction = jsonX.removeOp(["drawingsOrder", drawingIndex], blockId);
180
- rawActions.push(removeDrawingAction), rawActions.push(removeDrawingOrderAction), removeDrawingLen++;
174
+ const P = h.removeOp(["drawings", _], C), L = h.removeOp(["drawingsOrder", M], _);
175
+ v.push(P), v.push(L), S++;
181
176
  }
182
177
  }
183
- textX.push({
184
- t: TextXActionType.INSERT,
178
+ p.push({
179
+ t: Y.INSERT,
185
180
  body: {
186
- dataStream: "\b".repeat(drawings.length),
187
- customBlocks: drawings.map((drawing, i) => ({
188
- startIndex: i,
189
- blockId: drawing.drawingId
181
+ dataStream: "\b".repeat(d.length),
182
+ customBlocks: d.map((I, j) => ({
183
+ startIndex: j,
184
+ blockId: I.drawingId
190
185
  }))
191
186
  },
192
- len: drawings.length
187
+ len: d.length
193
188
  });
194
- const path = getRichTextEditPath(documentDataModel, segmentId), placeHolderAction = jsonX.editOp(textX.serialize(), path);
195
- rawActions.push(placeHolderAction);
196
- for (const drawing of drawings) {
197
- const { drawingId } = drawing, addDrawingAction = jsonX.insertOp(["drawings", drawingId], drawing), addDrawingOrderAction = jsonX.insertOp(["drawingsOrder", drawingOrderLength - removeDrawingLen], drawingId);
198
- rawActions.push(addDrawingAction), rawActions.push(addDrawingOrderAction);
189
+ const O = $e(s, f), D = h.editOp(p.serialize(), O);
190
+ v.push(D);
191
+ for (const I of d) {
192
+ const { drawingId: j } = I, H = h.insertOp(["drawings", j], I), E = h.insertOp(["drawingsOrder", w - S], j);
193
+ v.push(H), v.push(E);
199
194
  }
200
- const doMutation = {
201
- id: RichTextEditingMutation.id,
195
+ const x = {
196
+ id: J.id,
202
197
  params: {
203
- unitId,
198
+ unitId: a,
204
199
  actions: [],
205
200
  textRanges: []
206
201
  }
207
202
  };
208
- return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
209
- }, "handler")
210
- }, SetDocDrawingArrangeCommand = {
203
+ return x.params.actions = v.reduce((I, j) => q.compose(I, j), null), !!n.syncExecuteCommand(x.id, x.params);
204
+ }
205
+ }, et = {
211
206
  id: "doc.command.set-drawing-arrange",
212
- type: CommandType.COMMAND,
213
- handler: /* @__PURE__ */ __name((accessor, params) => {
214
- const commandService = accessor.get(ICommandService), docDrawingService = accessor.get(IDocDrawingService);
215
- if (params == null)
207
+ type: X.COMMAND,
208
+ handler: (i, e) => {
209
+ const n = i.get(z), t = i.get(je);
210
+ if (e == null)
216
211
  return !1;
217
- const { unitId, subUnitId, drawingIds, arrangeType } = params, drawingOrderMapParam = { unitId, subUnitId, drawingIds };
218
- let jsonOp;
219
- if (arrangeType === ArrangeTypeEnum.forward ? jsonOp = docDrawingService.getForwardDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.backward ? jsonOp = docDrawingService.getBackwardDrawingOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.front ? jsonOp = docDrawingService.getFrontDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.back && (jsonOp = docDrawingService.getBackDrawingsOp(drawingOrderMapParam)), jsonOp == null)
212
+ const { unitId: r, subUnitId: o, drawingIds: s, arrangeType: a } = e, d = { unitId: r, subUnitId: o, drawingIds: s };
213
+ let c;
214
+ if (a === Ye.forward ? c = t.getForwardDrawingsOp(d) : a === Ye.backward ? c = t.getBackwardDrawingOp(d) : a === Ye.front ? c = t.getFrontDrawingsOp(d) : a === Ye.back && (c = t.getBackDrawingsOp(d)), c == null)
220
215
  return !1;
221
- const { redo } = jsonOp;
222
- if (redo == null)
216
+ const { redo: g } = c;
217
+ if (g == null)
223
218
  return !1;
224
- const rawActions = [];
225
- let redoCopy = Tools.deepClone(redo);
226
- redoCopy = redoCopy.slice(3), redoCopy.unshift("drawingsOrder"), rawActions.push(redoCopy);
227
- const doMutation = {
228
- id: RichTextEditingMutation.id,
219
+ const f = [];
220
+ let m = Pe.deepClone(g);
221
+ m = m.slice(3), m.unshift("drawingsOrder"), f.push(m);
222
+ const p = {
223
+ id: J.id,
229
224
  params: {
230
- unitId,
225
+ unitId: r,
231
226
  actions: [],
232
227
  textRanges: null
233
228
  }
234
229
  };
235
- return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
236
- }, "handler")
237
- }, UngroupDocDrawingCommand = {
230
+ return p.params.actions = f.reduce((v, w) => q.compose(v, w), null), !!n.syncExecuteCommand(p.id, p.params);
231
+ }
232
+ }, nt = {
238
233
  id: "doc.command.ungroup-doc-image",
239
- type: CommandType.COMMAND,
240
- handler: /* @__PURE__ */ __name((accessor, params) => {
241
- accessor.get(ICommandService), accessor.get(IUndoRedoService);
242
- const docDrawingService = accessor.get(IDocDrawingService);
243
- if (!params) return !1;
244
- const unitIds = [];
245
- return params.forEach(({ parent, children }) => {
246
- unitIds.push(parent.unitId), children.forEach((child) => {
247
- unitIds.push(child.unitId);
234
+ type: X.COMMAND,
235
+ handler: (i, e) => {
236
+ i.get(z), i.get(Hn);
237
+ const n = i.get(je);
238
+ if (!e) return !1;
239
+ const t = [];
240
+ return e.forEach(({ parent: r, children: o }) => {
241
+ t.push(r.unitId), o.forEach((s) => {
242
+ t.push(s.unitId);
248
243
  });
249
- }), docDrawingService.getUngroupDrawingOp(params), !1;
250
- }, "handler")
251
- }, _DocRefreshDrawingsService = class _DocRefreshDrawingsService {
244
+ }), n.getUngroupDrawingOp(e), !1;
245
+ }
246
+ };
247
+ class ln {
252
248
  constructor() {
253
- __publicField(this, "_refreshDrawings$", new BehaviorSubject(null));
254
- __publicField(this, "refreshDrawings$", this._refreshDrawings$.asObservable());
249
+ Se(this, "_refreshDrawings$", new Ii(null));
250
+ Se(this, "refreshDrawings$", this._refreshDrawings$.asObservable());
255
251
  }
256
- refreshDrawings(skeleton) {
257
- this._refreshDrawings$.next(skeleton);
252
+ refreshDrawings(e) {
253
+ this._refreshDrawings$.next(e);
258
254
  }
259
- };
260
- __name(_DocRefreshDrawingsService, "DocRefreshDrawingsService");
261
- let DocRefreshDrawingsService = _DocRefreshDrawingsService;
262
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
263
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
264
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
265
- return kind && result && __defProp$6(target, key, result), result;
266
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a;
267
- let DocDrawingUpdateRenderController = (_a = class extends Disposable {
268
- constructor(_context, _commandService, _docSelectionManagerService, _renderManagerSrv, _imageIoService, _docDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, _docSelectionRenderService, _docRefreshDrawingsService, _fileOpenerService) {
269
- super(), this._context = _context, this._commandService = _commandService, this._docSelectionManagerService = _docSelectionManagerService, this._renderManagerSrv = _renderManagerSrv, this._imageIoService = _imageIoService, this._docDrawingService = _docDrawingService, this._drawingManagerService = _drawingManagerService, this._contextService = _contextService, this._messageService = _messageService, this._localeService = _localeService, this._docSelectionRenderService = _docSelectionRenderService, this._docRefreshDrawingsService = _docRefreshDrawingsService, this._fileOpenerService = _fileOpenerService, this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._editAreaChangeListener();
255
+ }
256
+ var Ri = Object.defineProperty, Ni = Object.getOwnPropertyDescriptor, Ai = (i, e, n, t) => {
257
+ for (var r = t > 1 ? void 0 : t ? Ni(e, n) : e, o = i.length - 1, s; o >= 0; o--)
258
+ (s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
259
+ return t && r && Ri(e, n, r), r;
260
+ }, ge = (i, e) => (n, t) => e(n, t, i);
261
+ let tn = class extends qe {
262
+ constructor(i, e, n, t, r, o, s, a, d, c, g, f, m) {
263
+ super(), this._context = i, this._commandService = e, this._docSelectionManagerService = n, this._renderManagerSrv = t, this._imageIoService = r, this._docDrawingService = o, this._drawingManagerService = s, this._contextService = a, this._messageService = d, this._localeService = c, this._docSelectionRenderService = g, this._docRefreshDrawingsService = f, this._fileOpenerService = m, this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._editAreaChangeListener();
270
264
  }
271
265
  async insertDocImage() {
272
- const files = await this._fileOpenerService.openFile({
266
+ const i = await this._fileOpenerService.openFile({
273
267
  multiple: !0,
274
- accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
275
- }), fileLength = files.length;
276
- return fileLength > DRAWING_IMAGE_COUNT_LIMIT ? (this._messageService.show({
277
- type: MessageType.Error,
278
- content: this._localeService.t("update-status.exceedMaxCount", String(DRAWING_IMAGE_COUNT_LIMIT))
279
- }), !1) : fileLength === 0 ? !1 : (await this._insertFloatImages(files), !0);
268
+ accept: Ft.map((n) => `.${n.replace("image/", "")}`).join(",")
269
+ }), e = i.length;
270
+ return e > Pn ? (this._messageService.show({
271
+ type: An.Error,
272
+ content: this._localeService.t("update-status.exceedMaxCount", String(Pn))
273
+ }), !1) : e === 0 ? !1 : (await this._insertFloatImages(i), !0);
280
274
  }
281
275
  // eslint-disable-next-line max-lines-per-function
282
- async _insertFloatImages(files) {
283
- let imageParams = [];
276
+ async _insertFloatImages(i) {
277
+ let e = [];
284
278
  try {
285
- imageParams = await Promise.all(files.map((file) => this._imageIoService.saveImage(file)));
286
- } catch (error) {
287
- const type = error.message;
288
- let content = "";
289
- switch (type) {
290
- case ImageUploadStatusType.ERROR_EXCEED_SIZE:
291
- content = this._localeService.t("update-status.exceedMaxSize", String(DRAWING_IMAGE_ALLOW_SIZE / (1024 * 1024)));
279
+ e = await Promise.all(i.map((r) => this._imageIoService.saveImage(r)));
280
+ } catch (r) {
281
+ const o = r.message;
282
+ let s = "";
283
+ switch (o) {
284
+ case hn.ERROR_EXCEED_SIZE:
285
+ s = this._localeService.t("update-status.exceedMaxSize", String(kt / (1024 * 1024)));
292
286
  break;
293
- case ImageUploadStatusType.ERROR_IMAGE_TYPE:
294
- content = this._localeService.t("update-status.invalidImageType");
287
+ case hn.ERROR_IMAGE_TYPE:
288
+ s = this._localeService.t("update-status.invalidImageType");
295
289
  break;
296
- case ImageUploadStatusType.ERROR_IMAGE:
297
- content = this._localeService.t("update-status.invalidImage");
290
+ case hn.ERROR_IMAGE:
291
+ s = this._localeService.t("update-status.invalidImage");
298
292
  break;
299
293
  }
300
294
  this._messageService.show({
301
- type: MessageType.Error,
302
- content
295
+ type: An.Error,
296
+ content: s
303
297
  });
304
298
  }
305
- if (imageParams.length === 0)
299
+ if (e.length === 0)
306
300
  return;
307
- const { unitId } = this._context, docDrawingParams = [];
308
- for (const imageParam of imageParams) {
309
- if (imageParam == null)
301
+ const { unitId: n } = this._context, t = [];
302
+ for (const r of e) {
303
+ if (r == null)
310
304
  continue;
311
- const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || "");
312
- this._imageIoService.addImageSourceCache(imageId, imageSourceType, image);
313
- let scale = 1;
314
- if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
315
- const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width, scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
316
- scale = Math.min(scaleWidth, scaleHeight);
305
+ const { imageId: o, imageSourceType: s, source: a, base64Cache: d } = r, { width: c, height: g, image: f } = await Ht(d || "");
306
+ this._imageIoService.addImageSourceCache(o, s, f);
307
+ let m = 1;
308
+ if (c > Tn || g > yn) {
309
+ const w = Tn / c, S = yn / g;
310
+ m = Math.min(w, S);
317
311
  }
318
- const docTransform = this._getImagePosition(width * scale, height * scale);
319
- if (docTransform == null)
312
+ const p = this._getImagePosition(c * m, g * m);
313
+ if (p == null)
320
314
  return;
321
- const docDrawingParam = {
322
- unitId,
323
- subUnitId: unitId,
324
- drawingId: imageId,
325
- drawingType: DrawingTypeEnum.DRAWING_IMAGE,
326
- imageSourceType,
327
- source,
328
- transform: docDrawingPositionToTransform(docTransform),
329
- docTransform,
330
- behindDoc: BooleanNumber.FALSE,
315
+ const h = {
316
+ unitId: n,
317
+ subUnitId: n,
318
+ drawingId: o,
319
+ drawingType: Wt.DRAWING_IMAGE,
320
+ imageSourceType: s,
321
+ source: a,
322
+ transform: gi(p),
323
+ docTransform: p,
324
+ behindDoc: re.FALSE,
331
325
  title: "",
332
326
  description: "",
333
- layoutType: PositionedObjectLayoutType.INLINE,
327
+ layoutType: k.INLINE,
334
328
  // Insert inline drawing by default.
335
- wrapText: WrapTextType.BOTH_SIDES,
329
+ wrapText: Ve.BOTH_SIDES,
336
330
  distB: 0,
337
331
  distL: 0,
338
332
  distR: 0,
339
333
  distT: 0
340
334
  };
341
- this._isInsertInHeaderFooter() && (docDrawingParam.isMultiTransform = BooleanNumber.TRUE, docDrawingParam.transforms = docDrawingParam.transform ? [docDrawingParam.transform] : null), docDrawingParams.push(docDrawingParam);
335
+ this._isInsertInHeaderFooter() && (h.isMultiTransform = re.TRUE, h.transforms = h.transform ? [h.transform] : null), t.push(h);
342
336
  }
343
- this._commandService.executeCommand(InsertDocDrawingCommand.id, {
344
- unitId,
345
- drawings: docDrawingParams
337
+ this._commandService.executeCommand(Qn.id, {
338
+ unitId: n,
339
+ drawings: t
346
340
  });
347
341
  }
348
342
  _isInsertInHeaderFooter() {
349
- var _a8;
350
- const { unitId } = this._context, viewModel = (_a8 = this._renderManagerSrv.getRenderById(unitId)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getViewModel(), editArea = viewModel == null ? void 0 : viewModel.getEditArea();
351
- return editArea === DocumentEditArea.HEADER || editArea === DocumentEditArea.FOOTER;
343
+ var t;
344
+ const { unitId: i } = this._context, e = (t = this._renderManagerSrv.getRenderById(i)) == null ? void 0 : t.with(oe).getViewModel(), n = e == null ? void 0 : e.getEditArea();
345
+ return n === Ue.HEADER || n === Ue.FOOTER;
352
346
  }
353
- _getImagePosition(imageWidth, imageHeight) {
354
- const activeTextRange = this._docSelectionRenderService.getActiveTextRange(), position = (activeTextRange == null ? void 0 : activeTextRange.getAbsolutePosition()) || {
347
+ _getImagePosition(i, e) {
348
+ const n = this._docSelectionRenderService.getActiveTextRange(), t = (n == null ? void 0 : n.getAbsolutePosition()) || {
355
349
  left: 0,
356
350
  top: 0
357
351
  };
358
352
  return {
359
353
  size: {
360
- width: imageWidth,
361
- height: imageHeight
354
+ width: i,
355
+ height: e
362
356
  },
363
357
  positionH: {
364
- relativeFrom: ObjectRelativeFromH.PAGE,
365
- posOffset: position.left
358
+ relativeFrom: ee.PAGE,
359
+ posOffset: t.left
366
360
  },
367
361
  positionV: {
368
- relativeFrom: ObjectRelativeFromV.PARAGRAPH,
362
+ relativeFrom: G.PARAGRAPH,
369
363
  posOffset: 0
370
364
  },
371
365
  angle: 0
372
366
  };
373
367
  }
374
368
  _updateOrderListener() {
375
- this._drawingManagerService.featurePluginOrderUpdate$.subscribe((params) => {
376
- const { unitId, subUnitId, drawingIds, arrangeType } = params;
377
- this._commandService.executeCommand(SetDocDrawingArrangeCommand.id, {
378
- unitId,
379
- subUnitId,
380
- drawingIds,
381
- arrangeType
369
+ this._drawingManagerService.featurePluginOrderUpdate$.subscribe((i) => {
370
+ const { unitId: e, subUnitId: n, drawingIds: t, arrangeType: r } = i;
371
+ this._commandService.executeCommand(et.id, {
372
+ unitId: e,
373
+ subUnitId: n,
374
+ drawingIds: t,
375
+ arrangeType: r
382
376
  });
383
377
  });
384
378
  }
385
379
  _groupDrawingListener() {
386
- this._drawingManagerService.featurePluginGroupUpdate$.subscribe((params) => {
387
- this._commandService.executeCommand(GroupDocDrawingCommand.id, params);
388
- }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((params) => {
389
- this._commandService.executeCommand(UngroupDocDrawingCommand.id, params);
380
+ this._drawingManagerService.featurePluginGroupUpdate$.subscribe((i) => {
381
+ this._commandService.executeCommand(Jn.id, i);
382
+ }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((i) => {
383
+ this._commandService.executeCommand(nt.id, i);
390
384
  });
391
385
  }
392
386
  _getCurrentSceneAndTransformer() {
393
- const { scene, mainComponent } = this._context;
394
- if (scene == null || mainComponent == null)
387
+ const { scene: i, mainComponent: e } = this._context;
388
+ if (i == null || e == null)
395
389
  return;
396
- const transformer = scene.getTransformerByCreate(), { docsLeft, docsTop } = mainComponent.getOffsetConfig();
397
- return { scene, transformer, docsLeft, docsTop };
390
+ const n = i.getTransformerByCreate(), { docsLeft: t, docsTop: r } = e.getOffsetConfig();
391
+ return { scene: i, transformer: n, docsLeft: t, docsTop: r };
398
392
  }
399
393
  _focusDrawingListener() {
400
394
  this.disposeWithMe(
401
- this._drawingManagerService.focus$.subscribe((params) => {
402
- var _a8;
403
- const { transformer, docsLeft, docsTop } = (_a8 = this._getCurrentSceneAndTransformer()) != null ? _a8 : {};
404
- if (params == null || params.length === 0)
405
- this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._docDrawingService.focusDrawing([]), transformer && transformer.resetProps({
395
+ this._drawingManagerService.focus$.subscribe((i) => {
396
+ var r;
397
+ const { transformer: e, docsLeft: n, docsTop: t } = (r = this._getCurrentSceneAndTransformer()) != null ? r : {};
398
+ if (i == null || i.length === 0)
399
+ this._contextService.setContextValue(nn, !1), this._docDrawingService.focusDrawing([]), e && e.resetProps({
406
400
  zeroTop: 0,
407
401
  zeroLeft: 0
408
402
  });
409
403
  else {
410
- this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._docDrawingService.focusDrawing(params), this._docSelectionManagerService.getActiveTextRange() && this._docSelectionManagerService.replaceTextRanges([]);
411
- const prevSegmentId = this._docSelectionRenderService.getSegment(), segmentId = this._findSegmentIdByDrawingId(params[0].drawingId);
412
- prevSegmentId !== segmentId && this._docSelectionRenderService.setSegment(segmentId), transformer && transformer.resetProps({
413
- zeroTop: docsTop,
414
- zeroLeft: docsLeft
404
+ this._contextService.setContextValue(nn, !0), this._docDrawingService.focusDrawing(i), this._docSelectionManagerService.getActiveTextRange() && this._docSelectionManagerService.replaceTextRanges([]);
405
+ const s = this._docSelectionRenderService.getSegment(), a = this._findSegmentIdByDrawingId(i[0].drawingId);
406
+ s !== a && this._docSelectionRenderService.setSegment(a), e && e.resetProps({
407
+ zeroTop: t,
408
+ zeroLeft: n
415
409
  });
416
410
  }
417
411
  })
418
412
  );
419
413
  }
420
- _findSegmentIdByDrawingId(drawingId) {
421
- var _a8, _b, _c;
422
- const { unit: DocDataModel } = this._context, { body, headers = {}, footers = {} } = DocDataModel.getSnapshot();
423
- if (((_a8 = body == null ? void 0 : body.customBlocks) != null ? _a8 : []).some((b) => b.blockId === drawingId))
414
+ _findSegmentIdByDrawingId(i) {
415
+ var s, a, d;
416
+ const { unit: e } = this._context, { body: n, headers: t = {}, footers: r = {} } = e.getSnapshot();
417
+ if (((s = n == null ? void 0 : n.customBlocks) != null ? s : []).some((c) => c.blockId === i))
424
418
  return "";
425
- for (const headerId of Object.keys(headers))
426
- if ((_b = headers[headerId].body.customBlocks) != null && _b.some((b) => b.blockId === drawingId))
427
- return headerId;
428
- for (const footerId of Object.keys(footers))
429
- if ((_c = footers[footerId].body.customBlocks) != null && _c.some((b) => b.blockId === drawingId))
430
- return footerId;
419
+ for (const c of Object.keys(t))
420
+ if ((a = t[c].body.customBlocks) != null && a.some((g) => g.blockId === i))
421
+ return c;
422
+ for (const c of Object.keys(r))
423
+ if ((d = r[c].body.customBlocks) != null && d.some((g) => g.blockId === i))
424
+ return c;
431
425
  return "";
432
426
  }
433
427
  // Update drawings edit status and opacity. You can not edit header footer images when you are editing body. and vice verse.
434
428
  _updateDrawingsEditStatus() {
435
- var _a8;
436
- const { unit: docDataModel, scene, unitId } = this._context, viewModel = (_a8 = this._renderManagerSrv.getRenderById(unitId)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getViewModel();
437
- if (viewModel == null || docDataModel == null)
429
+ var a;
430
+ const { unit: i, scene: e, unitId: n } = this._context, t = (a = this._renderManagerSrv.getRenderById(n)) == null ? void 0 : a.with(oe).getViewModel();
431
+ if (t == null || i == null)
438
432
  return;
439
- const snapshot = docDataModel.getSnapshot(), { drawings = {} } = snapshot, isEditBody = viewModel.getEditArea() === DocumentEditArea.BODY;
440
- for (const key of Object.keys(drawings)) {
441
- const drawing = drawings[key], objectKey = getDrawingShapeKeyByDrawingSearch({ unitId, drawingId: drawing.drawingId, subUnitId: unitId }), drawingShapes = scene.fuzzyMathObjects(objectKey, !0);
442
- if (drawingShapes.length)
443
- for (const shape of drawingShapes)
444
- scene.detachTransformerFrom(shape), shape.setOpacity(0.5), (isEditBody && drawing.isMultiTransform !== BooleanNumber.TRUE || !isEditBody && drawing.isMultiTransform === BooleanNumber.TRUE) && (scene.attachTransformerTo(shape), shape.setOpacity(1));
433
+ const r = i.getSnapshot(), { drawings: o = {} } = r, s = t.getEditArea() === Ue.BODY;
434
+ for (const d of Object.keys(o)) {
435
+ const c = o[d], g = Gt({ unitId: n, drawingId: c.drawingId, subUnitId: n }), f = e.fuzzyMathObjects(g, !0);
436
+ if (f.length)
437
+ for (const m of f)
438
+ e.detachTransformerFrom(m), m.setOpacity(0.5), (s && c.isMultiTransform !== re.TRUE || !s && c.isMultiTransform === re.TRUE) && (e.attachTransformerTo(m), m.setOpacity(1));
445
439
  }
446
440
  }
447
441
  _editAreaChangeListener() {
448
- var _a8;
449
- const { unitId } = this._context, viewModel = (_a8 = this._renderManagerSrv.getRenderById(unitId)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getViewModel();
450
- viewModel != null && (this._updateDrawingsEditStatus(), this.disposeWithMe(
451
- viewModel.editAreaChange$.subscribe(() => {
442
+ var n;
443
+ const { unitId: i } = this._context, e = (n = this._renderManagerSrv.getRenderById(i)) == null ? void 0 : n.with(oe).getViewModel();
444
+ e != null && (this._updateDrawingsEditStatus(), this.disposeWithMe(
445
+ e.editAreaChange$.subscribe(() => {
452
446
  this._updateDrawingsEditStatus();
453
447
  })
454
- ), this._docRefreshDrawingsService.refreshDrawings$.subscribe((skeleton) => {
455
- skeleton != null && queueMicrotask(() => {
448
+ ), this._docRefreshDrawingsService.refreshDrawings$.subscribe((t) => {
449
+ t != null && queueMicrotask(() => {
456
450
  this._updateDrawingsEditStatus();
457
451
  });
458
452
  }), this.disposeWithMe(
459
- this._commandService.onCommandExecuted(async (command) => {
460
- command.id === RichTextEditingMutation.id && queueMicrotask(() => {
453
+ this._commandService.onCommandExecuted(async (t) => {
454
+ t.id === J.id && queueMicrotask(() => {
461
455
  this._updateDrawingsEditStatus();
462
456
  });
463
457
  })
464
458
  ));
465
459
  }
466
- }, __name(_a, "DocDrawingUpdateRenderController"), _a);
467
- DocDrawingUpdateRenderController = __decorateClass$6([
468
- __decorateParam$6(1, ICommandService),
469
- __decorateParam$6(2, Inject(DocSelectionManagerService)),
470
- __decorateParam$6(3, IRenderManagerService),
471
- __decorateParam$6(4, IImageIoService),
472
- __decorateParam$6(5, IDocDrawingService),
473
- __decorateParam$6(6, IDrawingManagerService),
474
- __decorateParam$6(7, IContextService),
475
- __decorateParam$6(8, IMessageService),
476
- __decorateParam$6(9, Inject(LocaleService)),
477
- __decorateParam$6(10, Inject(DocSelectionRenderService)),
478
- __decorateParam$6(11, Inject(DocRefreshDrawingsService)),
479
- __decorateParam$6(12, ILocalFileService)
480
- ], DocDrawingUpdateRenderController);
481
- const InsertDocImageCommand = {
460
+ };
461
+ tn = Ai([
462
+ ge(1, z),
463
+ ge(2, we(In)),
464
+ ge(3, Q),
465
+ ge(4, Vt),
466
+ ge(5, je),
467
+ ge(6, ve),
468
+ ge(7, Wn),
469
+ ge(8, ti),
470
+ ge(9, we(dn)),
471
+ ge(10, we(ye)),
472
+ ge(11, we(ln)),
473
+ ge(12, ii)
474
+ ], tn);
475
+ const tt = {
482
476
  id: "doc.command.insert-float-image",
483
- type: CommandType.COMMAND,
484
- handler: /* @__PURE__ */ __name((accessor) => {
485
- var _a8, _b;
486
- return (_b = (_a8 = accessor.get(IRenderManagerService).getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a8.with(DocDrawingUpdateRenderController).insertDocImage()) != null ? _b : !1;
487
- }, "handler")
477
+ type: X.COMMAND,
478
+ handler: (i) => {
479
+ var n, t;
480
+ return (t = (n = i.get(Q).getCurrentTypeOfRenderer(Te.UNIVER_DOC)) == null ? void 0 : n.with(tn).insertDocImage()) != null ? t : !1;
481
+ }
488
482
  };
489
- var TextWrappingStyle = /* @__PURE__ */ ((TextWrappingStyle2) => (TextWrappingStyle2.INLINE = "inline", TextWrappingStyle2.BEHIND_TEXT = "behindText", TextWrappingStyle2.IN_FRONT_OF_TEXT = "inFrontOfText", TextWrappingStyle2.WRAP_SQUARE = "wrapSquare", TextWrappingStyle2.WRAP_TOP_AND_BOTTOM = "wrapTopAndBottom", TextWrappingStyle2))(TextWrappingStyle || {});
490
- const WRAPPING_STYLE_TO_LAYOUT_TYPE = {
491
- inline: PositionedObjectLayoutType.INLINE,
492
- wrapSquare: PositionedObjectLayoutType.WRAP_SQUARE,
493
- wrapTopAndBottom: PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM,
494
- inFrontOfText: PositionedObjectLayoutType.WRAP_NONE,
495
- behindText: PositionedObjectLayoutType.WRAP_NONE
483
+ var me = /* @__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))(me || {});
484
+ const Ei = {
485
+ inline: k.INLINE,
486
+ wrapSquare: k.WRAP_SQUARE,
487
+ wrapTopAndBottom: k.WRAP_TOP_AND_BOTTOM,
488
+ inFrontOfText: k.WRAP_NONE,
489
+ behindText: k.WRAP_NONE
496
490
  };
497
- function getDeleteAndInsertCustomBlockActions(segmentId, oldSegmentId, segmentPage, offset, drawingId, documentDataModel, docSelectionRenderManager) {
498
- var _a8, _b;
499
- const textX = new TextX(), jsonX = JSONX.getInstance(), rawActions = [], oldBody = documentDataModel.getSelfOrHeaderFooterModel(oldSegmentId).getBody(), body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
500
- if (oldBody == null || body == null)
491
+ function it(i, e, n, t, r, o, s) {
492
+ var p, h;
493
+ const a = new vn(), d = q.getInstance(), c = [], g = o.getSelfOrHeaderFooterModel(e).getBody(), f = o.getSelfOrHeaderFooterModel(i).getBody();
494
+ if (g == null || f == null)
501
495
  return;
502
- const oldOffset = (_b = (_a8 = oldBody.customBlocks) == null ? void 0 : _a8.find((block) => block.blockId === drawingId)) == null ? void 0 : _b.startIndex;
503
- if (oldOffset != null) {
504
- if (offset = Math.min(body.dataStream.length - 2, offset), segmentId === oldSegmentId) {
505
- if (offset < oldOffset ? (offset > 0 && textX.push({
506
- t: TextXActionType.RETAIN,
507
- len: offset
508
- }), textX.push({
509
- t: TextXActionType.INSERT,
496
+ const m = (h = (p = g.customBlocks) == null ? void 0 : p.find((v) => v.blockId === r)) == null ? void 0 : h.startIndex;
497
+ if (m != null) {
498
+ if (t = Math.min(f.dataStream.length - 2, t), i === e) {
499
+ if (t < m ? (t > 0 && a.push({
500
+ t: Y.RETAIN,
501
+ len: t
502
+ }), a.push({
503
+ t: Y.INSERT,
510
504
  body: {
511
505
  dataStream: "\b",
512
506
  customBlocks: [{
513
507
  startIndex: 0,
514
- blockId: drawingId
508
+ blockId: r
515
509
  }]
516
510
  },
517
511
  len: 1
518
- }), textX.push({
519
- t: TextXActionType.RETAIN,
520
- len: oldOffset - offset
521
- }), textX.push({
522
- t: TextXActionType.DELETE,
512
+ }), a.push({
513
+ t: Y.RETAIN,
514
+ len: m - t
515
+ }), a.push({
516
+ t: Y.DELETE,
523
517
  len: 1
524
- })) : (oldOffset > 0 && textX.push({
525
- t: TextXActionType.RETAIN,
526
- len: oldOffset
527
- }), textX.push({
528
- t: TextXActionType.DELETE,
518
+ })) : (m > 0 && a.push({
519
+ t: Y.RETAIN,
520
+ len: m
521
+ }), a.push({
522
+ t: Y.DELETE,
529
523
  len: 1
530
- }), offset - oldOffset - 1 > 0 && textX.push({
531
- t: TextXActionType.RETAIN,
532
- len: offset - oldOffset - 1
533
- }), textX.push({
534
- t: TextXActionType.INSERT,
524
+ }), t - m - 1 > 0 && a.push({
525
+ t: Y.RETAIN,
526
+ len: t - m - 1
527
+ }), a.push({
528
+ t: Y.INSERT,
535
529
  body: {
536
530
  dataStream: "\b",
537
531
  customBlocks: [{
538
532
  startIndex: 0,
539
- blockId: drawingId
533
+ blockId: r
540
534
  }]
541
535
  },
542
536
  len: 1
543
- })), offset !== oldOffset) {
544
- const path = getRichTextEditPath(documentDataModel, oldSegmentId), action = jsonX.editOp(textX.serialize(), path);
545
- rawActions.push(action);
537
+ })), t !== m) {
538
+ const v = $e(o, e), w = d.editOp(a.serialize(), v);
539
+ c.push(w);
546
540
  }
547
541
  } else {
548
- oldOffset > 0 && textX.push({
549
- t: TextXActionType.RETAIN,
550
- len: oldOffset
551
- }), textX.push({
552
- t: TextXActionType.DELETE,
542
+ m > 0 && a.push({
543
+ t: Y.RETAIN,
544
+ len: m
545
+ }), a.push({
546
+ t: Y.DELETE,
553
547
  len: 1
554
548
  });
555
- let path = getRichTextEditPath(documentDataModel, oldSegmentId), action = jsonX.editOp(textX.serialize(), path);
556
- rawActions.push(action), textX.empty(), offset > 0 && textX.push({
557
- t: TextXActionType.RETAIN,
558
- len: offset
559
- }), textX.push({
560
- t: TextXActionType.INSERT,
549
+ let v = $e(o, e), w = d.editOp(a.serialize(), v);
550
+ c.push(w), a.empty(), t > 0 && a.push({
551
+ t: Y.RETAIN,
552
+ len: t
553
+ }), a.push({
554
+ t: Y.INSERT,
561
555
  body: {
562
556
  dataStream: "\b",
563
557
  customBlocks: [{
564
558
  startIndex: 0,
565
- blockId: drawingId
559
+ blockId: r
566
560
  }]
567
561
  },
568
562
  len: 1
569
- }), path = getRichTextEditPath(documentDataModel, segmentId), action = jsonX.editOp(textX.serialize(), path), rawActions.push(action), docSelectionRenderManager.setSegment(segmentId), docSelectionRenderManager.setSegmentPage(segmentPage);
563
+ }), v = $e(o, i), w = d.editOp(a.serialize(), v), c.push(w), s.setSegment(i), s.setSegmentPage(n);
570
564
  }
571
- return rawActions;
565
+ return c;
572
566
  }
573
567
  }
574
- __name(getDeleteAndInsertCustomBlockActions, "getDeleteAndInsertCustomBlockActions");
575
- const UpdateDocDrawingWrappingStyleCommand = {
568
+ const rt = {
576
569
  id: "doc.command.update-doc-drawing-wrapping-style",
577
- type: CommandType.COMMAND,
570
+ type: X.COMMAND,
578
571
  // eslint-disable-next-line max-lines-per-function, complexity
579
- handler: /* @__PURE__ */ __name((accessor, params) => {
580
- var _a8, _b;
581
- if (params == null)
572
+ handler: (i, e) => {
573
+ var N, B;
574
+ if (e == null)
582
575
  return !1;
583
- const { drawings, wrappingStyle, unitId } = params, commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderObject = accessor.get(IRenderManagerService).getRenderById(unitId), skeletonData = renderObject == null ? void 0 : renderObject.with(DocSkeletonManagerService).getSkeleton().getSkeletonData(), viewModel = renderObject == null ? void 0 : renderObject.with(DocSkeletonManagerService).getViewModel(), scene = renderObject == null ? void 0 : renderObject.scene, documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
584
- if (documentDataModel == null || skeletonData == null || scene == null || viewModel == null)
576
+ const { drawings: n, wrappingStyle: t, unitId: r } = e, o = i.get(z), s = i.get(Z), d = i.get(Q).getRenderById(r), c = d == null ? void 0 : d.with(oe).getSkeleton().getSkeletonData(), g = d == null ? void 0 : d.with(oe).getViewModel(), f = d == null ? void 0 : d.scene, m = s.getCurrentUniverDocInstance();
577
+ if (m == null || c == null || f == null || g == null)
585
578
  return !1;
586
- const editArea = viewModel.getEditArea(), transformer = scene.getTransformerByCreate(), { pages, skeHeaders, skeFooters } = skeletonData, jsonX = JSONX.getInstance(), rawActions = [], { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
587
- for (const drawing of drawings) {
588
- const { drawingId } = drawing, oldLayoutType = oldDrawings[drawingId].layoutType, newLayoutType = WRAPPING_STYLE_TO_LAYOUT_TYPE[wrappingStyle];
589
- if (oldLayoutType !== newLayoutType) {
590
- const updateLayoutTypeAction = jsonX.replaceOp(["drawings", drawingId, "layoutType"], oldLayoutType, newLayoutType);
591
- rawActions.push(updateLayoutTypeAction);
579
+ const p = g.getEditArea(), h = f.getTransformerByCreate(), { pages: v, skeHeaders: w, skeFooters: S } = c, O = q.getInstance(), D = [], { drawings: x = {} } = m.getSnapshot();
580
+ for (const R of n) {
581
+ const { drawingId: I } = R, j = x[I].layoutType, H = Ei[t];
582
+ if (j !== H) {
583
+ const C = O.replaceOp(["drawings", I, "layoutType"], j, H);
584
+ D.push(C);
592
585
  }
593
- if (wrappingStyle === "behindText" || wrappingStyle === "inFrontOfText") {
594
- const oldBehindDoc = oldDrawings[drawingId].behindDoc, newBehindDoc = wrappingStyle === "behindText" ? BooleanNumber.TRUE : BooleanNumber.FALSE;
595
- if (oldBehindDoc !== newBehindDoc) {
596
- const updateBehindDocAction = jsonX.replaceOp(["drawings", drawingId, "behindDoc"], oldBehindDoc, newBehindDoc);
597
- rawActions.push(updateBehindDocAction);
586
+ if (t === "behindText" || t === "inFrontOfText") {
587
+ const C = x[I].behindDoc, M = t === "behindText" ? re.TRUE : re.FALSE;
588
+ if (C !== M) {
589
+ const P = O.replaceOp(["drawings", I, "behindDoc"], C, M);
590
+ D.push(P);
598
591
  }
599
592
  }
600
- if (wrappingStyle === "inline")
593
+ if (t === "inline")
601
594
  continue;
602
- let skeDrawing = null, pageMarginTop = 0, pageMarginLeft = 0;
603
- for (const page of pages) {
604
- const { headerId, footerId, marginTop, marginLeft, marginBottom, pageWidth, pageHeight } = page;
605
- switch (editArea) {
606
- case DocumentEditArea.HEADER: {
607
- const headerSke = (_a8 = skeHeaders.get(headerId)) == null ? void 0 : _a8.get(pageWidth);
608
- headerSke != null && headerSke.skeDrawings.has(drawingId) && (skeDrawing = headerSke.skeDrawings.get(drawingId), pageMarginTop = headerSke.marginTop, pageMarginLeft = marginLeft);
595
+ let E = null, W = 0, _ = 0;
596
+ for (const C of v) {
597
+ const { headerId: M, footerId: P, marginTop: L, marginLeft: U, marginBottom: y, pageWidth: A, pageHeight: $ } = C;
598
+ switch (p) {
599
+ case Ue.HEADER: {
600
+ const F = (N = w.get(M)) == null ? void 0 : N.get(A);
601
+ F != null && F.skeDrawings.has(I) && (E = F.skeDrawings.get(I), W = F.marginTop, _ = U);
609
602
  break;
610
603
  }
611
- case DocumentEditArea.FOOTER: {
612
- const footerSke = (_b = skeFooters.get(footerId)) == null ? void 0 : _b.get(pageWidth);
613
- footerSke != null && footerSke.skeDrawings.has(drawingId) && (skeDrawing = footerSke.skeDrawings.get(drawingId), pageMarginTop = pageHeight - marginBottom + footerSke.marginTop, pageMarginLeft = marginLeft);
604
+ case Ue.FOOTER: {
605
+ const F = (B = S.get(P)) == null ? void 0 : B.get(A);
606
+ F != null && F.skeDrawings.has(I) && (E = F.skeDrawings.get(I), W = $ - y + F.marginTop, _ = U);
614
607
  break;
615
608
  }
616
- case DocumentEditArea.BODY: {
617
- page.skeDrawings.has(drawingId) && (skeDrawing = page.skeDrawings.get(drawingId), pageMarginTop = marginTop, pageMarginLeft = marginLeft);
609
+ case Ue.BODY: {
610
+ C.skeDrawings.has(I) && (E = C.skeDrawings.get(I), W = L, _ = U);
618
611
  break;
619
612
  }
620
613
  }
621
- if (skeDrawing != null)
614
+ if (E != null)
622
615
  break;
623
616
  }
624
- if (skeDrawing != null) {
625
- const { aTop, aLeft } = skeDrawing, oldPositionH = oldDrawings[drawingId].docTransform.positionH;
626
- let posOffsetH = aLeft;
627
- oldPositionH.relativeFrom === ObjectRelativeFromH.MARGIN ? posOffsetH -= pageMarginLeft : oldPositionH.relativeFrom === ObjectRelativeFromH.COLUMN && (posOffsetH -= skeDrawing.columnLeft);
628
- const newPositionH = {
629
- relativeFrom: oldPositionH.relativeFrom,
630
- posOffset: posOffsetH
617
+ if (E != null) {
618
+ const { aTop: C, aLeft: M } = E, P = x[I].docTransform.positionH;
619
+ let L = M;
620
+ P.relativeFrom === ee.MARGIN ? L -= _ : P.relativeFrom === ee.COLUMN && (L -= E.columnLeft);
621
+ const U = {
622
+ relativeFrom: P.relativeFrom,
623
+ posOffset: L
631
624
  };
632
- if (oldPositionH.posOffset !== newPositionH.posOffset) {
633
- const action = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionH"], oldPositionH, newPositionH);
634
- rawActions.push(action);
625
+ if (P.posOffset !== U.posOffset) {
626
+ const F = O.replaceOp(["drawings", I, "docTransform", "positionH"], P, U);
627
+ D.push(F);
635
628
  }
636
- const oldPositionV = oldDrawings[drawingId].docTransform.positionV;
637
- let posOffsetV = aTop;
638
- oldPositionV.relativeFrom === ObjectRelativeFromV.PAGE ? posOffsetV += pageMarginTop : oldPositionV.relativeFrom === ObjectRelativeFromV.LINE ? posOffsetV -= skeDrawing.lineTop : oldPositionV.relativeFrom === ObjectRelativeFromV.PARAGRAPH && (posOffsetV -= skeDrawing.blockAnchorTop);
639
- const newPositionV = {
640
- relativeFrom: oldPositionV.relativeFrom,
641
- posOffset: posOffsetV
629
+ const y = x[I].docTransform.positionV;
630
+ let A = C;
631
+ y.relativeFrom === G.PAGE ? A += W : y.relativeFrom === G.LINE ? A -= E.lineTop : y.relativeFrom === G.PARAGRAPH && (A -= E.blockAnchorTop);
632
+ const $ = {
633
+ relativeFrom: y.relativeFrom,
634
+ posOffset: A
642
635
  };
643
- if (oldPositionV.posOffset !== newPositionV.posOffset) {
644
- const action = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionV"], oldPositionV, newPositionV);
645
- rawActions.push(action);
636
+ if (y.posOffset !== $.posOffset) {
637
+ const F = O.replaceOp(["drawings", I, "docTransform", "positionV"], y, $);
638
+ D.push(F);
646
639
  }
647
640
  }
648
641
  }
649
- const doMutation = {
650
- id: RichTextEditingMutation.id,
642
+ const b = {
643
+ id: J.id,
651
644
  params: {
652
- unitId,
645
+ unitId: r,
653
646
  actions: [],
654
647
  textRanges: null
655
648
  }
656
649
  };
657
- doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
658
- const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
659
- return transformer.refreshControls(), !!result;
660
- }, "handler")
661
- }, UpdateDocDrawingDistanceCommand = {
650
+ b.params.actions = D.reduce((R, I) => q.compose(R, I), null);
651
+ const T = o.syncExecuteCommand(b.id, b.params);
652
+ return h.refreshControls(), !!T;
653
+ }
654
+ }, ot = {
662
655
  id: "doc.command.update-doc-drawing-distance",
663
- type: CommandType.COMMAND,
664
- handler: /* @__PURE__ */ __name((accessor, params) => {
665
- if (params == null)
656
+ type: X.COMMAND,
657
+ handler: (i, e) => {
658
+ if (e == null)
666
659
  return !1;
667
- const commandService = accessor.get(ICommandService), documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
668
- if (documentDataModel == null)
660
+ const n = i.get(z), r = i.get(Z).getCurrentUniverDocInstance();
661
+ if (r == null)
669
662
  return !1;
670
- const { drawings, dist, unitId } = params, jsonX = JSONX.getInstance(), rawActions = [], { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
671
- for (const drawing of drawings) {
672
- const { drawingId } = drawing;
673
- for (const [key, value] of Object.entries(dist)) {
674
- const oldValue = oldDrawings[drawingId][key];
675
- if (oldValue !== value) {
676
- const action = jsonX.replaceOp(["drawings", drawingId, key], oldValue, value);
677
- rawActions.push(action);
663
+ const { drawings: o, dist: s, unitId: a } = e, d = q.getInstance(), c = [], { drawings: g = {} } = r.getSnapshot();
664
+ for (const p of o) {
665
+ const { drawingId: h } = p;
666
+ for (const [v, w] of Object.entries(s)) {
667
+ const S = g[h][v];
668
+ if (S !== w) {
669
+ const O = d.replaceOp(["drawings", h, v], S, w);
670
+ c.push(O);
678
671
  }
679
672
  }
680
673
  }
681
- const doMutation = {
682
- id: RichTextEditingMutation.id,
674
+ const f = {
675
+ id: J.id,
683
676
  params: {
684
- unitId,
677
+ unitId: a,
685
678
  actions: [],
686
679
  textRanges: null
687
680
  }
688
681
  };
689
- return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
690
- }, "handler")
691
- }, UpdateDocDrawingWrapTextCommand = {
682
+ return f.params.actions = c.reduce((p, h) => q.compose(p, h), null), !!n.syncExecuteCommand(f.id, f.params);
683
+ }
684
+ }, st = {
692
685
  id: "doc.command.update-doc-drawing-wrap-text",
693
- type: CommandType.COMMAND,
694
- handler: /* @__PURE__ */ __name((accessor, params) => {
695
- if (params == null)
686
+ type: X.COMMAND,
687
+ handler: (i, e) => {
688
+ if (e == null)
696
689
  return !1;
697
- const commandService = accessor.get(ICommandService), documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
698
- if (documentDataModel == null)
690
+ const n = i.get(z), r = i.get(Z).getCurrentUniverDocInstance();
691
+ if (r == null)
699
692
  return !1;
700
- const { drawings, wrapText, unitId } = params, jsonX = JSONX.getInstance(), rawActions = [], { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
701
- for (const drawing of drawings) {
702
- const { drawingId } = drawing, oldWrapText = oldDrawings[drawingId].wrapText;
703
- if (oldWrapText !== wrapText) {
704
- const action = jsonX.replaceOp(["drawings", drawingId, "wrapText"], oldWrapText, wrapText);
705
- rawActions.push(action);
693
+ const { drawings: o, wrapText: s, unitId: a } = e, d = q.getInstance(), c = [], { drawings: g = {} } = r.getSnapshot();
694
+ for (const p of o) {
695
+ const { drawingId: h } = p, v = g[h].wrapText;
696
+ if (v !== s) {
697
+ const w = d.replaceOp(["drawings", h, "wrapText"], v, s);
698
+ c.push(w);
706
699
  }
707
700
  }
708
- const doMutation = {
709
- id: RichTextEditingMutation.id,
701
+ const f = {
702
+ id: J.id,
710
703
  params: {
711
- unitId,
704
+ unitId: a,
712
705
  actions: [],
713
706
  textRanges: null
714
707
  }
715
708
  };
716
- return doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
717
- }, "handler")
718
- }, UpdateDrawingDocTransformCommand = {
709
+ return f.params.actions = c.reduce((p, h) => q.compose(p, h), null), !!n.syncExecuteCommand(f.id, f.params);
710
+ }
711
+ }, ze = {
719
712
  id: "doc.command.update-drawing-doc-transform",
720
- type: CommandType.COMMAND,
721
- handler: /* @__PURE__ */ __name((accessor, params) => {
722
- if (params == null)
713
+ type: X.COMMAND,
714
+ handler: (i, e) => {
715
+ if (e == null)
723
716
  return !1;
724
- const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderObject = accessor.get(IRenderManagerService).getRenderById(params.unitId), scene = renderObject == null ? void 0 : renderObject.scene;
725
- if (scene == null)
717
+ const n = i.get(z), t = i.get(Z), o = i.get(Q).getRenderById(e.unitId), s = o == null ? void 0 : o.scene;
718
+ if (s == null)
726
719
  return !1;
727
- const transformer = scene.getTransformerByCreate(), documentDataModel = univerInstanceService.getCurrentUniverDocInstance();
728
- if (documentDataModel == null)
720
+ const a = s.getTransformerByCreate(), d = t.getCurrentUniverDocInstance();
721
+ if (d == null)
729
722
  return !1;
730
- const { drawings, unitId } = params, jsonX = JSONX.getInstance(), rawActions = [], { drawings: oldDrawings = {} } = documentDataModel.getSnapshot();
731
- for (const drawing of drawings) {
732
- const { drawingId, key, value } = drawing, oldValue = oldDrawings[drawingId].docTransform[key];
733
- if (!Tools.diffValue(oldValue, value)) {
734
- const action = jsonX.replaceOp(["drawings", drawingId, "docTransform", key], oldValue, value);
735
- rawActions.push(action);
723
+ const { drawings: c, unitId: g } = e, f = q.getInstance(), m = [], { drawings: p = {} } = d.getSnapshot();
724
+ for (const w of c) {
725
+ const { drawingId: S, key: O, value: D } = w, x = p[S].docTransform[O];
726
+ if (!Pe.diffValue(x, D)) {
727
+ const b = f.replaceOp(["drawings", S, "docTransform", O], x, D);
728
+ m.push(b);
736
729
  }
737
730
  }
738
- const doMutation = {
739
- id: RichTextEditingMutation.id,
731
+ const h = {
732
+ id: J.id,
740
733
  params: {
741
- unitId,
734
+ unitId: g,
742
735
  actions: [],
743
736
  textRanges: null,
744
737
  debounce: !0
745
738
  }
746
739
  };
747
- doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
748
- const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
749
- return transformer.refreshControls(), !!result;
750
- }, "handler")
751
- }, IMoveInlineDrawingCommand = {
740
+ h.params.actions = m.reduce((w, S) => q.compose(w, S), null);
741
+ const v = n.syncExecuteCommand(h.id, h.params);
742
+ return a.refreshControls(), !!v;
743
+ }
744
+ }, at = {
752
745
  id: "doc.command.move-inline-drawing",
753
- type: CommandType.COMMAND,
754
- handler: /* @__PURE__ */ __name((accessor, params) => {
755
- var _a8, _b;
756
- if (params == null)
746
+ type: X.COMMAND,
747
+ handler: (i, e) => {
748
+ var B, R;
749
+ if (e == null)
757
750
  return !1;
758
- const renderManagerService = accessor.get(IRenderManagerService), docSelectionRenderService = (_a8 = renderManagerService.getRenderById(params.unitId)) == null ? void 0 : _a8.with(DocSelectionRenderService), docRefreshDrawingsService = accessor.get(DocRefreshDrawingsService), renderObject = renderManagerService.getRenderById(params.unitId), scene = renderObject == null ? void 0 : renderObject.scene, skeleton = renderObject == null ? void 0 : renderObject.with(DocSkeletonManagerService).getSkeleton();
759
- if (scene == null || docSelectionRenderService == null)
751
+ const n = i.get(Q), t = (B = n.getRenderById(e.unitId)) == null ? void 0 : B.with(ye), r = i.get(ln), o = n.getRenderById(e.unitId), s = o == null ? void 0 : o.scene, a = o == null ? void 0 : o.with(oe).getSkeleton();
752
+ if (s == null || t == null)
760
753
  return !1;
761
- const transformer = scene.getTransformerByCreate(), commandService = accessor.get(ICommandService), documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
762
- if (documentDataModel == null)
754
+ const d = s.getTransformerByCreate(), c = i.get(z), f = i.get(Z).getCurrentUniverDocInstance();
755
+ if (f == null)
763
756
  return !1;
764
- const { drawing, unitId, offset, segmentId: newSegmentId, segmentPage, needRefreshDrawings } = params;
765
- if (needRefreshDrawings)
766
- return docRefreshDrawingsService.refreshDrawings(skeleton), transformer.refreshControls(), !0;
767
- const rawActions = [], { drawingId } = drawing, segmentId = (_b = docSelectionRenderService.getSegment()) != null ? _b : "", actions = getDeleteAndInsertCustomBlockActions(
768
- newSegmentId,
769
- segmentId,
770
- segmentPage,
771
- offset,
772
- drawingId,
773
- documentDataModel,
774
- docSelectionRenderService
757
+ const { drawing: m, unitId: p, offset: h, segmentId: v, segmentPage: w, needRefreshDrawings: S } = e;
758
+ if (S)
759
+ return r.refreshDrawings(a), d.refreshControls(), !0;
760
+ const O = [], { drawingId: D } = m, x = (R = t.getSegment()) != null ? R : "", b = it(
761
+ v,
762
+ x,
763
+ w,
764
+ h,
765
+ D,
766
+ f,
767
+ t
775
768
  );
776
- if (actions == null || actions.length === 0)
777
- return docRefreshDrawingsService.refreshDrawings(skeleton), transformer.refreshControls(), !1;
778
- rawActions.push(...actions);
779
- const doMutation = {
780
- id: RichTextEditingMutation.id,
769
+ if (b == null || b.length === 0)
770
+ return r.refreshDrawings(a), d.refreshControls(), !1;
771
+ O.push(...b);
772
+ const T = {
773
+ id: J.id,
781
774
  params: {
782
- unitId,
775
+ unitId: p,
783
776
  actions: [],
784
777
  textRanges: null
785
778
  }
786
779
  };
787
- doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
788
- const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
789
- return transformer.refreshControls(), !!result;
790
- }, "handler")
791
- }, ITransformNonInlineDrawingCommand = {
780
+ T.params.actions = O.reduce((I, j) => q.compose(I, j), null);
781
+ const N = c.syncExecuteCommand(T.id, T.params);
782
+ return d.refreshControls(), !!N;
783
+ }
784
+ }, ct = {
792
785
  id: "doc.command.transform-non-inline-drawing",
793
- type: CommandType.COMMAND,
786
+ type: X.COMMAND,
794
787
  // eslint-disable-next-line max-lines-per-function
795
- handler: /* @__PURE__ */ __name((accessor, params) => {
796
- var _a8, _b;
797
- if (params == null)
788
+ handler: (i, e) => {
789
+ var E, W;
790
+ if (e == null)
798
791
  return !1;
799
- const renderManagerService = accessor.get(IRenderManagerService), docSelectionRenderService = (_a8 = renderManagerService.getRenderById(params.unitId)) == null ? void 0 : _a8.with(DocSelectionRenderService), renderObject = renderManagerService.getRenderById(params.unitId), scene = renderObject == null ? void 0 : renderObject.scene;
800
- if (scene == null || docSelectionRenderService == null)
792
+ const n = i.get(Q), t = (E = n.getRenderById(e.unitId)) == null ? void 0 : E.with(ye), r = n.getRenderById(e.unitId), o = r == null ? void 0 : r.scene;
793
+ if (o == null || t == null)
801
794
  return !1;
802
- const transformer = scene.getTransformerByCreate(), commandService = accessor.get(ICommandService), documentDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
803
- if (documentDataModel == null)
795
+ const s = o.getTransformerByCreate(), a = i.get(z), c = i.get(Z).getCurrentUniverDocInstance();
796
+ if (c == null)
804
797
  return !1;
805
- const { drawing, unitId, offset, docTransform, segmentId: newSegmentId, segmentPage } = params, rawActions = [], { drawingId } = drawing, segmentId = (_b = docSelectionRenderService.getSegment()) != null ? _b : "", actions = getDeleteAndInsertCustomBlockActions(
806
- newSegmentId,
807
- segmentId,
808
- segmentPage,
809
- offset,
810
- drawingId,
811
- documentDataModel,
812
- docSelectionRenderService
798
+ const { drawing: g, unitId: f, offset: m, docTransform: p, segmentId: h, segmentPage: v } = e, w = [], { drawingId: S } = g, O = (W = t.getSegment()) != null ? W : "", D = it(
799
+ h,
800
+ O,
801
+ v,
802
+ m,
803
+ S,
804
+ c,
805
+ t
813
806
  );
814
- if (actions == null)
807
+ if (D == null)
815
808
  return !1;
816
- actions.length > 0 && rawActions.push(...actions);
817
- const jsonX = JSONX.getInstance(), { drawings: oldDrawings = {} } = documentDataModel.getSnapshot(), oldDocTransform = oldDrawings[drawingId].docTransform, { positionH: oldPositionH, positionV: oldPositionV, size: oldSize, angle: oldAngle } = oldDocTransform;
818
- if (!Tools.diffValue(oldPositionH, docTransform.positionH)) {
819
- const updateAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionH"], oldPositionH, docTransform.positionH);
820
- rawActions.push(updateAction);
809
+ D.length > 0 && w.push(...D);
810
+ const x = q.getInstance(), { drawings: b = {} } = c.getSnapshot(), T = b[S].docTransform, { positionH: N, positionV: B, size: R, angle: I } = T;
811
+ if (!Pe.diffValue(N, p.positionH)) {
812
+ const _ = x.replaceOp(["drawings", S, "docTransform", "positionH"], N, p.positionH);
813
+ w.push(_);
821
814
  }
822
- if (!Tools.diffValue(oldPositionV, docTransform.positionV)) {
823
- const updateAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "positionV"], oldPositionV, docTransform.positionV);
824
- rawActions.push(updateAction);
815
+ if (!Pe.diffValue(B, p.positionV)) {
816
+ const _ = x.replaceOp(["drawings", S, "docTransform", "positionV"], B, p.positionV);
817
+ w.push(_);
825
818
  }
826
- if (!Tools.diffValue(oldSize, docTransform.size)) {
827
- const updateAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "size"], oldSize, docTransform.size);
828
- rawActions.push(updateAction);
819
+ if (!Pe.diffValue(R, p.size)) {
820
+ const _ = x.replaceOp(["drawings", S, "docTransform", "size"], R, p.size);
821
+ w.push(_);
829
822
  }
830
- if (!Tools.diffValue(oldAngle, docTransform.angle)) {
831
- const updateAction = jsonX.replaceOp(["drawings", drawingId, "docTransform", "angle"], oldAngle, docTransform.angle);
832
- rawActions.push(updateAction);
823
+ if (!Pe.diffValue(I, p.angle)) {
824
+ const _ = x.replaceOp(["drawings", S, "docTransform", "angle"], I, p.angle);
825
+ w.push(_);
833
826
  }
834
- const doMutation = {
835
- id: RichTextEditingMutation.id,
827
+ const j = {
828
+ id: J.id,
836
829
  params: {
837
- unitId,
830
+ unitId: f,
838
831
  actions: [],
839
832
  textRanges: null,
840
833
  debounce: !0
841
834
  }
842
835
  };
843
- doMutation.params.actions = rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null);
844
- const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
845
- return transformer.refreshControls(), !!result;
846
- }, "handler")
847
- }, MoveDocDrawingsCommand = {
836
+ j.params.actions = w.reduce((_, C) => q.compose(_, C), null);
837
+ const H = a.syncExecuteCommand(j.id, j.params);
838
+ return s.refreshControls(), !!H;
839
+ }
840
+ }, Xe = {
848
841
  id: "doc.command.move-drawing",
849
- type: CommandType.COMMAND,
850
- handler: /* @__PURE__ */ __name((accessor, params) => {
851
- const commandService = accessor.get(ICommandService), docDrawingService = accessor.get(IDocDrawingService), univerInstanceService = accessor.get(IUniverInstanceService), renderManagerService = accessor.get(IRenderManagerService), { direction } = params, drawings = docDrawingService.getFocusDrawings();
852
- if (drawings.length === 0)
842
+ type: X.COMMAND,
843
+ handler: (i, e) => {
844
+ const n = i.get(z), t = i.get(je), r = i.get(Z), o = i.get(Q), { direction: s } = e, a = t.getFocusDrawings();
845
+ if (a.length === 0)
853
846
  return !1;
854
- const unitId = drawings[0].unitId, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
855
- if (scene == null)
847
+ const d = a[0].unitId, c = o.getRenderById(d), g = c == null ? void 0 : c.scene;
848
+ if (g == null)
856
849
  return !1;
857
- const transformer = scene.getTransformerByCreate(), documentDataModel = univerInstanceService.getUniverDocInstance(unitId), newDrawings = drawings.map((drawing) => {
858
- var _a8, _b, _c, _d, _e;
859
- const { drawingId } = drawing, drawingData = (_a8 = documentDataModel == null ? void 0 : documentDataModel.getSnapshot().drawings) == null ? void 0 : _a8[drawingId];
860
- if (drawingData == null || drawingData.layoutType === PositionedObjectLayoutType.INLINE)
850
+ const f = g.getTransformerByCreate(), m = r.getUniverDocInstance(d), p = a.map((v) => {
851
+ var T, N, B, R, I;
852
+ const { drawingId: w } = v, S = (T = m == null ? void 0 : m.getSnapshot().drawings) == null ? void 0 : T[w];
853
+ if (S == null || S.layoutType === k.INLINE)
861
854
  return null;
862
- const { positionH, positionV } = drawingData.docTransform, newPositionH = { ...positionH }, newPositionV = { ...positionV };
863
- return direction === Direction.UP ? newPositionV.posOffset = ((_b = newPositionV.posOffset) != null ? _b : 0) - 2 : direction === Direction.DOWN ? newPositionV.posOffset = ((_c = newPositionV.posOffset) != null ? _c : 0) + 2 : direction === Direction.LEFT ? newPositionH.posOffset = ((_d = newPositionH.posOffset) != null ? _d : 0) - 2 : direction === Direction.RIGHT && (newPositionH.posOffset = ((_e = newPositionH.posOffset) != null ? _e : 0) + 2), {
864
- drawingId,
865
- key: direction === Direction.UP || direction === Direction.DOWN ? "positionV" : "positionH",
866
- value: direction === Direction.UP || direction === Direction.DOWN ? newPositionV : newPositionH
855
+ const { positionH: O, positionV: D } = S.docTransform, x = { ...O }, b = { ...D };
856
+ return s === ue.UP ? b.posOffset = ((N = b.posOffset) != null ? N : 0) - 2 : s === ue.DOWN ? b.posOffset = ((B = b.posOffset) != null ? B : 0) + 2 : s === ue.LEFT ? x.posOffset = ((R = x.posOffset) != null ? R : 0) - 2 : s === ue.RIGHT && (x.posOffset = ((I = x.posOffset) != null ? I : 0) + 2), {
857
+ drawingId: w,
858
+ key: s === ue.UP || s === ue.DOWN ? "positionV" : "positionH",
859
+ value: s === ue.UP || s === ue.DOWN ? b : x
867
860
  };
868
- }).filter((drawing) => drawing != null);
869
- if (newDrawings.length === 0)
861
+ }).filter((v) => v != null);
862
+ if (p.length === 0)
870
863
  return !1;
871
- const result = commandService.syncExecuteCommand(UpdateDrawingDocTransformCommand.id, {
872
- unitId,
873
- subUnitId: unitId,
874
- drawings: newDrawings
864
+ const h = n.syncExecuteCommand(ze.id, {
865
+ unitId: d,
866
+ subUnitId: d,
867
+ drawings: p
875
868
  });
876
- return transformer.refreshControls(), !!result;
877
- }, "handler")
878
- }, ClearDocDrawingTransformerOperation = {
869
+ return f.refreshControls(), !!h;
870
+ }
871
+ }, ji = {
879
872
  id: "doc.operation.clear-drawing-transformer",
880
- type: CommandType.MUTATION,
881
- handler: /* @__PURE__ */ __name((accessor, params) => {
882
- const renderManagerService = accessor.get(IRenderManagerService);
883
- return params.forEach((unitId) => {
884
- var _a8, _b;
885
- (_b = (_a8 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a8.scene.getTransformer()) == null || _b.debounceRefreshControls();
873
+ type: X.MUTATION,
874
+ handler: (i, e) => {
875
+ const n = i.get(Q);
876
+ return e.forEach((t) => {
877
+ var r, o;
878
+ (o = (r = n.getRenderById(t)) == null ? void 0 : r.scene.getTransformer()) == null || o.debounceRefreshControls();
886
879
  }), !0;
887
- }, "handler")
888
- }, COMPONENT_DOC_DRAWING_PANEL = "COMPONENT_DOC_DRAWING_PANEL", SidebarDocDrawingOperation = {
880
+ }
881
+ }, dt = "COMPONENT_DOC_DRAWING_PANEL", lt = {
889
882
  id: "sidebar.operation.doc-image",
890
- type: CommandType.COMMAND,
891
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
892
- const sidebarService = accessor.get(ISidebarService), localeService = accessor.get(LocaleService), drawingManagerService = accessor.get(IDrawingManagerService);
893
- switch (params.value) {
883
+ type: X.COMMAND,
884
+ handler: async (i, e) => {
885
+ const n = i.get(ri), t = i.get(dn), r = i.get(ve);
886
+ switch (e.value) {
894
887
  case "open":
895
- sidebarService.open({
896
- header: { title: localeService.t("docImage.panel.title") },
897
- children: { label: COMPONENT_DOC_DRAWING_PANEL },
898
- onClose: /* @__PURE__ */ __name(() => {
899
- drawingManagerService.focusDrawing(null);
900
- }, "onClose"),
888
+ n.open({
889
+ header: { title: t.t("docImage.panel.title") },
890
+ children: { label: dt },
891
+ onClose: () => {
892
+ r.focusDrawing(null);
893
+ },
901
894
  width: 360
902
895
  });
903
896
  break;
904
897
  case "close":
905
898
  default:
906
- sidebarService.close();
899
+ n.close();
907
900
  break;
908
901
  }
909
902
  return !0;
910
- }, "handler")
911
- }, EditDocDrawingOperation = {
903
+ }
904
+ }, gt = {
912
905
  id: "doc.operation.edit-doc-image",
913
- type: CommandType.OPERATION,
914
- handler: /* @__PURE__ */ __name((accessor, params) => {
915
- const drawingManagerService = accessor.get(IDrawingManagerService), commandService = accessor.get(ICommandService);
916
- return params == null ? !1 : (drawingManagerService.focusDrawing([params]), commandService.executeCommand(SidebarDocDrawingOperation.id, { value: "open" }), !0);
917
- }, "handler")
906
+ type: X.OPERATION,
907
+ handler: (i, e) => {
908
+ const n = i.get(ve), t = i.get(z);
909
+ return e == null ? !1 : (n.focusDrawing([e]), t.executeCommand(lt.id, { value: "open" }), !0);
910
+ }
918
911
  };
919
- function r(e) {
920
- var t, f, n = "";
921
- if (typeof e == "string" || typeof e == "number") n += e;
922
- else if (typeof e == "object") if (Array.isArray(e)) {
923
- var o = e.length;
924
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
925
- } else for (f in e) e[f] && (n && (n += " "), n += f);
926
- return n;
912
+ var mt = { exports: {} }, gn = {};
913
+ /**
914
+ * @license React
915
+ * react-jsx-runtime.production.min.js
916
+ *
917
+ * Copyright (c) Facebook, Inc. and its affiliates.
918
+ *
919
+ * This source code is licensed under the MIT license found in the
920
+ * LICENSE file in the root directory of this source tree.
921
+ */
922
+ var Li = Ci, Bi = Symbol.for("react.element"), Ui = Symbol.for("react.fragment"), Fi = Object.prototype.hasOwnProperty, ki = Li.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Hi = { key: !0, ref: !0, __self: !0, __source: !0 };
923
+ function ut(i, e, n) {
924
+ var t, r = {}, o = null, s = null;
925
+ n !== void 0 && (o = "" + n), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
926
+ for (t in e) Fi.call(e, t) && !Hi.hasOwnProperty(t) && (r[t] = e[t]);
927
+ if (i && i.defaultProps) for (t in e = i.defaultProps, e) r[t] === void 0 && (r[t] = e[t]);
928
+ return { $$typeof: Bi, type: i, key: o, ref: s, props: r, _owner: ki.current };
927
929
  }
928
- __name(r, "r");
929
- function clsx() {
930
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
931
- return n;
930
+ gn.Fragment = Ui;
931
+ gn.jsx = ut;
932
+ gn.jsxs = ut;
933
+ mt.exports = gn;
934
+ var l = mt.exports;
935
+ function ft(i) {
936
+ var e, n, t = "";
937
+ if (typeof i == "string" || typeof i == "number") t += i;
938
+ else if (typeof i == "object") if (Array.isArray(i)) {
939
+ var r = i.length;
940
+ for (e = 0; e < r; e++) i[e] && (n = ft(i[e])) && (t && (t += " "), t += n);
941
+ } else for (n in i) i[n] && (t && (t += " "), t += n);
942
+ return t;
932
943
  }
933
- __name(clsx, "clsx");
934
- const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", sheetImageMenu = "univer-sheet-image-menu", sheetImageMenuInput = "univer-sheet-image-menu-input", styles = {
935
- imageCommonPanel,
936
- imageCommonPanelGrid,
937
- imageCommonPanelBorder,
938
- imageCommonPanelTitle,
939
- imageCommonPanelSubtitle,
940
- imageCommonPanelRow,
941
- imageCommonPanelRowVertical,
942
- imageCommonPanelColumn,
943
- imageCommonPanelColumnCenter,
944
- imageCommonPanelInline,
945
- imageCommonPanelSpan2,
946
- imageCommonPanelSpan3,
947
- imageCommonPanelInput,
948
- sheetImageMenu,
949
- sheetImageMenuInput
950
- }, MIN_OFFSET = -1e3, MAX_OFFSET = 1e3, DocDrawingPosition = /* @__PURE__ */ __name((props) => {
951
- const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), { drawings } = props, drawingParam = drawings[0];
952
- if (drawingParam == null)
944
+ function V() {
945
+ for (var i, e, n = 0, t = "", r = arguments.length; n < r; n++) (i = arguments[n]) && (e = ft(i)) && (t && (t += " "), t += e);
946
+ return t;
947
+ }
948
+ const Wi = "univer-image-common-panel", Gi = "univer-image-common-panel-grid", Vi = "univer-image-common-panel-border", $i = "univer-image-common-panel-title", zi = "univer-image-common-panel-subtitle", qi = "univer-image-common-panel-row", Xi = "univer-image-common-panel-row-vertical", Ki = "univer-image-common-panel-column", Yi = "univer-image-common-panel-column-center", Zi = "univer-image-common-panel-inline", Ji = "univer-image-common-panel-span2", Qi = "univer-image-common-panel-span3", er = "univer-image-common-panel-input", nr = "univer-sheet-image-menu", tr = "univer-sheet-image-menu-input", u = {
949
+ imageCommonPanel: Wi,
950
+ imageCommonPanelGrid: Gi,
951
+ imageCommonPanelBorder: Vi,
952
+ imageCommonPanelTitle: $i,
953
+ imageCommonPanelSubtitle: zi,
954
+ imageCommonPanelRow: qi,
955
+ imageCommonPanelRowVertical: Xi,
956
+ imageCommonPanelColumn: Ki,
957
+ imageCommonPanelColumnCenter: Yi,
958
+ imageCommonPanelInline: Zi,
959
+ imageCommonPanelSpan2: Ji,
960
+ imageCommonPanelSpan3: Qi,
961
+ imageCommonPanelInput: er,
962
+ sheetImageMenu: nr,
963
+ sheetImageMenuInput: tr
964
+ }, Un = -1e3, Fn = 1e3, ir = (i) => {
965
+ const e = pe(z), n = pe(dn), t = pe(ve), r = pe(Q), o = pe(Z), { drawings: s } = i, a = s[0];
966
+ if (a == null)
953
967
  return;
954
- const { unitId } = drawingParam, documentDataModel = univerInstanceService.getUniverDocInstance(unitId), documentFlavor = documentDataModel == null ? void 0 : documentDataModel.getSnapshot().documentStyle.documentFlavor, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
955
- if (scene == null)
968
+ const { unitId: d } = a, c = o.getUniverDocInstance(d), g = c == null ? void 0 : c.getSnapshot().documentStyle.documentFlavor, f = r.getRenderById(d), m = f == null ? void 0 : f.scene;
969
+ if (m == null)
956
970
  return;
957
- const transformer = scene.getTransformerByCreate(), HORIZONTAL_RELATIVE_FROM = [{
958
- label: localeService.t("image-position.column"),
959
- value: String(ObjectRelativeFromH.COLUMN)
971
+ const p = m.getTransformerByCreate(), h = [{
972
+ label: n.t("image-position.column"),
973
+ value: String(ee.COLUMN)
960
974
  }, {
961
- label: localeService.t("image-position.page"),
962
- value: String(ObjectRelativeFromH.PAGE)
975
+ label: n.t("image-position.page"),
976
+ value: String(ee.PAGE)
963
977
  }, {
964
- label: localeService.t("image-position.margin"),
965
- value: String(ObjectRelativeFromH.MARGIN)
966
- }], VERTICAL_RELATIVE_FROM = [{
967
- label: localeService.t("image-position.line"),
968
- value: String(ObjectRelativeFromV.LINE),
969
- disabled: documentFlavor === DocumentFlavor.MODERN
978
+ label: n.t("image-position.margin"),
979
+ value: String(ee.MARGIN)
980
+ }], v = [{
981
+ label: n.t("image-position.line"),
982
+ value: String(G.LINE),
983
+ disabled: g === fn.MODERN
970
984
  }, {
971
- label: localeService.t("image-position.page"),
972
- value: String(ObjectRelativeFromV.PAGE),
973
- disabled: documentFlavor === DocumentFlavor.MODERN
985
+ label: n.t("image-position.page"),
986
+ value: String(G.PAGE),
987
+ disabled: g === fn.MODERN
974
988
  }, {
975
- label: localeService.t("image-position.margin"),
976
- value: String(ObjectRelativeFromV.MARGIN),
977
- disabled: documentFlavor === DocumentFlavor.MODERN
989
+ label: n.t("image-position.margin"),
990
+ value: String(G.MARGIN),
991
+ disabled: g === fn.MODERN
978
992
  }, {
979
- label: localeService.t("image-position.paragraph"),
980
- value: String(ObjectRelativeFromV.PARAGRAPH)
981
- }], [disabled, setDisabled] = useState(!0), [hPosition, setHPosition] = useState({
982
- relativeFrom: ObjectRelativeFromH.PAGE,
993
+ label: n.t("image-position.paragraph"),
994
+ value: String(G.PARAGRAPH)
995
+ }], [w, S] = ie(!0), [O, D] = ie({
996
+ relativeFrom: ee.PAGE,
983
997
  posOffset: 0
984
- }), [vPosition, setVPosition] = useState({
985
- relativeFrom: ObjectRelativeFromV.PAGE,
998
+ }), [x, b] = ie({
999
+ relativeFrom: G.PAGE,
986
1000
  posOffset: 0
987
- }), [followTextMove, setFollowTextMove] = useState(!0), [showPanel, setShowPanel] = useState(!0);
988
- function handlePositionChange(direction, value) {
989
- var _a8;
990
- direction === "positionH" ? setHPosition(value) : setVPosition(value);
991
- const focusDrawings = drawingManagerService.getFocusDrawings();
992
- if (focusDrawings.length === 0)
1001
+ }), [T, N] = ie(!0), [B, R] = ie(!0);
1002
+ function I(C, M) {
1003
+ var y;
1004
+ C === "positionH" ? D(M) : b(M);
1005
+ const P = t.getFocusDrawings();
1006
+ if (P.length === 0)
993
1007
  return;
994
- const drawings2 = focusDrawings.map((drawing) => ({
995
- unitId: drawing.unitId,
996
- subUnitId: drawing.subUnitId,
997
- drawingId: drawing.drawingId
1008
+ const L = P.map((A) => ({
1009
+ unitId: A.unitId,
1010
+ subUnitId: A.subUnitId,
1011
+ drawingId: A.drawingId
998
1012
  }));
999
- commandService.executeCommand(UpdateDrawingDocTransformCommand.id, {
1000
- unitId: focusDrawings[0].unitId,
1001
- subUnitId: focusDrawings[0].unitId,
1002
- drawings: drawings2.map((drawing) => ({
1003
- drawingId: drawing.drawingId,
1004
- key: direction,
1005
- value
1013
+ e.executeCommand(ze.id, {
1014
+ unitId: P[0].unitId,
1015
+ subUnitId: P[0].unitId,
1016
+ drawings: L.map((A) => ({
1017
+ drawingId: A.drawingId,
1018
+ key: C,
1019
+ value: M
1006
1020
  }))
1007
1021
  });
1008
- const docSelectionRenderService = (_a8 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a8.with(DocSelectionRenderService);
1009
- docSelectionRenderService && docSelectionRenderService.blur(), transformer.refreshControls();
1010
- }
1011
- __name(handlePositionChange, "handlePositionChange");
1012
- function handleHorizontalRelativeFromChange(value) {
1013
- var _a8, _b, _c;
1014
- const prevRelativeFrom = hPosition.relativeFrom, prevPosOffset = hPosition.posOffset, relativeFrom = Number(value);
1015
- if (prevRelativeFrom === relativeFrom)
1022
+ const U = (y = r.getRenderById(d)) == null ? void 0 : y.with(ye);
1023
+ U && U.blur(), p.refreshControls();
1024
+ }
1025
+ function j(C) {
1026
+ var te, Ie, _e;
1027
+ const M = O.relativeFrom, P = O.posOffset, L = Number(C);
1028
+ if (M === L)
1016
1029
  return;
1017
- const focusDrawings = drawingManagerService.getFocusDrawings();
1018
- if (focusDrawings.length === 0)
1030
+ const U = t.getFocusDrawings();
1031
+ if (U.length === 0)
1019
1032
  return;
1020
- const drawingId = focusDrawings[0].drawingId, unitId2 = focusDrawings[0].unitId;
1021
- let drawing = null, pageMarginLeft = 0;
1022
- const skeleton = (_a8 = renderManagerService.getRenderById(unitId2)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getSkeleton(), skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData();
1023
- if (skeletonData == null)
1033
+ const y = U[0].drawingId, A = U[0].unitId;
1034
+ let $ = null, F = 0;
1035
+ const K = (te = r.getRenderById(A)) == null ? void 0 : te.with(oe).getSkeleton(), se = K == null ? void 0 : K.getSkeletonData();
1036
+ if (se == null)
1024
1037
  return;
1025
- const { pages, skeHeaders, skeFooters } = skeletonData;
1026
- for (const page of pages) {
1027
- const { marginLeft, skeDrawings, headerId, footerId, pageWidth } = page;
1028
- if (skeDrawings.has(drawingId)) {
1029
- drawing = skeDrawings.get(drawingId), pageMarginLeft = marginLeft;
1038
+ const { pages: Le, skeHeaders: be, skeFooters: ke } = se;
1039
+ for (const ce of Le) {
1040
+ const { marginLeft: Ce, skeDrawings: De, headerId: Me, footerId: Re, pageWidth: Oe } = ce;
1041
+ if (De.has(y)) {
1042
+ $ = De.get(y), F = Ce;
1030
1043
  break;
1031
1044
  }
1032
- const headerPage = (_b = skeHeaders.get(headerId)) == null ? void 0 : _b.get(pageWidth);
1033
- if (headerPage != null && headerPage.skeDrawings.has(drawingId)) {
1034
- drawing = headerPage == null ? void 0 : headerPage.skeDrawings.get(drawingId), pageMarginLeft = marginLeft;
1045
+ const de = (Ie = be.get(Me)) == null ? void 0 : Ie.get(Oe);
1046
+ if (de != null && de.skeDrawings.has(y)) {
1047
+ $ = de == null ? void 0 : de.skeDrawings.get(y), F = Ce;
1035
1048
  break;
1036
1049
  }
1037
- const footerPage = (_c = skeFooters.get(footerId)) == null ? void 0 : _c.get(pageWidth);
1038
- if (footerPage != null && footerPage.skeDrawings.has(drawingId)) {
1039
- drawing = footerPage == null ? void 0 : footerPage.skeDrawings.get(drawingId), pageMarginLeft = marginLeft;
1050
+ const le = (_e = ke.get(Re)) == null ? void 0 : _e.get(Oe);
1051
+ if (le != null && le.skeDrawings.has(y)) {
1052
+ $ = le == null ? void 0 : le.skeDrawings.get(y), F = Ce;
1040
1053
  break;
1041
1054
  }
1042
1055
  }
1043
- if (drawing == null)
1056
+ if ($ == null)
1044
1057
  return;
1045
- let delta = 0;
1046
- prevRelativeFrom === ObjectRelativeFromH.COLUMN ? delta -= drawing.columnLeft : prevRelativeFrom === ObjectRelativeFromH.MARGIN && (delta -= pageMarginLeft), relativeFrom === ObjectRelativeFromH.COLUMN ? delta += drawing.columnLeft : relativeFrom === ObjectRelativeFromH.MARGIN ? delta += pageMarginLeft : ObjectRelativeFromH.PAGE;
1047
- const newPositionH = {
1048
- relativeFrom,
1049
- posOffset: (prevPosOffset != null ? prevPosOffset : 0) - delta
1058
+ let ae = 0;
1059
+ M === ee.COLUMN ? ae -= $.columnLeft : M === ee.MARGIN && (ae -= F), L === ee.COLUMN ? ae += $.columnLeft : L === ee.MARGIN ? ae += F : ee.PAGE;
1060
+ const ne = {
1061
+ relativeFrom: L,
1062
+ posOffset: (P != null ? P : 0) - ae
1050
1063
  };
1051
- handlePositionChange("positionH", newPositionH);
1064
+ I("positionH", ne);
1052
1065
  }
1053
- __name(handleHorizontalRelativeFromChange, "handleHorizontalRelativeFromChange");
1054
- function handleVerticalRelativeFromChange(value) {
1055
- var _a8, _b, _c, _d, _e, _f;
1056
- const prevRelativeFrom = vPosition.relativeFrom, prevPosOffset = vPosition.posOffset, relativeFrom = Number(value);
1057
- if (prevRelativeFrom === relativeFrom)
1066
+ function H(C) {
1067
+ var De, Me, Re, Oe, de, le;
1068
+ const M = x.relativeFrom, P = x.posOffset, L = Number(C);
1069
+ if (M === L)
1058
1070
  return;
1059
- const focusDrawings = drawingManagerService.getFocusDrawings();
1060
- if (focusDrawings.length === 0)
1071
+ const U = t.getFocusDrawings();
1072
+ if (U.length === 0)
1061
1073
  return;
1062
- const { drawingId, unitId: unitId2 } = focusDrawings[0], documentDataModel2 = univerInstanceService.getUniverDocInstance(unitId2), skeleton = (_a8 = renderManagerService.getRenderById(unitId2)) == null ? void 0 : _a8.with(DocSkeletonManagerService).getSkeleton(), docSelectionRenderService = (_b = renderManagerService.getRenderById(unitId2)) == null ? void 0 : _b.with(DocSelectionRenderService), segmentId = docSelectionRenderService == null ? void 0 : docSelectionRenderService.getSegment(), segmentPage = docSelectionRenderService == null ? void 0 : docSelectionRenderService.getSegmentPage(), drawing = (_d = (_c = documentDataModel2 == null ? void 0 : documentDataModel2.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _c.customBlocks) == null ? void 0 : _d.find((c) => c.blockId === drawingId);
1063
- if (drawing == null || skeleton == null || docSelectionRenderService == null)
1074
+ const { drawingId: y, unitId: A } = U[0], $ = o.getUniverDocInstance(A), F = (De = r.getRenderById(A)) == null ? void 0 : De.with(oe).getSkeleton(), K = (Me = r.getRenderById(A)) == null ? void 0 : Me.with(ye), se = K == null ? void 0 : K.getSegment(), Le = K == null ? void 0 : K.getSegmentPage(), be = (Oe = (Re = $ == null ? void 0 : $.getSelfOrHeaderFooterModel(se).getBody()) == null ? void 0 : Re.customBlocks) == null ? void 0 : Oe.find((Ne) => Ne.blockId === y);
1075
+ if (be == null || F == null || K == null)
1064
1076
  return;
1065
- const { startIndex } = drawing, glyph = skeleton.findNodeByCharIndex(startIndex, segmentId, segmentPage), line = (_e = glyph == null ? void 0 : glyph.parent) == null ? void 0 : _e.parent, column = line == null ? void 0 : line.parent, paragraphStartLine = column == null ? void 0 : column.lines.find((l) => l.paragraphIndex === (line == null ? void 0 : line.paragraphIndex) && l.paragraphStart), page = (_f = column == null ? void 0 : column.parent) == null ? void 0 : _f.parent;
1066
- if (glyph == null || line == null || paragraphStartLine == null || column == null || page == null)
1077
+ const { startIndex: ke } = be, ae = F.findNodeByCharIndex(ke, se, Le), ne = (de = ae == null ? void 0 : ae.parent) == null ? void 0 : de.parent, te = ne == null ? void 0 : ne.parent, Ie = te == null ? void 0 : te.lines.find((Ne) => Ne.paragraphIndex === (ne == null ? void 0 : ne.paragraphIndex) && Ne.paragraphStart), _e = (le = te == null ? void 0 : te.parent) == null ? void 0 : le.parent;
1078
+ if (ae == null || ne == null || Ie == null || te == null || _e == null)
1067
1079
  return;
1068
- let delta = 0;
1069
- prevRelativeFrom === ObjectRelativeFromV.PARAGRAPH ? delta -= paragraphStartLine.top : prevRelativeFrom === ObjectRelativeFromV.LINE ? delta -= line.top : prevRelativeFrom === ObjectRelativeFromV.PAGE && (delta += page.marginTop), relativeFrom === ObjectRelativeFromV.PARAGRAPH ? delta += paragraphStartLine.top : relativeFrom === ObjectRelativeFromV.LINE ? delta += line.top : relativeFrom === ObjectRelativeFromV.PAGE && (delta -= page.marginTop);
1070
- const newPositionV = {
1071
- relativeFrom,
1072
- posOffset: (prevPosOffset != null ? prevPosOffset : 0) - delta
1080
+ let ce = 0;
1081
+ M === G.PARAGRAPH ? ce -= Ie.top : M === G.LINE ? ce -= ne.top : M === G.PAGE && (ce += _e.marginTop), L === G.PARAGRAPH ? ce += Ie.top : L === G.LINE ? ce += ne.top : L === G.PAGE && (ce -= _e.marginTop);
1082
+ const Ce = {
1083
+ relativeFrom: L,
1084
+ posOffset: (P != null ? P : 0) - ce
1073
1085
  };
1074
- handlePositionChange("positionV", newPositionV);
1086
+ I("positionV", Ce);
1075
1087
  }
1076
- __name(handleVerticalRelativeFromChange, "handleVerticalRelativeFromChange");
1077
- function updateState(drawingParam2) {
1078
- var _a8;
1079
- const snapshot = documentDataModel == null ? void 0 : documentDataModel.getSnapshot(), drawing = (_a8 = snapshot == null ? void 0 : snapshot.drawings) == null ? void 0 : _a8[drawingParam2.drawingId];
1080
- if (drawing == null)
1088
+ function E(C) {
1089
+ var A;
1090
+ const M = c == null ? void 0 : c.getSnapshot(), P = (A = M == null ? void 0 : M.drawings) == null ? void 0 : A[C.drawingId];
1091
+ if (P == null)
1081
1092
  return;
1082
- const { layoutType } = drawing, {
1083
- positionH,
1084
- positionV
1085
- } = drawing.docTransform;
1086
- setHPosition(positionH), setVPosition(positionV), setDisabled(layoutType === PositionedObjectLayoutType.INLINE), setFollowTextMove(positionV.relativeFrom === ObjectRelativeFromV.PARAGRAPH || positionV.relativeFrom === ObjectRelativeFromV.LINE);
1087
- }
1088
- __name(updateState, "updateState");
1089
- function updateFocusDrawingState() {
1090
- const focusDrawings = drawingManagerService.getFocusDrawings();
1091
- focusDrawings.length !== 0 && updateState(focusDrawings[0]);
1092
- }
1093
- __name(updateFocusDrawingState, "updateFocusDrawingState");
1094
- function handleFollowTextMoveCheck(val) {
1095
- setFollowTextMove(val), handleVerticalRelativeFromChange(String(val ? ObjectRelativeFromV.PARAGRAPH : ObjectRelativeFromV.PAGE));
1096
- }
1097
- return __name(handleFollowTextMoveCheck, "handleFollowTextMoveCheck"), useEffect(() => {
1098
- updateFocusDrawingState();
1099
- const subscription = drawingManagerService.focus$.subscribe((drawingParams) => {
1100
- if (drawingParams.length === 0) {
1101
- setShowPanel(!1);
1093
+ const { layoutType: L } = P, {
1094
+ positionH: U,
1095
+ positionV: y
1096
+ } = P.docTransform;
1097
+ D(U), b(y), S(L === k.INLINE), N(y.relativeFrom === G.PARAGRAPH || y.relativeFrom === G.LINE);
1098
+ }
1099
+ function W() {
1100
+ const C = t.getFocusDrawings();
1101
+ C.length !== 0 && E(C[0]);
1102
+ }
1103
+ function _(C) {
1104
+ N(C), H(String(C ? G.PARAGRAPH : G.PAGE));
1105
+ }
1106
+ return _n(() => {
1107
+ W();
1108
+ const C = t.focus$.subscribe((P) => {
1109
+ if (P.length === 0) {
1110
+ R(!1);
1102
1111
  return;
1103
1112
  }
1104
- setShowPanel(!0), updateState(drawingParams[0]);
1105
- }), mutationListener = commandService.onCommandExecuted(async (command) => {
1106
- command.id === RichTextEditingMutation.id && updateFocusDrawingState();
1113
+ R(!0), E(P[0]);
1114
+ }), M = e.onCommandExecuted(async (P) => {
1115
+ P.id === J.id && W();
1107
1116
  });
1108
1117
  return () => {
1109
- subscription.unsubscribe(), mutationListener.dispose();
1118
+ C.unsubscribe(), M.dispose();
1110
1119
  };
1111
- }, []), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: showPanel ? "block" : "none" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.title")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.horizontal")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-position.absolutePosition"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1112
- InputNumber,
1113
- {
1114
- min: MIN_OFFSET,
1115
- max: MAX_OFFSET,
1116
- precision: 1,
1117
- disabled,
1118
- value: hPosition.posOffset,
1119
- onChange: /* @__PURE__ */ __name((val) => {
1120
- handlePositionChange("positionH", {
1121
- relativeFrom: hPosition.relativeFrom,
1122
- posOffset: val
1123
- });
1124
- }, "onChange"),
1125
- className: styles.imageCommonPanelInput
1126
- }
1127
- ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-position.toTheRightOf"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1128
- Select,
1129
- {
1130
- value: String(hPosition.relativeFrom),
1131
- disabled,
1132
- options: HORIZONTAL_RELATIVE_FROM,
1133
- onChange: handleHorizontalRelativeFromChange
1134
- }
1135
- )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.vertical")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-position.absolutePosition"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1136
- InputNumber,
1137
- {
1138
- min: MIN_OFFSET,
1139
- max: MAX_OFFSET,
1140
- precision: 1,
1141
- disabled,
1142
- value: vPosition.posOffset,
1143
- onChange: /* @__PURE__ */ __name((val) => {
1144
- handlePositionChange("positionV", {
1145
- relativeFrom: vPosition.relativeFrom,
1146
- posOffset: val
1147
- });
1148
- }, "onChange"),
1149
- className: styles.imageCommonPanelInput
1150
- }
1151
- ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-position.bellow"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1152
- Select,
1153
- {
1154
- disabled,
1155
- value: String(vPosition.relativeFrom),
1156
- options: VERTICAL_RELATIVE_FROM,
1157
- onChange: handleVerticalRelativeFromChange
1158
- }
1159
- )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.options")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow, style: { marginBottom: "50px" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(Checkbox, { disabled, checked: followTextMove, onChange: handleFollowTextMoveCheck }, localeService.t("image-position.moveObjectWithText")))));
1160
- }, "DocDrawingPosition"), MIN_MARGIN = 0, MAX_MARGIN = 100, DocDrawingTextWrap = /* @__PURE__ */ __name((props) => {
1161
- const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), { drawings } = props, drawingParam = drawings[0];
1162
- if (drawingParam == null)
1120
+ }, []), /* @__PURE__ */ l.jsxs("div", { className: V(u.imageCommonPanelGrid, u.imageCommonPanelBorder), style: { display: B ? "block" : "none" }, children: [
1121
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelTitle), children: /* @__PURE__ */ l.jsx("div", { children: n.t("image-position.title") }) }) }),
1122
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSubtitle), children: /* @__PURE__ */ l.jsx("div", { children: n.t("image-position.horizontal") }) }) }),
1123
+ /* @__PURE__ */ l.jsxs("div", { className: u.imageCommonPanelRow, children: [
1124
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: /* @__PURE__ */ l.jsxs("label", { children: [
1125
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: n.t("image-position.absolutePosition") }) }),
1126
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(
1127
+ Be,
1128
+ {
1129
+ min: Un,
1130
+ max: Fn,
1131
+ precision: 1,
1132
+ disabled: w,
1133
+ value: O.posOffset,
1134
+ onChange: (C) => {
1135
+ I("positionH", {
1136
+ relativeFrom: O.relativeFrom,
1137
+ posOffset: C
1138
+ });
1139
+ },
1140
+ className: u.imageCommonPanelInput
1141
+ }
1142
+ ) }) })
1143
+ ] }) }),
1144
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: /* @__PURE__ */ l.jsxs("label", { children: [
1145
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: n.t("image-position.toTheRightOf") }) }),
1146
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(
1147
+ En,
1148
+ {
1149
+ value: String(O.relativeFrom),
1150
+ disabled: w,
1151
+ options: h,
1152
+ onChange: j
1153
+ }
1154
+ ) }) })
1155
+ ] }) })
1156
+ ] }),
1157
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSubtitle), children: /* @__PURE__ */ l.jsx("div", { children: n.t("image-position.vertical") }) }) }),
1158
+ /* @__PURE__ */ l.jsxs("div", { className: u.imageCommonPanelRow, children: [
1159
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: /* @__PURE__ */ l.jsxs("label", { children: [
1160
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: n.t("image-position.absolutePosition") }) }),
1161
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(
1162
+ Be,
1163
+ {
1164
+ min: Un,
1165
+ max: Fn,
1166
+ precision: 1,
1167
+ disabled: w,
1168
+ value: x.posOffset,
1169
+ onChange: (C) => {
1170
+ I("positionV", {
1171
+ relativeFrom: x.relativeFrom,
1172
+ posOffset: C
1173
+ });
1174
+ },
1175
+ className: u.imageCommonPanelInput
1176
+ }
1177
+ ) }) })
1178
+ ] }) }),
1179
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: /* @__PURE__ */ l.jsxs("label", { children: [
1180
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: n.t("image-position.bellow") }) }),
1181
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(
1182
+ En,
1183
+ {
1184
+ disabled: w,
1185
+ value: String(x.relativeFrom),
1186
+ options: v,
1187
+ onChange: H
1188
+ }
1189
+ ) }) })
1190
+ ] }) })
1191
+ ] }),
1192
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSubtitle), children: /* @__PURE__ */ l.jsx("div", { children: n.t("image-position.options") }) }) }),
1193
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, style: { marginBottom: "50px" }, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(vi, { disabled: w, checked: T, onChange: _, children: n.t("image-position.moveObjectWithText") }) }) })
1194
+ ] });
1195
+ }, Ze = 0, Je = 100, rr = (i) => {
1196
+ const e = pe(z), n = pe(dn), t = pe(ve), r = pe(Q), o = pe(Z), { drawings: s } = i, a = s[0];
1197
+ if (a == null)
1163
1198
  return null;
1164
- const { unitId } = drawingParam, documentDataModel = univerInstanceService.getUniverDocInstance(unitId), renderObject = renderManagerService.getRenderById(unitId);
1165
- if ((renderObject == null ? void 0 : renderObject.scene) == null)
1199
+ const { unitId: d } = a, c = o.getUniverDocInstance(d), g = r.getRenderById(d);
1200
+ if ((g == null ? void 0 : g.scene) == null)
1166
1201
  return null;
1167
- const [disableWrapText, setDisableWrapText] = useState(!0), [disableDistTB, setDisableDistTB] = useState(!0), [disableDistLR, setDisableDistLR] = useState(!0), [wrappingStyle, setWrappingStyle] = useState(TextWrappingStyle.INLINE), [wrapText, setWrapText] = useState(""), [distToText, setDistToText] = useState({
1202
+ const [m, p] = ie(!0), [h, v] = ie(!0), [w, S] = ie(!0), [O, D] = ie(me.INLINE), [x, b] = ie(""), [T, N] = ie({
1168
1203
  distT: 0,
1169
1204
  distL: 0,
1170
1205
  distB: 0,
1171
1206
  distR: 0
1172
- }), [showPanel, setShowPanel] = useState(!0);
1173
- function handleWrappingStyleChange(value) {
1174
- setWrappingStyle(value);
1175
- const focusDrawings = drawingManagerService.getFocusDrawings();
1176
- if (focusDrawings.length === 0)
1207
+ }), [B, R] = ie(!0);
1208
+ function I(_) {
1209
+ D(_);
1210
+ const C = t.getFocusDrawings();
1211
+ if (C.length === 0)
1177
1212
  return;
1178
- const { unitId: unitId2, subUnitId } = focusDrawings[0], drawings2 = focusDrawings.map(({ unitId: unitId3, subUnitId: subUnitId2, drawingId }) => ({
1179
- unitId: unitId3,
1180
- subUnitId: subUnitId2,
1181
- drawingId
1213
+ const { unitId: M, subUnitId: P } = C[0], L = C.map(({ unitId: U, subUnitId: y, drawingId: A }) => ({
1214
+ unitId: U,
1215
+ subUnitId: y,
1216
+ drawingId: A
1182
1217
  }));
1183
- commandService.executeCommand(UpdateDocDrawingWrappingStyleCommand.id, {
1184
- unitId: unitId2,
1185
- subUnitId,
1186
- drawings: drawings2,
1187
- wrappingStyle: value
1218
+ e.executeCommand(rt.id, {
1219
+ unitId: M,
1220
+ subUnitId: P,
1221
+ drawings: L,
1222
+ wrappingStyle: _
1188
1223
  });
1189
1224
  }
1190
- __name(handleWrappingStyleChange, "handleWrappingStyleChange");
1191
- function handleWrapTextChange(value) {
1192
- setWrapText(value);
1193
- const focusDrawings = drawingManagerService.getFocusDrawings();
1194
- if (focusDrawings.length === 0)
1225
+ function j(_) {
1226
+ b(_);
1227
+ const C = t.getFocusDrawings();
1228
+ if (C.length === 0)
1195
1229
  return;
1196
- const drawings2 = focusDrawings.map((drawing) => ({
1197
- unitId: drawing.unitId,
1198
- subUnitId: drawing.subUnitId,
1199
- drawingId: drawing.drawingId
1230
+ const M = C.map((P) => ({
1231
+ unitId: P.unitId,
1232
+ subUnitId: P.subUnitId,
1233
+ drawingId: P.drawingId
1200
1234
  }));
1201
- commandService.executeCommand(UpdateDocDrawingWrapTextCommand.id, {
1202
- unitId: focusDrawings[0].unitId,
1203
- subUnitId: focusDrawings[0].unitId,
1204
- drawings: drawings2,
1205
- wrapText: value
1235
+ e.executeCommand(st.id, {
1236
+ unitId: C[0].unitId,
1237
+ subUnitId: C[0].unitId,
1238
+ drawings: M,
1239
+ wrapText: _
1206
1240
  });
1207
1241
  }
1208
- __name(handleWrapTextChange, "handleWrapTextChange");
1209
- function handleDistToTextChange(value, direction) {
1210
- if (value == null)
1242
+ function H(_, C) {
1243
+ if (_ == null)
1211
1244
  return;
1212
- const newDistToText = { ...distToText, [direction]: value };
1213
- setDistToText(newDistToText);
1214
- const focusDrawings = drawingManagerService.getFocusDrawings();
1215
- if (focusDrawings.length === 0)
1245
+ const M = { ...T, [C]: _ };
1246
+ N(M);
1247
+ const P = t.getFocusDrawings();
1248
+ if (P.length === 0)
1216
1249
  return;
1217
- const drawings2 = focusDrawings.map((drawing) => ({
1218
- unitId: drawing.unitId,
1219
- subUnitId: drawing.subUnitId,
1220
- drawingId: drawing.drawingId
1250
+ const L = P.map((U) => ({
1251
+ unitId: U.unitId,
1252
+ subUnitId: U.subUnitId,
1253
+ drawingId: U.drawingId
1221
1254
  }));
1222
- commandService.executeCommand(UpdateDocDrawingDistanceCommand.id, {
1223
- unitId: focusDrawings[0].unitId,
1224
- subUnitId: focusDrawings[0].unitId,
1225
- drawings: drawings2,
1255
+ e.executeCommand(ot.id, {
1256
+ unitId: P[0].unitId,
1257
+ subUnitId: P[0].unitId,
1258
+ drawings: L,
1226
1259
  dist: {
1227
- [direction]: value
1260
+ [C]: _
1228
1261
  }
1229
1262
  });
1230
1263
  }
1231
- __name(handleDistToTextChange, "handleDistToTextChange");
1232
- function updateFocusDrawingState() {
1233
- const focusDrawings = drawingManagerService.getFocusDrawings();
1234
- focusDrawings.length !== 0 && updateState(focusDrawings[0]);
1264
+ function E() {
1265
+ const _ = t.getFocusDrawings();
1266
+ _.length !== 0 && W(_[0]);
1235
1267
  }
1236
- __name(updateFocusDrawingState, "updateFocusDrawingState");
1237
- function updateState(drawingParam2) {
1238
- var _a8, _b;
1239
- const drawing = (_b = (_a8 = documentDataModel == null ? void 0 : documentDataModel.getSnapshot()) == null ? void 0 : _a8.drawings) == null ? void 0 : _b[drawingParam2.drawingId];
1240
- if (drawing == null)
1268
+ function W(_) {
1269
+ var K, se;
1270
+ const C = (se = (K = c == null ? void 0 : c.getSnapshot()) == null ? void 0 : K.drawings) == null ? void 0 : se[_.drawingId];
1271
+ if (C == null)
1241
1272
  return;
1242
1273
  const {
1243
- distT = 0,
1244
- distL = 0,
1245
- distB = 0,
1246
- distR = 0,
1247
- layoutType = PositionedObjectLayoutType.INLINE,
1248
- behindDoc = BooleanNumber.FALSE,
1249
- wrapText: wrapText2 = WrapTextType.BOTH_SIDES
1250
- } = drawing;
1251
- if (setDistToText({
1252
- distT,
1253
- distL,
1254
- distB,
1255
- distR
1256
- }), setWrapText(wrapText2), setDisableWrapText(layoutType !== PositionedObjectLayoutType.WRAP_SQUARE), layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.INLINE ? setDisableDistTB(!0) : setDisableDistTB(!1), layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.INLINE || layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM ? setDisableDistLR(!0) : setDisableDistLR(!1), layoutType === PositionedObjectLayoutType.WRAP_NONE)
1257
- behindDoc === BooleanNumber.TRUE ? setWrappingStyle(TextWrappingStyle.BEHIND_TEXT) : setWrappingStyle(TextWrappingStyle.IN_FRONT_OF_TEXT);
1274
+ distT: M = 0,
1275
+ distL: P = 0,
1276
+ distB: L = 0,
1277
+ distR: U = 0,
1278
+ layoutType: y = k.INLINE,
1279
+ behindDoc: A = re.FALSE,
1280
+ wrapText: $ = Ve.BOTH_SIDES
1281
+ } = C;
1282
+ if (N({
1283
+ distT: M,
1284
+ distL: P,
1285
+ distB: L,
1286
+ distR: U
1287
+ }), b($), p(y !== k.WRAP_SQUARE), y === k.WRAP_NONE || y === k.INLINE ? v(!0) : v(!1), y === k.WRAP_NONE || y === k.INLINE || y === k.WRAP_TOP_AND_BOTTOM ? S(!0) : S(!1), y === k.WRAP_NONE)
1288
+ A === re.TRUE ? D(me.BEHIND_TEXT) : D(me.IN_FRONT_OF_TEXT);
1258
1289
  else
1259
- switch (layoutType) {
1260
- case PositionedObjectLayoutType.INLINE:
1261
- setWrappingStyle(TextWrappingStyle.INLINE);
1290
+ switch (y) {
1291
+ case k.INLINE:
1292
+ D(me.INLINE);
1262
1293
  break;
1263
- case PositionedObjectLayoutType.WRAP_SQUARE:
1264
- setWrappingStyle(TextWrappingStyle.WRAP_SQUARE);
1294
+ case k.WRAP_SQUARE:
1295
+ D(me.WRAP_SQUARE);
1265
1296
  break;
1266
- case PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM:
1267
- setWrappingStyle(TextWrappingStyle.WRAP_TOP_AND_BOTTOM);
1297
+ case k.WRAP_TOP_AND_BOTTOM:
1298
+ D(me.WRAP_TOP_AND_BOTTOM);
1268
1299
  break;
1269
1300
  default:
1270
- throw new Error(`Unsupported layout type: ${layoutType}`);
1301
+ throw new Error(`Unsupported layout type: ${y}`);
1271
1302
  }
1272
1303
  }
1273
- return __name(updateState, "updateState"), useEffect(() => {
1274
- updateFocusDrawingState();
1275
- const subscription = drawingManagerService.focus$.subscribe((drawingParams) => {
1276
- if (drawingParams.length === 0) {
1277
- setShowPanel(!1);
1304
+ return _n(() => {
1305
+ E();
1306
+ const _ = t.focus$.subscribe((M) => {
1307
+ if (M.length === 0) {
1308
+ R(!1);
1278
1309
  return;
1279
1310
  }
1280
- setShowPanel(!0), updateState(drawingParams[0]);
1281
- }), mutationListener = commandService.onCommandExecuted(async (command) => {
1282
- command.id === RichTextEditingMutation.id && updateFocusDrawingState();
1311
+ R(!0), W(M[0]);
1312
+ }), C = e.onCommandExecuted(async (M) => {
1313
+ M.id === J.id && E();
1283
1314
  });
1284
1315
  return () => {
1285
- subscription.unsubscribe(), mutationListener.dispose();
1316
+ _.unsubscribe(), C.dispose();
1286
1317
  };
1287
- }, []), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: showPanel ? "block" : "none" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.title")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.wrappingStyle")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { value: wrappingStyle, onChange: handleWrappingStyleChange, direction: "vertical" }, /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.INLINE }, localeService.t("image-text-wrap.inline")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.WRAP_SQUARE }, localeService.t("image-text-wrap.square")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.WRAP_TOP_AND_BOTTOM }, localeService.t("image-text-wrap.topAndBottom")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.BEHIND_TEXT }, localeService.t("image-text-wrap.behindText")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.IN_FRONT_OF_TEXT }, localeService.t("image-text-wrap.inFrontText"))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.wrapText")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { disabled: disableWrapText, value: wrapText, onChange: handleWrapTextChange, direction: "horizontal" }, /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.BOTH_SIDES }, localeService.t("image-text-wrap.bothSide")), /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.LEFT }, localeService.t("image-text-wrap.leftOnly")), /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.RIGHT }, localeService.t("image-text-wrap.rightOnly"))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.distanceFromText")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.top"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1288
- InputNumber,
1289
- {
1290
- min: MIN_MARGIN,
1291
- max: MAX_MARGIN,
1292
- disabled: disableDistTB,
1293
- precision: 1,
1294
- value: distToText.distT,
1295
- onChange: /* @__PURE__ */ __name((val) => {
1296
- handleDistToTextChange(val, "distT");
1297
- }, "onChange"),
1298
- className: styles.imageCommonPanelInput
1299
- }
1300
- ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.left"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1301
- InputNumber,
1302
- {
1303
- min: MIN_MARGIN,
1304
- max: MAX_MARGIN,
1305
- disabled: disableDistLR,
1306
- precision: 1,
1307
- value: distToText.distL,
1308
- onChange: /* @__PURE__ */ __name((val) => {
1309
- handleDistToTextChange(val, "distL");
1310
- }, "onChange"),
1311
- className: styles.imageCommonPanelInput
1312
- }
1313
- )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.bottom"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1314
- InputNumber,
1315
- {
1316
- min: MIN_MARGIN,
1317
- max: MAX_MARGIN,
1318
- disabled: disableDistTB,
1319
- precision: 1,
1320
- value: distToText.distB,
1321
- onChange: /* @__PURE__ */ __name((val) => {
1322
- handleDistToTextChange(val, "distB");
1323
- }, "onChange"),
1324
- className: styles.imageCommonPanelInput
1325
- }
1326
- ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.right"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1327
- InputNumber,
1328
- {
1329
- min: MIN_MARGIN,
1330
- max: MAX_MARGIN,
1331
- disabled: disableDistLR,
1332
- precision: 1,
1333
- value: distToText.distR,
1334
- onChange: /* @__PURE__ */ __name((val) => {
1335
- handleDistToTextChange(val, "distR");
1336
- }, "onChange"),
1337
- className: styles.imageCommonPanelInput
1338
- }
1339
- )))))));
1340
- }, "DocDrawingTextWrap"), DocDrawingPanel = /* @__PURE__ */ __name(() => {
1341
- const drawingManagerService = useDependency(IDrawingManagerService), focusDrawings = drawingManagerService.getFocusDrawings(), [drawings, setDrawings] = useState(focusDrawings);
1342
- return useEffect(() => {
1343
- const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
1344
- setDrawings(drawings2);
1318
+ }, []), /* @__PURE__ */ l.jsxs("div", { className: V(u.imageCommonPanelGrid, u.imageCommonPanelBorder), style: { display: B ? "block" : "none" }, children: [
1319
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelTitle), children: /* @__PURE__ */ l.jsx("div", { children: n.t("image-text-wrap.title") }) }) }),
1320
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSubtitle), children: /* @__PURE__ */ l.jsx("div", { children: n.t("image-text-wrap.wrappingStyle") }) }) }),
1321
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelRow), children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn), children: /* @__PURE__ */ l.jsxs(jn, { value: O, onChange: I, direction: "vertical", children: [
1322
+ /* @__PURE__ */ l.jsx(xe, { value: me.INLINE, children: n.t("image-text-wrap.inline") }),
1323
+ /* @__PURE__ */ l.jsx(xe, { value: me.WRAP_SQUARE, children: n.t("image-text-wrap.square") }),
1324
+ /* @__PURE__ */ l.jsx(xe, { value: me.WRAP_TOP_AND_BOTTOM, children: n.t("image-text-wrap.topAndBottom") }),
1325
+ /* @__PURE__ */ l.jsx(xe, { value: me.BEHIND_TEXT, children: n.t("image-text-wrap.behindText") }),
1326
+ /* @__PURE__ */ l.jsx(xe, { value: me.IN_FRONT_OF_TEXT, children: n.t("image-text-wrap.inFrontText") })
1327
+ ] }) }) }),
1328
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSubtitle), children: /* @__PURE__ */ l.jsx("div", { children: n.t("image-text-wrap.wrapText") }) }) }),
1329
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelRow), children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn), children: /* @__PURE__ */ l.jsxs(jn, { disabled: m, value: x, onChange: j, direction: "horizontal", children: [
1330
+ /* @__PURE__ */ l.jsx(xe, { value: Ve.BOTH_SIDES, children: n.t("image-text-wrap.bothSide") }),
1331
+ /* @__PURE__ */ l.jsx(xe, { value: Ve.LEFT, children: n.t("image-text-wrap.leftOnly") }),
1332
+ /* @__PURE__ */ l.jsx(xe, { value: Ve.RIGHT, children: n.t("image-text-wrap.rightOnly") })
1333
+ ] }) }) }),
1334
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSubtitle), children: /* @__PURE__ */ l.jsx("div", { children: n.t("image-text-wrap.distanceFromText") }) }) }),
1335
+ /* @__PURE__ */ l.jsxs("div", { className: u.imageCommonPanelRow, children: [
1336
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: /* @__PURE__ */ l.jsxs("label", { children: [
1337
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: n.t("image-text-wrap.top") }) }),
1338
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(
1339
+ Be,
1340
+ {
1341
+ min: Ze,
1342
+ max: Je,
1343
+ disabled: h,
1344
+ precision: 1,
1345
+ value: T.distT,
1346
+ onChange: (_) => {
1347
+ H(_, "distT");
1348
+ },
1349
+ className: u.imageCommonPanelInput
1350
+ }
1351
+ ) }) })
1352
+ ] }) }),
1353
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: /* @__PURE__ */ l.jsxs("label", { children: [
1354
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: n.t("image-text-wrap.left") }) }),
1355
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(
1356
+ Be,
1357
+ {
1358
+ min: Ze,
1359
+ max: Je,
1360
+ disabled: w,
1361
+ precision: 1,
1362
+ value: T.distL,
1363
+ onChange: (_) => {
1364
+ H(_, "distL");
1365
+ },
1366
+ className: u.imageCommonPanelInput
1367
+ }
1368
+ ) }) })
1369
+ ] }) })
1370
+ ] }),
1371
+ /* @__PURE__ */ l.jsxs("div", { className: u.imageCommonPanelRow, children: [
1372
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: /* @__PURE__ */ l.jsxs("label", { children: [
1373
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: n.t("image-text-wrap.bottom") }) }),
1374
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(
1375
+ Be,
1376
+ {
1377
+ min: Ze,
1378
+ max: Je,
1379
+ disabled: h,
1380
+ precision: 1,
1381
+ value: T.distB,
1382
+ onChange: (_) => {
1383
+ H(_, "distB");
1384
+ },
1385
+ className: u.imageCommonPanelInput
1386
+ }
1387
+ ) }) })
1388
+ ] }) }),
1389
+ /* @__PURE__ */ l.jsx("div", { className: V(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: /* @__PURE__ */ l.jsxs("label", { children: [
1390
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: n.t("image-text-wrap.right") }) }),
1391
+ /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelRow, children: /* @__PURE__ */ l.jsx("div", { className: u.imageCommonPanelColumn, children: /* @__PURE__ */ l.jsx(
1392
+ Be,
1393
+ {
1394
+ min: Ze,
1395
+ max: Je,
1396
+ disabled: w,
1397
+ precision: 1,
1398
+ value: T.distR,
1399
+ onChange: (_) => {
1400
+ H(_, "distR");
1401
+ },
1402
+ className: u.imageCommonPanelInput
1403
+ }
1404
+ ) }) })
1405
+ ] }) })
1406
+ ] })
1407
+ ] });
1408
+ }, or = () => {
1409
+ const i = pe(ve), e = i.getFocusDrawings(), [n, t] = ie(e);
1410
+ return _n(() => {
1411
+ const r = i.focus$.subscribe((o) => {
1412
+ t(o);
1345
1413
  });
1346
1414
  return () => {
1347
- focusDispose.unsubscribe();
1415
+ r.unsubscribe();
1348
1416
  };
1349
- }, []), !!(drawings != null && drawings.length) && /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanel }, /* @__PURE__ */ React.createElement(DrawingCommonPanel, { drawings, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }), /* @__PURE__ */ React.createElement(DocDrawingTextWrap, { drawings }), /* @__PURE__ */ React.createElement(DocDrawingPosition, { drawings }));
1350
- }, "DocDrawingPanel"), ImageUploadIcon = "addition-and-subtraction-single", IMAGE_MENU_ID = "doc.menu.image", IMAGE_MENU_UPLOAD_FLOAT_ID = InsertDocImageCommand.id, getDisableWhenSelectionInTableObservable = /* @__PURE__ */ __name((accessor) => {
1351
- const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService);
1352
- return new Observable((subscriber) => {
1353
- const observable = docSelectionManagerService.textSelection$.subscribe(() => {
1354
- var _a8;
1355
- const activeRange = docSelectionManagerService.getActiveTextRange();
1356
- if (activeRange) {
1357
- const { segmentId, startOffset, endOffset } = activeRange, docDataModel = univerInstanceService.getCurrentUniverDocInstance(), tables = (_a8 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a8.tables;
1358
- if (tables && tables.length && tables.some((table) => {
1359
- const { startIndex, endIndex } = table;
1360
- return startOffset >= startIndex && startOffset < endIndex || endOffset >= startIndex && endOffset < endIndex;
1417
+ }, []), !!(n != null && n.length) && /* @__PURE__ */ l.jsxs("div", { className: u.imageCommonPanel, children: [
1418
+ /* @__PURE__ */ l.jsx(zt, { drawings: n, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }),
1419
+ /* @__PURE__ */ l.jsx(rr, { drawings: n }),
1420
+ /* @__PURE__ */ l.jsx(ir, { drawings: n })
1421
+ ] });
1422
+ }, ht = "addition-and-subtraction-single", pt = "doc.menu.image", wt = tt.id, sr = (i) => {
1423
+ const e = i.get(In), n = i.get(Z);
1424
+ return new _i((t) => {
1425
+ const r = e.textSelection$.subscribe(() => {
1426
+ var s;
1427
+ const o = e.getActiveTextRange();
1428
+ if (o) {
1429
+ const { segmentId: a, startOffset: d, endOffset: c } = o, g = n.getCurrentUniverDocInstance(), f = (s = g == null ? void 0 : g.getSelfOrHeaderFooterModel(a).getBody()) == null ? void 0 : s.tables;
1430
+ if (f && f.length && f.some((m) => {
1431
+ const { startIndex: p, endIndex: h } = m;
1432
+ return d >= p && d < h || c >= p && c < h;
1361
1433
  })) {
1362
- subscriber.next(!0);
1434
+ t.next(!0);
1363
1435
  return;
1364
1436
  }
1365
1437
  } else {
1366
- subscriber.next(!0);
1438
+ t.next(!0);
1367
1439
  return;
1368
1440
  }
1369
- subscriber.next(!1);
1441
+ t.next(!1);
1370
1442
  });
1371
- return () => observable.unsubscribe();
1443
+ return () => r.unsubscribe();
1372
1444
  });
1373
- }, "getDisableWhenSelectionInTableObservable");
1374
- function ImageMenuFactory(accessor) {
1445
+ };
1446
+ function ar(i) {
1375
1447
  return {
1376
- id: IMAGE_MENU_ID,
1377
- type: MenuItemType.SUBITEMS,
1378
- icon: ImageUploadIcon,
1448
+ id: pt,
1449
+ type: Vn.SUBITEMS,
1450
+ icon: ht,
1379
1451
  tooltip: "docImage.title",
1380
- disabled$: getDisableWhenSelectionInTableObservable(accessor),
1381
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
1452
+ disabled$: sr(i),
1453
+ hidden$: $n(i, Te.UNIVER_DOC)
1382
1454
  };
1383
1455
  }
1384
- __name(ImageMenuFactory, "ImageMenuFactory");
1385
- function UploadFloatImageMenuFactory(_accessor) {
1456
+ function cr(i) {
1386
1457
  return {
1387
- id: IMAGE_MENU_UPLOAD_FLOAT_ID,
1458
+ id: wt,
1388
1459
  title: "docImage.upload.float",
1389
- type: MenuItemType.BUTTON,
1390
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_DOC)
1460
+ type: Vn.BUTTON,
1461
+ hidden$: $n(i, Te.UNIVER_DOC)
1391
1462
  };
1392
1463
  }
1393
- __name(UploadFloatImageMenuFactory, "UploadFloatImageMenuFactory");
1394
- const menuSchema = {
1395
- [RibbonStartGroup.LAYOUT]: {
1396
- [IMAGE_MENU_ID]: {
1464
+ const dr = {
1465
+ [oi.LAYOUT]: {
1466
+ [pt]: {
1397
1467
  order: 0,
1398
- menuItemFactory: ImageMenuFactory,
1399
- [IMAGE_MENU_UPLOAD_FLOAT_ID]: {
1468
+ menuItemFactory: ar,
1469
+ [wt]: {
1400
1470
  order: 0,
1401
- menuItemFactory: UploadFloatImageMenuFactory
1471
+ menuItemFactory: cr
1402
1472
  }
1403
1473
  }
1404
1474
  }
1405
1475
  };
1406
- function whenDocDrawingFocused(contextService) {
1407
- return contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
1476
+ function Ke(i) {
1477
+ return i.getContextValue(Tt) && i.getContextValue(nn);
1408
1478
  }
1409
- __name(whenDocDrawingFocused, "whenDocDrawingFocused");
1410
- const MoveDrawingDownShortcutItem = {
1411
- id: MoveDocDrawingsCommand.id,
1479
+ const lr = {
1480
+ id: Xe.id,
1412
1481
  description: "shortcut.doc.drawing-move-down",
1413
1482
  group: "4_doc-drawing-view",
1414
- binding: KeyCode.ARROW_DOWN,
1483
+ binding: Fe.ARROW_DOWN,
1415
1484
  priority: 100,
1416
- preconditions: whenDocDrawingFocused,
1485
+ preconditions: Ke,
1417
1486
  staticParameters: {
1418
- direction: Direction.DOWN
1487
+ direction: ue.DOWN
1419
1488
  }
1420
- }, MoveDrawingUpShortcutItem = {
1421
- id: MoveDocDrawingsCommand.id,
1489
+ }, gr = {
1490
+ id: Xe.id,
1422
1491
  description: "shortcut.doc.drawing-move-up",
1423
1492
  group: "4_doc-drawing-view",
1424
- binding: KeyCode.ARROW_UP,
1493
+ binding: Fe.ARROW_UP,
1425
1494
  priority: 100,
1426
- preconditions: whenDocDrawingFocused,
1495
+ preconditions: Ke,
1427
1496
  staticParameters: {
1428
- direction: Direction.UP
1497
+ direction: ue.UP
1429
1498
  }
1430
- }, MoveDrawingLeftShortcutItem = {
1431
- id: MoveDocDrawingsCommand.id,
1499
+ }, mr = {
1500
+ id: Xe.id,
1432
1501
  description: "shortcut.doc.drawing-move-left",
1433
1502
  group: "4_doc-drawing-view",
1434
- binding: KeyCode.ARROW_LEFT,
1503
+ binding: Fe.ARROW_LEFT,
1435
1504
  priority: 100,
1436
- preconditions: whenDocDrawingFocused,
1505
+ preconditions: Ke,
1437
1506
  staticParameters: {
1438
- direction: Direction.LEFT
1507
+ direction: ue.LEFT
1439
1508
  }
1440
- }, MoveDrawingRightShortcutItem = {
1441
- id: MoveDocDrawingsCommand.id,
1509
+ }, ur = {
1510
+ id: Xe.id,
1442
1511
  description: "shortcut.doc.drawing-move-right",
1443
1512
  group: "4_doc-drawing-view",
1444
- binding: KeyCode.ARROW_RIGHT,
1513
+ binding: Fe.ARROW_RIGHT,
1445
1514
  priority: 100,
1446
- preconditions: whenDocDrawingFocused,
1515
+ preconditions: Ke,
1447
1516
  staticParameters: {
1448
- direction: Direction.RIGHT
1517
+ direction: ue.RIGHT
1449
1518
  }
1450
- }, DeleteDrawingsShortcutItem = {
1451
- id: DeleteDocDrawingsCommand.id,
1519
+ }, fr = {
1520
+ id: Zn.id,
1452
1521
  description: "shortcut.doc.drawing-delete",
1453
1522
  group: "4_doc-drawing-view",
1454
1523
  // when focusing on any other input tag do not trigger this shortcut
1455
- preconditions: whenDocDrawingFocused,
1456
- binding: KeyCode.DELETE,
1457
- mac: KeyCode.BACKSPACE
1524
+ preconditions: Ke,
1525
+ binding: Fe.DELETE,
1526
+ mac: Fe.BACKSPACE
1458
1527
  };
1459
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1460
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1461
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1462
- return kind && result && __defProp$5(target, key, result), result;
1463
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a2;
1464
- let DocDrawingUIController = (_a2 = class extends Disposable {
1465
- constructor(_componentManager, _menuManagerService, _commandService, _shortcutService) {
1466
- super(), this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
1528
+ var hr = Object.defineProperty, pr = Object.getOwnPropertyDescriptor, wr = (i, e, n, t) => {
1529
+ for (var r = t > 1 ? void 0 : t ? pr(e, n) : e, o = i.length - 1, s; o >= 0; o--)
1530
+ (s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
1531
+ return t && r && hr(e, n, r), r;
1532
+ }, Qe = (i, e) => (n, t) => e(n, t, i);
1533
+ let rn = class extends qe {
1534
+ constructor(i, e, n, t) {
1535
+ super(), this._componentManager = i, this._menuManagerService = e, this._commandService = n, this._shortcutService = t, this._init();
1467
1536
  }
1468
1537
  _initCustomComponents() {
1469
- const componentManager = this._componentManager;
1470
- this.disposeWithMe(componentManager.register(ImageUploadIcon, AddImageSingle)), this.disposeWithMe(componentManager.register(COMPONENT_DOC_DRAWING_PANEL, DocDrawingPanel));
1538
+ const i = this._componentManager;
1539
+ this.disposeWithMe(i.register(ht, Yn)), this.disposeWithMe(i.register(dt, or));
1471
1540
  }
1472
1541
  _initMenus() {
1473
- this._menuManagerService.mergeMenu(menuSchema);
1542
+ this._menuManagerService.mergeMenu(dr);
1474
1543
  }
1475
1544
  _initCommands() {
1476
1545
  [
1477
- InsertDocImageCommand,
1478
- InsertDocDrawingCommand,
1479
- UpdateDocDrawingWrappingStyleCommand,
1480
- UpdateDocDrawingDistanceCommand,
1481
- UpdateDocDrawingWrapTextCommand,
1482
- UpdateDrawingDocTransformCommand,
1483
- IMoveInlineDrawingCommand,
1484
- ITransformNonInlineDrawingCommand,
1485
- RemoveDocDrawingCommand,
1486
- SidebarDocDrawingOperation,
1487
- ClearDocDrawingTransformerOperation,
1488
- EditDocDrawingOperation,
1489
- GroupDocDrawingCommand,
1490
- UngroupDocDrawingCommand,
1491
- MoveDocDrawingsCommand,
1492
- DeleteDocDrawingsCommand,
1493
- SetDocDrawingArrangeCommand
1494
- ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1546
+ tt,
1547
+ Qn,
1548
+ rt,
1549
+ ot,
1550
+ st,
1551
+ ze,
1552
+ at,
1553
+ ct,
1554
+ Sn,
1555
+ lt,
1556
+ ji,
1557
+ gt,
1558
+ Jn,
1559
+ nt,
1560
+ Xe,
1561
+ Zn,
1562
+ et
1563
+ ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
1495
1564
  }
1496
1565
  _initShortcuts() {
1497
1566
  [
1498
1567
  // sheet drawing shortcuts
1499
- MoveDrawingDownShortcutItem,
1500
- MoveDrawingUpShortcutItem,
1501
- MoveDrawingLeftShortcutItem,
1502
- MoveDrawingRightShortcutItem,
1503
- DeleteDrawingsShortcutItem
1504
- ].forEach((item) => {
1505
- this.disposeWithMe(this._shortcutService.registerShortcut(item));
1568
+ lr,
1569
+ gr,
1570
+ mr,
1571
+ ur,
1572
+ fr
1573
+ ].forEach((i) => {
1574
+ this.disposeWithMe(this._shortcutService.registerShortcut(i));
1506
1575
  });
1507
1576
  }
1508
1577
  _init() {
1509
1578
  this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
1510
1579
  }
1511
- }, __name(_a2, "DocDrawingUIController"), _a2);
1512
- DocDrawingUIController = __decorateClass$5([
1513
- __decorateParam$5(0, Inject(ComponentManager)),
1514
- __decorateParam$5(1, IMenuManagerService),
1515
- __decorateParam$5(2, ICommandService),
1516
- __decorateParam$5(3, IShortcutService)
1517
- ], DocDrawingUIController);
1518
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1519
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1520
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1521
- return kind && result && __defProp$4(target, key, result), result;
1522
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
1523
- function getAddOrRemoveDrawings(actions) {
1524
- var _a8, _b, _c, _d;
1525
- if (JSONX.isNoop(actions) || !Array.isArray(actions))
1580
+ };
1581
+ rn = wr([
1582
+ Qe(0, we(si)),
1583
+ Qe(1, ai),
1584
+ Qe(2, z),
1585
+ Qe(3, ci)
1586
+ ], rn);
1587
+ var vr = Object.defineProperty, Ir = Object.getOwnPropertyDescriptor, _r = (i, e, n, t) => {
1588
+ for (var r = t > 1 ? void 0 : t ? Ir(e, n) : e, o = i.length - 1, s; o >= 0; o--)
1589
+ (s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
1590
+ return t && r && vr(e, n, r), r;
1591
+ }, We = (i, e) => (n, t) => e(n, t, i);
1592
+ function Sr(i) {
1593
+ var t, r, o, s;
1594
+ if (q.isNoop(i) || !Array.isArray(i))
1526
1595
  return null;
1527
- const drawingsOp = actions.find((action) => Array.isArray(action) && (action == null ? void 0 : action[0]) === "drawings");
1528
- if (drawingsOp == null || !Array.isArray(drawingsOp) || drawingsOp.length < 3 || typeof drawingsOp[1] == "string" && typeof drawingsOp[2] != "object" || Array.isArray(drawingsOp[1]) && typeof drawingsOp[1][1] != "object")
1596
+ const e = i.find((a) => Array.isArray(a) && (a == null ? void 0 : a[0]) === "drawings");
1597
+ if (e == null || !Array.isArray(e) || e.length < 3 || typeof e[1] == "string" && typeof e[2] != "object" || Array.isArray(e[1]) && typeof e[1][1] != "object")
1529
1598
  return null;
1530
- const drawings = [];
1531
- if (Array.isArray(drawingsOp == null ? void 0 : drawingsOp[1]))
1532
- for (const op of drawingsOp)
1533
- Array.isArray(op) && drawings.push({
1534
- type: (_a8 = op == null ? void 0 : op[1]) != null && _a8.i ? "add" : "remove",
1535
- drawingId: op == null ? void 0 : op[0],
1536
- drawing: (_b = op == null ? void 0 : op[1]) == null ? void 0 : _b.i
1599
+ const n = [];
1600
+ if (Array.isArray(e == null ? void 0 : e[1]))
1601
+ for (const a of e)
1602
+ Array.isArray(a) && n.push({
1603
+ type: (t = a == null ? void 0 : a[1]) != null && t.i ? "add" : "remove",
1604
+ drawingId: a == null ? void 0 : a[0],
1605
+ drawing: (r = a == null ? void 0 : a[1]) == null ? void 0 : r.i
1537
1606
  });
1538
1607
  else
1539
- drawings.push({
1540
- type: (_c = drawingsOp[2]) != null && _c.i ? "add" : "remove",
1541
- drawingId: drawingsOp[1],
1542
- drawing: (_d = drawingsOp[2]) == null ? void 0 : _d.i
1608
+ n.push({
1609
+ type: (o = e[2]) != null && o.i ? "add" : "remove",
1610
+ drawingId: e[1],
1611
+ drawing: (s = e[2]) == null ? void 0 : s.i
1543
1612
  });
1544
- return drawings;
1613
+ return n;
1545
1614
  }
1546
- __name(getAddOrRemoveDrawings, "getAddOrRemoveDrawings");
1547
- function getReOrderedDrawings(actions) {
1548
- if (!Array.isArray(actions) || actions.length < 3 || actions[0] !== "drawingsOrder")
1615
+ function Cr(i) {
1616
+ if (!Array.isArray(i) || i.length < 3 || i[0] !== "drawingsOrder")
1549
1617
  return [];
1550
- const drawingIndexes = [];
1551
- for (let i = 1; i < actions.length; i++) {
1552
- const action = actions[i];
1553
- if (Array.isArray(action) && typeof action[0] == "number" && typeof action[1] == "object")
1554
- drawingIndexes.push(action[0]);
1618
+ const e = [];
1619
+ for (let n = 1; n < i.length; n++) {
1620
+ const t = i[n];
1621
+ if (Array.isArray(t) && typeof t[0] == "number" && typeof t[1] == "object")
1622
+ e.push(t[0]);
1555
1623
  else {
1556
- drawingIndexes.length = 0;
1624
+ e.length = 0;
1557
1625
  break;
1558
1626
  }
1559
1627
  }
1560
- return drawingIndexes;
1628
+ return e;
1561
1629
  }
1562
- __name(getReOrderedDrawings, "getReOrderedDrawings");
1563
- var _a3;
1564
- let DocDrawingAddRemoveController = (_a3 = class extends Disposable {
1565
- constructor(_univerInstanceService, _commandService, _drawingManagerService, _docDrawingService, _renderManagerService) {
1566
- super(), this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._docDrawingService = _docDrawingService, this._renderManagerService = _renderManagerService, this._initialize();
1630
+ let on = class extends qe {
1631
+ constructor(i, e, n, t, r) {
1632
+ super(), this._univerInstanceService = i, this._commandService = e, this._drawingManagerService = n, this._docDrawingService = t, this._renderManagerService = r, this._initialize();
1567
1633
  }
1568
1634
  _initialize() {
1569
1635
  this._commandExecutedListener();
1570
1636
  }
1571
1637
  _commandExecutedListener() {
1572
1638
  this.disposeWithMe(
1573
- this._commandService.beforeCommandExecuted((command) => {
1574
- if (command.id !== RichTextEditingMutation.id)
1639
+ this._commandService.beforeCommandExecuted((i) => {
1640
+ if (i.id !== J.id)
1575
1641
  return;
1576
- const params = command.params, { unitId, actions } = params, addOrRemoveDrawings = getAddOrRemoveDrawings(actions);
1577
- if (addOrRemoveDrawings != null)
1578
- for (const { type, drawingId, drawing } of addOrRemoveDrawings)
1579
- type === "add" ? this._addDrawings(unitId, [drawing]) : this._removeDrawings(unitId, [drawingId]);
1642
+ const e = i.params, { unitId: n, actions: t } = e, r = Sr(t);
1643
+ if (r != null)
1644
+ for (const { type: o, drawingId: s, drawing: a } of r)
1645
+ o === "add" ? this._addDrawings(n, [a]) : this._removeDrawings(n, [s]);
1580
1646
  })
1581
1647
  ), this.disposeWithMe(
1582
- this._commandService.onCommandExecuted((command) => {
1583
- if (command.id !== RichTextEditingMutation.id)
1648
+ this._commandService.onCommandExecuted((i) => {
1649
+ if (i.id !== J.id)
1584
1650
  return;
1585
- const params = command.params, { unitId, actions } = params;
1586
- getReOrderedDrawings(actions).length > 0 && this._updateDrawingsOrder(unitId);
1651
+ const e = i.params, { unitId: n, actions: t } = e;
1652
+ Cr(t).length > 0 && this._updateDrawingsOrder(n);
1587
1653
  })
1588
1654
  ), this.disposeWithMe(
1589
- this._commandService.onCommandExecuted((command) => {
1590
- var _a8;
1591
- if (command.id !== UndoCommand.id && command.id !== RedoCommand.id)
1655
+ this._commandService.onCommandExecuted((i) => {
1656
+ var s;
1657
+ if (i.id !== yt.id && i.id !== bt.id)
1592
1658
  return;
1593
- const unitId = (_a8 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a8.getUnitId(), focusedDrawings = this._drawingManagerService.getFocusDrawings();
1594
- if (unitId == null || focusedDrawings.length === 0)
1659
+ const e = (s = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : s.getUnitId(), n = this._drawingManagerService.getFocusDrawings();
1660
+ if (e == null || n.length === 0)
1595
1661
  return;
1596
- const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1597
- if (scene == null)
1662
+ const t = this._renderManagerService.getRenderById(e), r = t == null ? void 0 : t.scene;
1663
+ if (r == null)
1598
1664
  return !1;
1599
- scene.getTransformerByCreate().refreshControls();
1665
+ r.getTransformerByCreate().refreshControls();
1600
1666
  })
1601
1667
  );
1602
1668
  }
1603
- _addDrawings(unitId, drawings) {
1604
- const drawingManagerService = this._drawingManagerService, docDrawingService = this._docDrawingService, jsonOp = this._docDrawingService.getBatchAddOp(drawings), { subUnitId, redo: op, objects } = jsonOp;
1605
- drawingManagerService.applyJson1(unitId, subUnitId, op), docDrawingService.applyJson1(unitId, subUnitId, op), drawingManagerService.addNotification(objects), docDrawingService.addNotification(objects);
1606
- }
1607
- _removeDrawings(unitId, drawingIds) {
1608
- const drawingManagerService = this._drawingManagerService, docDrawingService = this._docDrawingService, jsonOp = this._docDrawingService.getBatchRemoveOp(drawingIds.map((drawingId) => ({
1609
- unitId,
1610
- subUnitId: unitId,
1611
- drawingId
1612
- }))), { subUnitId, redo: op, objects } = jsonOp;
1613
- drawingManagerService.applyJson1(unitId, subUnitId, op), docDrawingService.applyJson1(unitId, subUnitId, op), drawingManagerService.removeNotification(objects), docDrawingService.removeNotification(objects);
1614
- }
1615
- _updateDrawingsOrder(unitId) {
1616
- const documentDataModel = this._univerInstanceService.getUniverDocInstance(unitId);
1617
- if (documentDataModel == null)
1669
+ _addDrawings(i, e) {
1670
+ const n = this._drawingManagerService, t = this._docDrawingService, r = this._docDrawingService.getBatchAddOp(e), { subUnitId: o, redo: s, objects: a } = r;
1671
+ n.applyJson1(i, o, s), t.applyJson1(i, o, s), n.addNotification(a), t.addNotification(a);
1672
+ }
1673
+ _removeDrawings(i, e) {
1674
+ const n = this._drawingManagerService, t = this._docDrawingService, r = this._docDrawingService.getBatchRemoveOp(e.map((d) => ({
1675
+ unitId: i,
1676
+ subUnitId: i,
1677
+ drawingId: d
1678
+ }))), { subUnitId: o, redo: s, objects: a } = r;
1679
+ n.applyJson1(i, o, s), t.applyJson1(i, o, s), n.removeNotification(a), t.removeNotification(a);
1680
+ }
1681
+ _updateDrawingsOrder(i) {
1682
+ const e = this._univerInstanceService.getUniverDocInstance(i);
1683
+ if (e == null)
1618
1684
  return;
1619
- const drawingsOrder = documentDataModel.getSnapshot().drawingsOrder;
1620
- if (drawingsOrder == null)
1685
+ const n = e.getSnapshot().drawingsOrder;
1686
+ if (n == null)
1621
1687
  return;
1622
- const drawingManagerService = this._drawingManagerService, docDrawingService = this._docDrawingService;
1623
- drawingManagerService.setDrawingOrder(unitId, unitId, drawingsOrder), docDrawingService.setDrawingOrder(unitId, unitId, drawingsOrder);
1624
- const objects = {
1625
- unitId,
1626
- subUnitId: unitId,
1627
- drawingIds: drawingsOrder
1688
+ const t = this._drawingManagerService, r = this._docDrawingService;
1689
+ t.setDrawingOrder(i, i, n), r.setDrawingOrder(i, i, n);
1690
+ const o = {
1691
+ unitId: i,
1692
+ subUnitId: i,
1693
+ drawingIds: n
1628
1694
  };
1629
- drawingManagerService.orderNotification(objects), docDrawingService.orderNotification(objects);
1630
- }
1631
- }, __name(_a3, "DocDrawingAddRemoveController"), _a3);
1632
- DocDrawingAddRemoveController = __decorateClass$4([
1633
- __decorateParam$4(0, IUniverInstanceService),
1634
- __decorateParam$4(1, ICommandService),
1635
- __decorateParam$4(2, IDrawingManagerService),
1636
- __decorateParam$4(3, IDocDrawingService),
1637
- __decorateParam$4(4, IRenderManagerService)
1638
- ], DocDrawingAddRemoveController);
1639
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1640
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1641
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1642
- return kind && result && __defProp$3(target, key, result), result;
1643
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
1644
- const INLINE_DRAWING_ANCHOR_KEY_PREFIX = "__InlineDrawingAnchor__";
1645
- function isInTableCell(nodePosition) {
1646
- const { path } = nodePosition;
1647
- return path.some((p) => p === "cells");
1695
+ t.orderNotification(o), r.orderNotification(o);
1696
+ }
1697
+ };
1698
+ on = _r([
1699
+ We(0, Z),
1700
+ We(1, z),
1701
+ We(2, ve),
1702
+ We(3, je),
1703
+ We(4, Q)
1704
+ ], on);
1705
+ var Dr = Object.defineProperty, Or = Object.getOwnPropertyDescriptor, xr = (i, e, n, t) => {
1706
+ for (var r = t > 1 ? void 0 : t ? Or(e, n) : e, o = i.length - 1, s; o >= 0; o--)
1707
+ (s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
1708
+ return t && r && Dr(e, n, r), r;
1709
+ }, en = (i, e) => (n, t) => e(n, t, i);
1710
+ const Pr = "__InlineDrawingAnchor__";
1711
+ function kn(i) {
1712
+ const { path: e } = i;
1713
+ return e.some((n) => n === "cells");
1648
1714
  }
1649
- __name(isInTableCell, "isInTableCell");
1650
- var _a4;
1651
- let DocDrawingTransformerController = (_a4 = class extends Disposable {
1652
- constructor(_commandService, _univerInstanceService, _drawingManagerService, _renderManagerService) {
1715
+ let sn = class extends qe {
1716
+ constructor(e, n, t, r) {
1653
1717
  super();
1654
- __publicField(this, "_liquid", new Liquid());
1655
- __publicField(this, "_listenerOnImageMap", /* @__PURE__ */ new Set());
1718
+ Se(this, "_liquid", new Gn());
1719
+ Se(this, "_listenerOnImageMap", /* @__PURE__ */ new Set());
1656
1720
  // Use to cache the drawings is under transforming or scaling.
1657
- __publicField(this, "_transformerCache", /* @__PURE__ */ new Map());
1658
- __publicField(this, "_anchorShape");
1659
- this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._init();
1721
+ Se(this, "_transformerCache", /* @__PURE__ */ new Map());
1722
+ Se(this, "_anchorShape");
1723
+ this._commandService = e, this._univerInstanceService = n, this._drawingManagerService = t, this._renderManagerService = r, this._init();
1660
1724
  }
1661
1725
  _init() {
1662
1726
  this._listenDrawingFocus();
1663
1727
  }
1664
1728
  _listenDrawingFocus() {
1665
1729
  this.disposeWithMe(
1666
- this._drawingManagerService.add$.subscribe((drawingParams) => {
1667
- if (drawingParams.length !== 0)
1668
- for (const drawingParam of drawingParams) {
1669
- const { unitId } = drawingParam;
1670
- this._listenerOnImageMap.has(unitId) || (this._listenTransformerChange(unitId), this._listenerOnImageMap.add(unitId));
1730
+ this._drawingManagerService.add$.subscribe((e) => {
1731
+ if (e.length !== 0)
1732
+ for (const n of e) {
1733
+ const { unitId: t } = n;
1734
+ this._listenerOnImageMap.has(t) || (this._listenTransformerChange(t), this._listenerOnImageMap.add(t));
1671
1735
  }
1672
1736
  })
1673
1737
  );
1674
1738
  }
1675
1739
  // Only handle one drawing transformer change.
1676
1740
  // eslint-disable-next-line max-lines-per-function
1677
- _listenTransformerChange(unitId) {
1678
- var _a8;
1679
- const transformer = (_a8 = this._getSceneAndTransformerByDrawingSearch(unitId)) == null ? void 0 : _a8.transformer;
1680
- if (transformer == null)
1741
+ _listenTransformerChange(e) {
1742
+ var r;
1743
+ const n = (r = this._getSceneAndTransformerByDrawingSearch(e)) == null ? void 0 : r.transformer;
1744
+ if (n == null)
1681
1745
  return;
1682
1746
  this.disposeWithMe(
1683
- toDisposable(
1684
- transformer.changeStart$.subscribe((state) => {
1685
- var _a9;
1747
+ Ee(
1748
+ n.changeStart$.subscribe((o) => {
1749
+ var a;
1686
1750
  this._transformerCache.clear();
1687
- const { objects } = state;
1688
- for (const object of objects.values()) {
1689
- const { oKey, width, height, left, top, angle } = object, drawing = this._drawingManagerService.getDrawingOKey(oKey);
1690
- if (drawing == null)
1751
+ const { objects: s } = o;
1752
+ for (const d of s.values()) {
1753
+ const { oKey: c, width: g, height: f, left: m, top: p, angle: h } = d, v = this._drawingManagerService.getDrawingOKey(c);
1754
+ if (v == null)
1691
1755
  continue;
1692
- const documentDataModel = this._univerInstanceService.getUniverDocInstance(drawing.unitId), drawingData = (_a9 = documentDataModel == null ? void 0 : documentDataModel.getSnapshot().drawings) == null ? void 0 : _a9[drawing.drawingId];
1693
- (drawingData == null ? void 0 : drawingData.layoutType) === PositionedObjectLayoutType.INLINE && object.setOpacity(0.2), drawingData != null && this._transformerCache.set(drawing.drawingId, {
1694
- drawing: drawingData,
1695
- top,
1696
- left,
1697
- width,
1698
- height,
1699
- angle
1756
+ const w = this._univerInstanceService.getUniverDocInstance(v.unitId), S = (a = w == null ? void 0 : w.getSnapshot().drawings) == null ? void 0 : a[v.drawingId];
1757
+ (S == null ? void 0 : S.layoutType) === k.INLINE && d.setOpacity(0.2), S != null && this._transformerCache.set(v.drawingId, {
1758
+ drawing: S,
1759
+ top: p,
1760
+ left: m,
1761
+ width: g,
1762
+ height: f,
1763
+ angle: h
1700
1764
  });
1701
1765
  }
1702
1766
  })
1703
1767
  )
1704
1768
  );
1705
- const throttleMultipleDrawingUpdate = throttle(this._updateMultipleDrawingDocTransform.bind(this), 50);
1706
- throttle(this._nonInlineDrawingTransform.bind(this), 50), this.disposeWithMe(
1707
- toDisposable(
1708
- transformer.changing$.subscribe((state) => {
1709
- const { objects, offsetX, offsetY } = state;
1710
- if (objects.size > 1)
1711
- throttleMultipleDrawingUpdate(objects);
1712
- else if (objects.size === 1) {
1713
- const drawingCache = this._transformerCache.values().next().value, object = objects.values().next().value, { width, height, top, left, angle } = object;
1714
- if (drawingCache && width === drawingCache.width && height === drawingCache.height && top === drawingCache.top && left === drawingCache.left && angle === drawingCache.angle)
1769
+ const t = On(this._updateMultipleDrawingDocTransform.bind(this), 50);
1770
+ On(this._nonInlineDrawingTransform.bind(this), 50), this.disposeWithMe(
1771
+ Ee(
1772
+ n.changing$.subscribe((o) => {
1773
+ const { objects: s, offsetX: a, offsetY: d } = o;
1774
+ if (s.size > 1)
1775
+ t(s);
1776
+ else if (s.size === 1) {
1777
+ const c = this._transformerCache.values().next().value, g = s.values().next().value, { width: f, height: m, top: p, left: h, angle: v } = g;
1778
+ if (c && f === c.width && m === c.height && p === c.top && h === c.left && v === c.angle)
1715
1779
  return;
1716
- drawingCache && (drawingCache.drawing.layoutType, PositionedObjectLayoutType.INLINE), drawingCache && drawingCache.drawing.layoutType === PositionedObjectLayoutType.INLINE && offsetX != null && offsetY != null && this._updateInlineDrawingAnchor(drawingCache.drawing, offsetX, offsetY);
1780
+ c && (c.drawing.layoutType, k.INLINE), c && c.drawing.layoutType === k.INLINE && a != null && d != null && this._updateInlineDrawingAnchor(c.drawing, a, d);
1717
1781
  }
1718
1782
  })
1719
1783
  )
1720
1784
  ), this.disposeWithMe(
1721
- toDisposable(
1785
+ Ee(
1722
1786
  // eslint-disable-next-line complexity
1723
- transformer.changeEnd$.subscribe((state) => {
1724
- const { objects, offsetX, offsetY } = state;
1725
- for (const object of objects.values()) {
1726
- const drawing = this._drawingManagerService.getDrawingOKey(object.oKey);
1727
- if (drawing == null)
1787
+ n.changeEnd$.subscribe((o) => {
1788
+ const { objects: s, offsetX: a, offsetY: d } = o;
1789
+ for (const c of s.values()) {
1790
+ const g = this._drawingManagerService.getDrawingOKey(c.oKey);
1791
+ if (g == null)
1728
1792
  continue;
1729
- const drawingCache = this._transformerCache.get(drawing == null ? void 0 : drawing.drawingId);
1730
- (drawingCache == null ? void 0 : drawingCache.drawing.layoutType) === PositionedObjectLayoutType.INLINE && object.setOpacity(1);
1793
+ const f = this._transformerCache.get(g == null ? void 0 : g.drawingId);
1794
+ (f == null ? void 0 : f.drawing.layoutType) === k.INLINE && c.setOpacity(1);
1731
1795
  }
1732
- if (this._anchorShape && this._anchorShape.hide(), objects.size > 1)
1733
- this._updateMultipleDrawingDocTransform(objects);
1734
- else if (objects.size === 1) {
1735
- const drawingCache = this._transformerCache.values().next().value, object = objects.values().next().value, { width, height, top, left, angle } = object;
1736
- if (drawingCache && width === drawingCache.width && height === drawingCache.height && top === drawingCache.top && left === drawingCache.left && angle === drawingCache.angle)
1796
+ if (this._anchorShape && this._anchorShape.hide(), s.size > 1)
1797
+ this._updateMultipleDrawingDocTransform(s);
1798
+ else if (s.size === 1) {
1799
+ const c = this._transformerCache.values().next().value, g = s.values().next().value, { width: f, height: m, top: p, left: h, angle: v } = g;
1800
+ if (c && f === c.width && m === c.height && p === c.top && h === c.left && v === c.angle)
1737
1801
  return;
1738
- drawingCache && drawingCache.drawing.layoutType === PositionedObjectLayoutType.INLINE ? width !== drawingCache.width || height !== drawingCache.height || angle !== drawingCache.angle ? this._updateDrawingSize(drawingCache, object) : offsetX != null && offsetY != null && this._moveInlineDrawing(drawingCache.drawing, offsetX, offsetY) : drawingCache && this._nonInlineDrawingTransform(drawingCache.drawing, object);
1802
+ c && c.drawing.layoutType === k.INLINE ? f !== c.width || m !== c.height || v !== c.angle ? this._updateDrawingSize(c, g) : a != null && d != null && this._moveInlineDrawing(c.drawing, a, d) : c && this._nonInlineDrawingTransform(c.drawing, g);
1739
1803
  }
1740
1804
  this._transformerCache.clear();
1741
1805
  })
@@ -1743,177 +1807,177 @@ let DocDrawingTransformerController = (_a4 = class extends Disposable {
1743
1807
  );
1744
1808
  }
1745
1809
  // eslint-disable-next-line max-lines-per-function
1746
- _updateMultipleDrawingDocTransform(objects) {
1747
- if (objects.size < 1)
1810
+ _updateMultipleDrawingDocTransform(e) {
1811
+ if (e.size < 1)
1748
1812
  return;
1749
- const drawings = [];
1750
- let unitId, subUnitId;
1751
- for (const object of objects.values()) {
1752
- const { oKey, left, top, angle } = object;
1753
- let { width, height } = object;
1754
- const drawing = this._drawingManagerService.getDrawingOKey(oKey);
1755
- if (drawing == null)
1813
+ const n = [];
1814
+ let t, r;
1815
+ for (const o of e.values()) {
1816
+ const { oKey: s, left: a, top: d, angle: c } = o;
1817
+ let { width: g, height: f } = o;
1818
+ const m = this._drawingManagerService.getDrawingOKey(s);
1819
+ if (m == null)
1756
1820
  continue;
1757
- unitId == null && (unitId = drawing.unitId), subUnitId == null && (subUnitId = drawing.subUnitId);
1758
- const drawingCache = this._transformerCache.get(drawing.drawingId);
1759
- if (drawingCache == null)
1821
+ t == null && (t = m.unitId), r == null && (r = m.subUnitId);
1822
+ const p = this._transformerCache.get(m.drawingId);
1823
+ if (p == null)
1760
1824
  continue;
1761
- const { drawing: drawingData, top: oldTop, left: oldLeft, width: oldWidth, height: oldHeight, angle: oldAngle } = drawingCache, { width: maxWidth, height: maxHeight } = this._getPageContentSize(drawingData);
1762
- if (width = Math.min(width, maxWidth), height = Math.min(height, maxHeight), (oldWidth !== width || oldHeight !== height) && drawings.push({
1763
- drawingId: drawing.drawingId,
1825
+ const { drawing: h, top: v, left: w, width: S, height: O, angle: D } = p, { width: x, height: b } = this._getPageContentSize(h);
1826
+ if (g = Math.min(g, x), f = Math.min(f, b), (S !== g || O !== f) && n.push({
1827
+ drawingId: m.drawingId,
1764
1828
  key: "size",
1765
1829
  value: {
1766
- width,
1767
- height
1830
+ width: g,
1831
+ height: f
1768
1832
  }
1769
- }), oldAngle !== angle && drawings.push({
1770
- drawingId: drawing.drawingId,
1833
+ }), D !== c && n.push({
1834
+ drawingId: m.drawingId,
1771
1835
  key: "angle",
1772
- value: angle
1773
- }), oldTop !== top || oldLeft !== left) {
1774
- const verticalDelta = top - oldTop, horizontalDelta = left - oldLeft;
1775
- verticalDelta !== 0 && drawings.push({
1776
- drawingId: drawing.drawingId,
1836
+ value: c
1837
+ }), v !== d || w !== a) {
1838
+ const T = d - v, N = a - w;
1839
+ T !== 0 && n.push({
1840
+ drawingId: m.drawingId,
1777
1841
  key: "positionV",
1778
1842
  value: {
1779
- relativeFrom: drawingData.docTransform.positionV.relativeFrom,
1780
- posOffset: drawingData.docTransform.positionV.posOffset + verticalDelta
1843
+ relativeFrom: h.docTransform.positionV.relativeFrom,
1844
+ posOffset: h.docTransform.positionV.posOffset + T
1781
1845
  }
1782
- }), horizontalDelta !== 0 && drawings.push({
1783
- drawingId: drawing.drawingId,
1846
+ }), N !== 0 && n.push({
1847
+ drawingId: m.drawingId,
1784
1848
  key: "positionH",
1785
1849
  value: {
1786
- relativeFrom: drawingData.docTransform.positionH.relativeFrom,
1787
- posOffset: drawingData.docTransform.positionH.posOffset + horizontalDelta
1850
+ relativeFrom: h.docTransform.positionH.relativeFrom,
1851
+ posOffset: h.docTransform.positionH.posOffset + N
1788
1852
  }
1789
1853
  });
1790
1854
  }
1791
1855
  }
1792
- drawings.length > 0 && unitId && subUnitId && this._commandService.executeCommand(UpdateDrawingDocTransformCommand.id, {
1793
- unitId,
1794
- subUnitId,
1795
- drawings
1856
+ n.length > 0 && t && r && this._commandService.executeCommand(ze.id, {
1857
+ unitId: t,
1858
+ subUnitId: r,
1859
+ drawings: n
1796
1860
  });
1797
1861
  }
1798
1862
  // TODO: @JOCS, Use to draw and update the drawing anchor.
1799
- _updateDrawingAnchor(objects) {
1863
+ _updateDrawingAnchor(e) {
1800
1864
  if (this._transformerCache.size !== 1)
1801
1865
  return;
1802
- const drawingCache = this._transformerCache.values().next().value, object = objects.values().next().value;
1803
- this._getDrawingAnchor(drawingCache.drawing, object);
1866
+ const n = this._transformerCache.values().next().value, t = e.values().next().value;
1867
+ this._getDrawingAnchor(n.drawing, t);
1804
1868
  }
1805
- _updateInlineDrawingAnchor(drawing, offsetX, offsetY) {
1806
- var _a8;
1869
+ _updateInlineDrawingAnchor(e, n, t) {
1870
+ var o;
1807
1871
  if (this._transformerCache.size !== 1)
1808
1872
  return;
1809
- const { contentBoxPointGroup } = (_a8 = this._getInlineDrawingAnchor(drawing, offsetX, offsetY)) != null ? _a8 : {};
1810
- contentBoxPointGroup != null && this._createOrUpdateInlineAnchor(drawing.unitId, contentBoxPointGroup);
1873
+ const { contentBoxPointGroup: r } = (o = this._getInlineDrawingAnchor(e, n, t)) != null ? o : {};
1874
+ r != null && this._createOrUpdateInlineAnchor(e.unitId, r);
1811
1875
  }
1812
- _getInlineDrawingAnchor(drawing, offsetX, offsetY) {
1813
- var _a8, _b;
1814
- const currentRender = this._renderManagerService.getRenderById(drawing.unitId), skeleton = currentRender == null ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
1815
- if (currentRender == null)
1876
+ _getInlineDrawingAnchor(e, n, t) {
1877
+ var E, W;
1878
+ const r = this._renderManagerService.getRenderById(e.unitId), o = r == null ? void 0 : r.with(oe).getSkeleton();
1879
+ if (r == null)
1816
1880
  return;
1817
- const { mainComponent, scene } = currentRender, documentComponent = mainComponent, activeViewport = scene.getViewports()[0], {
1818
- pageLayoutType = PageLayoutType.VERTICAL,
1819
- pageMarginLeft,
1820
- pageMarginTop
1821
- } = documentComponent.getOffsetConfig();
1822
- let glyphAnchor = null, isBack = !1, segmentPageIndex = -1, segmentId = "";
1823
- const HALF = 0.5, coord = this._getTransformCoordForDocumentOffset(documentComponent, activeViewport, offsetX, offsetY);
1824
- if (coord == null)
1881
+ const { mainComponent: s, scene: a } = r, d = s, c = a.getViewports()[0], {
1882
+ pageLayoutType: g = bn.VERTICAL,
1883
+ pageMarginLeft: f,
1884
+ pageMarginTop: m
1885
+ } = d.getOffsetConfig();
1886
+ let p = null, h = !1, v = -1, w = "";
1887
+ const S = 0.5, O = this._getTransformCoordForDocumentOffset(d, c, n, t);
1888
+ if (O == null)
1825
1889
  return;
1826
- const docSelectionRenderService = (_a8 = this._renderManagerService.getRenderById(drawing.unitId)) == null ? void 0 : _a8.with(DocSelectionRenderService);
1827
- if (docSelectionRenderService == null)
1890
+ const D = (E = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : E.with(ye);
1891
+ if (D == null)
1828
1892
  return;
1829
- const nodeInfo = skeleton == null ? void 0 : skeleton.findNodeByCoord(
1830
- coord,
1831
- pageLayoutType,
1832
- pageMarginLeft,
1833
- pageMarginTop,
1893
+ const x = o == null ? void 0 : o.findNodeByCoord(
1894
+ O,
1895
+ g,
1896
+ f,
1897
+ m,
1834
1898
  {
1835
1899
  strict: !1,
1836
- segmentId: docSelectionRenderService.getSegment(),
1837
- segmentPage: docSelectionRenderService.getSegmentPage()
1900
+ segmentId: D.getSegment(),
1901
+ segmentPage: D.getSegmentPage()
1838
1902
  }
1839
1903
  );
1840
- if (nodeInfo) {
1841
- const { node, ratioX, segmentPage, segmentId: nodeSegmentId } = nodeInfo;
1842
- isBack = ratioX < HALF, glyphAnchor = node, segmentPageIndex = segmentPage, segmentId = nodeSegmentId;
1904
+ if (x) {
1905
+ const { node: _, ratioX: C, segmentPage: M, segmentId: P } = x;
1906
+ h = C < S, p = _, v = M, w = P;
1843
1907
  }
1844
- if (glyphAnchor == null)
1908
+ if (p == null)
1845
1909
  return;
1846
- const nodePosition = skeleton == null ? void 0 : skeleton.findPositionByGlyph(glyphAnchor, segmentPageIndex), docObject = this._getDocObject();
1847
- if (nodePosition == null || skeleton == null || docObject == null || isInTableCell(nodePosition))
1910
+ const b = o == null ? void 0 : o.findPositionByGlyph(p, v), T = this._getDocObject();
1911
+ if (b == null || o == null || T == null || kn(b))
1848
1912
  return;
1849
- const positionWithIsBack = {
1850
- ...nodePosition,
1851
- isBack
1852
- }, documentOffsetConfig = docObject.document.getOffsetConfig(), convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { cursorList, contentBoxPointGroup } = convertor.getRangePointData(positionWithIsBack, positionWithIsBack), { startOffset } = (_b = getOneTextSelectionRange(cursorList)) != null ? _b : {};
1853
- if (startOffset != null)
1854
- return { offset: startOffset, contentBoxPointGroup, segmentId, segmentPage: segmentPageIndex };
1913
+ const N = {
1914
+ ...b,
1915
+ isBack: h
1916
+ }, B = T.document.getOffsetConfig(), R = new Rn(B, o), { cursorList: I, contentBoxPointGroup: j } = R.getRangePointData(N, N), { startOffset: H } = (W = Nn(I)) != null ? W : {};
1917
+ if (H != null)
1918
+ return { offset: H, contentBoxPointGroup: j, segmentId: w, segmentPage: v };
1855
1919
  }
1856
1920
  // eslint-disable-next-line max-lines-per-function, complexity
1857
- _getDrawingAnchor(drawing, object) {
1858
- var _a8, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1859
- const currentRender = this._renderManagerService.getRenderById(drawing.unitId), skeleton = currentRender == null ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton(), skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData();
1860
- if (skeletonData == null || currentRender == null)
1921
+ _getDrawingAnchor(e, n) {
1922
+ var Ie, _e, ce, Ce, De, Me, Re, Oe, de, le, Ne;
1923
+ const t = this._renderManagerService.getRenderById(e.unitId), r = t == null ? void 0 : t.with(oe).getSkeleton(), o = r == null ? void 0 : r.getSkeletonData();
1924
+ if (o == null || t == null)
1861
1925
  return;
1862
- const { pages, skeHeaders, skeFooters } = skeletonData, { mainComponent, scene } = currentRender, documentComponent = mainComponent, activeViewport = scene.getViewports()[0], { pageLayoutType = PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop, docsLeft, docsTop } = documentComponent.getOffsetConfig(), { left, top, angle } = object;
1863
- let { width, height } = object;
1864
- const { positionV, positionH } = drawing.docTransform, { width: maxWidth, height: maxHeight } = this._getPageContentSize(drawing);
1865
- width = Math.min(width, maxWidth), height = Math.min(height, maxHeight);
1866
- let glyphAnchor = null, segmentId = "", segmentPage = -1;
1867
- const isBack = !1, docTransform = {
1868
- ...drawing.docTransform,
1926
+ const { pages: s, skeHeaders: a, skeFooters: d } = o, { mainComponent: c, scene: g } = t, f = c, m = g.getViewports()[0], { pageLayoutType: p = bn.VERTICAL, pageMarginLeft: h, pageMarginTop: v, docsLeft: w, docsTop: S } = f.getOffsetConfig(), { left: O, top: D, angle: x } = n;
1927
+ let { width: b, height: T } = n;
1928
+ const { positionV: N, positionH: B } = e.docTransform, { width: R, height: I } = this._getPageContentSize(e);
1929
+ b = Math.min(b, R), T = Math.min(T, I);
1930
+ let j = null, H = "", E = -1;
1931
+ const W = !1, _ = {
1932
+ ...e.docTransform,
1869
1933
  size: {
1870
- width,
1871
- height
1934
+ width: b,
1935
+ height: T
1872
1936
  },
1873
- angle
1874
- }, { x, y } = scene.getViewportScrollXY(activeViewport), coord = this._getTransformCoordForDocumentOffset(documentComponent, activeViewport, left - x, top - y);
1875
- if (coord == null)
1937
+ angle: x
1938
+ }, { x: C, y: M } = g.getViewportScrollXY(m), P = this._getTransformCoordForDocumentOffset(f, m, O - C, D - M);
1939
+ if (P == null)
1876
1940
  return;
1877
- const docSelectionRenderService = (_a8 = this._renderManagerService.getRenderById(drawing.unitId)) == null ? void 0 : _a8.with(DocSelectionRenderService);
1878
- if (docSelectionRenderService == null)
1941
+ const L = (Ie = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : Ie.with(ye);
1942
+ if (L == null)
1879
1943
  return;
1880
- const nodeInfo = skeleton == null ? void 0 : skeleton.findNodeByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop, {
1944
+ const U = r == null ? void 0 : r.findNodeByCoord(P, p, h, v, {
1881
1945
  strict: !1,
1882
- segmentId: docSelectionRenderService.getSegment(),
1883
- segmentPage: docSelectionRenderService.getSegmentPage()
1946
+ segmentId: L.getSegment(),
1947
+ segmentPage: L.getSegmentPage()
1884
1948
  });
1885
- if (nodeInfo) {
1886
- const { node, segmentPage: segmentPageIndex, segmentId: nodeSegmentId } = nodeInfo;
1887
- glyphAnchor = node, segmentPage = segmentPageIndex, segmentId = nodeSegmentId;
1949
+ if (U) {
1950
+ const { node: he, segmentPage: mn, segmentId: un } = U;
1951
+ j = he, E = mn, H = un;
1888
1952
  }
1889
- if (glyphAnchor == null)
1953
+ if (j == null)
1890
1954
  return;
1891
- const line = (_b = glyphAnchor.parent) == null ? void 0 : _b.parent, column = line == null ? void 0 : line.parent, paragraphStartLine = (_c = column == null ? void 0 : column.lines.find((l) => l.paragraphIndex === (line == null ? void 0 : line.paragraphIndex) && l.paragraphStart)) != null ? _c : column == null ? void 0 : column.lines[0], page = (_d = column == null ? void 0 : column.parent) == null ? void 0 : _d.parent;
1892
- if (line == null || column == null || paragraphStartLine == null || page == null)
1955
+ const y = (_e = j.parent) == null ? void 0 : _e.parent, A = y == null ? void 0 : y.parent, $ = (ce = A == null ? void 0 : A.lines.find((he) => he.paragraphIndex === (y == null ? void 0 : y.paragraphIndex) && he.paragraphStart)) != null ? ce : A == null ? void 0 : A.lines[0], F = (Ce = A == null ? void 0 : A.parent) == null ? void 0 : Ce.parent;
1956
+ if (y == null || A == null || $ == null || F == null)
1893
1957
  return;
1894
1958
  this._liquid.reset();
1895
- const pageType = page.type;
1896
- for (const p of pages) {
1897
- const { headerId, footerId, pageHeight, pageWidth, marginLeft, marginBottom } = p, pIndex = pages.indexOf(p);
1898
- if (segmentPage > -1 && pIndex === segmentPage) {
1899
- switch (pageType) {
1900
- case DocumentSkeletonPageType.HEADER: {
1901
- const headerSke = (_e = skeHeaders.get(headerId)) == null ? void 0 : _e.get(pageWidth);
1902
- if (headerSke)
1959
+ const K = F.type;
1960
+ for (const he of s) {
1961
+ const { headerId: mn, footerId: un, pageHeight: _t, pageWidth: Cn, marginLeft: Dn, marginBottom: St } = he, Ct = s.indexOf(he);
1962
+ if (E > -1 && Ct === E) {
1963
+ switch (K) {
1964
+ case Mn.HEADER: {
1965
+ const He = (De = a.get(mn)) == null ? void 0 : De.get(Cn);
1966
+ if (He)
1903
1967
  this._liquid.translatePagePadding({
1904
- marginTop: headerSke.marginTop,
1905
- marginLeft
1968
+ marginTop: He.marginTop,
1969
+ marginLeft: Dn
1906
1970
  });
1907
1971
  else
1908
1972
  throw new Error("header skeleton not found");
1909
1973
  break;
1910
1974
  }
1911
- case DocumentSkeletonPageType.FOOTER: {
1912
- const footerSke = (_f = skeFooters.get(footerId)) == null ? void 0 : _f.get(pageWidth);
1913
- if (footerSke)
1975
+ case Mn.FOOTER: {
1976
+ const He = (Me = d.get(un)) == null ? void 0 : Me.get(Cn);
1977
+ if (He)
1914
1978
  this._liquid.translatePagePadding({
1915
- marginTop: pageHeight - marginBottom + footerSke.marginTop,
1916
- marginLeft
1979
+ marginTop: _t - St + He.marginTop,
1980
+ marginLeft: Dn
1917
1981
  });
1918
1982
  else
1919
1983
  throw new Error("footer skeleton not found");
@@ -1922,552 +1986,551 @@ let DocDrawingTransformerController = (_a4 = class extends Disposable {
1922
1986
  }
1923
1987
  break;
1924
1988
  }
1925
- if (this._liquid.translatePagePadding(p), p === page)
1989
+ if (this._liquid.translatePagePadding(he), he === F)
1926
1990
  break;
1927
- this._liquid.restorePagePadding(p), this._liquid.translatePage(p, pageLayoutType, pageMarginLeft, pageMarginTop);
1991
+ this._liquid.restorePagePadding(he), this._liquid.translatePage(he, p, h, v);
1928
1992
  }
1929
- switch (positionV.relativeFrom === ObjectRelativeFromV.LINE ? glyphAnchor = line.divides[0].glyphGroup[0] : glyphAnchor = (_j = (_i = (_h = (_g = paragraphStartLine.divides) == null ? void 0 : _g[0]) == null ? void 0 : _h.glyphGroup) == null ? void 0 : _i[0]) != null ? _j : glyphAnchor, docTransform.positionH = {
1930
- relativeFrom: positionH.relativeFrom,
1931
- posOffset: left - this._liquid.x - docsLeft
1932
- }, positionH.relativeFrom) {
1933
- case ObjectRelativeFromH.MARGIN: {
1934
- docTransform.positionH.posOffset = left - this._liquid.x - docsLeft - page.marginLeft;
1993
+ switch (N.relativeFrom === G.LINE ? j = y.divides[0].glyphGroup[0] : j = (le = (de = (Oe = (Re = $.divides) == null ? void 0 : Re[0]) == null ? void 0 : Oe.glyphGroup) == null ? void 0 : de[0]) != null ? le : j, _.positionH = {
1994
+ relativeFrom: B.relativeFrom,
1995
+ posOffset: O - this._liquid.x - w
1996
+ }, B.relativeFrom) {
1997
+ case ee.MARGIN: {
1998
+ _.positionH.posOffset = O - this._liquid.x - w - F.marginLeft;
1935
1999
  break;
1936
2000
  }
1937
- case ObjectRelativeFromH.COLUMN: {
1938
- docTransform.positionH.posOffset = left - this._liquid.x - docsLeft - column.left;
2001
+ case ee.COLUMN: {
2002
+ _.positionH.posOffset = O - this._liquid.x - w - A.left;
1939
2003
  break;
1940
2004
  }
1941
2005
  }
1942
- switch (docTransform.positionV = {
1943
- relativeFrom: positionV.relativeFrom,
1944
- posOffset: top - this._liquid.y - docsTop
1945
- }, positionV.relativeFrom) {
1946
- case ObjectRelativeFromV.PAGE: {
1947
- docTransform.positionV.posOffset = top - this._liquid.y - docsTop - page.marginTop;
2006
+ switch (_.positionV = {
2007
+ relativeFrom: N.relativeFrom,
2008
+ posOffset: D - this._liquid.y - S
2009
+ }, N.relativeFrom) {
2010
+ case G.PAGE: {
2011
+ _.positionV.posOffset = D - this._liquid.y - S - F.marginTop;
1948
2012
  break;
1949
2013
  }
1950
- case ObjectRelativeFromV.LINE: {
1951
- docTransform.positionV.posOffset = top - this._liquid.y - docsTop - line.top;
2014
+ case G.LINE: {
2015
+ _.positionV.posOffset = D - this._liquid.y - S - y.top;
1952
2016
  break;
1953
2017
  }
1954
- case ObjectRelativeFromV.PARAGRAPH: {
1955
- docTransform.positionV.posOffset = top - this._liquid.y - docsTop - paragraphStartLine.top;
2018
+ case G.PARAGRAPH: {
2019
+ _.positionV.posOffset = D - this._liquid.y - S - $.top;
1956
2020
  break;
1957
2021
  }
1958
2022
  }
1959
- if (glyphAnchor == null)
2023
+ if (j == null)
1960
2024
  return;
1961
- const nodePosition = skeleton == null ? void 0 : skeleton.findPositionByGlyph(glyphAnchor, segmentPage), docObject = this._getDocObject();
1962
- if (nodePosition == null || skeleton == null || docObject == null || isInTableCell(nodePosition))
2025
+ const se = r == null ? void 0 : r.findPositionByGlyph(j, E), Le = this._getDocObject();
2026
+ if (se == null || r == null || Le == null || kn(se))
1963
2027
  return;
1964
- const positionWithIsBack = {
1965
- ...nodePosition,
1966
- isBack
1967
- }, documentOffsetConfig = docObject.document.getOffsetConfig(), convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { cursorList } = convertor.getRangePointData(positionWithIsBack, positionWithIsBack), { startOffset } = (_k = getOneTextSelectionRange(cursorList)) != null ? _k : {};
1968
- if (startOffset != null)
1969
- return { offset: startOffset, docTransform, segmentId, segmentPage };
2028
+ const be = {
2029
+ ...se,
2030
+ isBack: W
2031
+ }, ke = Le.document.getOffsetConfig(), ae = new Rn(ke, r), { cursorList: ne } = ae.getRangePointData(be, be), { startOffset: te } = (Ne = Nn(ne)) != null ? Ne : {};
2032
+ if (te != null)
2033
+ return { offset: te, docTransform: _, segmentId: H, segmentPage: E };
1970
2034
  }
1971
2035
  // Update drawing when use transformer to resize it.
1972
- _updateDrawingSize(drawingCache, object) {
1973
- const drawings = [], { drawing, width: oldWidth, height: oldHeight, angle: oldAngle } = drawingCache, { unitId, subUnitId } = drawing;
1974
- let { width, height, angle } = object;
1975
- const { width: maxWidth, height: maxHeight } = this._getPageContentSize(drawing);
1976
- width = Math.min(maxWidth, width), height = Math.min(maxHeight, height), (width !== oldWidth || height !== oldHeight) && drawings.push({
1977
- drawingId: drawing.drawingId,
2036
+ _updateDrawingSize(e, n) {
2037
+ const t = [], { drawing: r, width: o, height: s, angle: a } = e, { unitId: d, subUnitId: c } = r;
2038
+ let { width: g, height: f, angle: m } = n;
2039
+ const { width: p, height: h } = this._getPageContentSize(r);
2040
+ g = Math.min(p, g), f = Math.min(h, f), (g !== o || f !== s) && t.push({
2041
+ drawingId: r.drawingId,
1978
2042
  key: "size",
1979
2043
  value: {
1980
- width,
1981
- height
2044
+ width: g,
2045
+ height: f
1982
2046
  }
1983
- }), angle !== oldAngle && drawings.push({
1984
- drawingId: drawing.drawingId,
2047
+ }), m !== a && t.push({
2048
+ drawingId: r.drawingId,
1985
2049
  key: "angle",
1986
- value: angle
1987
- }), drawings.length > 0 && unitId && subUnitId && this._commandService.executeCommand(UpdateDrawingDocTransformCommand.id, {
1988
- unitId,
1989
- subUnitId,
1990
- drawings
2050
+ value: m
2051
+ }), t.length > 0 && d && c && this._commandService.executeCommand(ze.id, {
2052
+ unitId: d,
2053
+ subUnitId: c,
2054
+ drawings: t
1991
2055
  });
1992
2056
  }
1993
2057
  // Update inline drawing when use transformer to move it.
1994
- _moveInlineDrawing(drawing, offsetX, offsetY) {
1995
- const anchor = this._getInlineDrawingAnchor(drawing, offsetX, offsetY), { offset, segmentId, segmentPage } = anchor != null ? anchor : {};
1996
- return this._commandService.executeCommand(IMoveInlineDrawingCommand.id, {
1997
- unitId: drawing.unitId,
1998
- subUnitId: drawing.unitId,
1999
- drawing,
2000
- offset,
2001
- segmentId,
2002
- segmentPage,
2003
- needRefreshDrawings: offset == null
2058
+ _moveInlineDrawing(e, n, t) {
2059
+ const r = this._getInlineDrawingAnchor(e, n, t), { offset: o, segmentId: s, segmentPage: a } = r != null ? r : {};
2060
+ return this._commandService.executeCommand(at.id, {
2061
+ unitId: e.unitId,
2062
+ subUnitId: e.unitId,
2063
+ drawing: e,
2064
+ offset: o,
2065
+ segmentId: s,
2066
+ segmentPage: a,
2067
+ needRefreshDrawings: o == null
2004
2068
  });
2005
2069
  }
2006
2070
  // Limit the drawing to the page area, mainly in the vertical direction,
2007
2071
  // and the upper and lower limits cannot exceed the page margin area.
2008
- _limitDrawingInPage(drawing, object) {
2009
- const currentRender = this._renderManagerService.getRenderById(drawing.unitId), { left, top, width, height, angle } = object, skeleton = currentRender == null ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton(), skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData(), { pages } = skeletonData != null ? skeletonData : {};
2010
- if (skeletonData == null || currentRender == null || pages == null)
2072
+ _limitDrawingInPage(e, n) {
2073
+ const t = this._renderManagerService.getRenderById(e.unitId), { left: r, top: o, width: s, height: a, angle: d } = n, c = t == null ? void 0 : t.with(oe).getSkeleton(), g = c == null ? void 0 : c.getSkeletonData(), { pages: f } = g != null ? g : {};
2074
+ if (g == null || t == null || f == null)
2011
2075
  return {
2012
- left,
2013
- top,
2014
- width,
2015
- height,
2016
- angle
2076
+ left: r,
2077
+ top: o,
2078
+ width: s,
2079
+ height: a,
2080
+ angle: d
2017
2081
  };
2018
- const { mainComponent } = currentRender, documentComponent = mainComponent, { top: docsTop, pageLayoutType, pageMarginLeft, pageMarginTop } = documentComponent;
2019
- let newTop = top;
2082
+ const { mainComponent: m } = t, p = m, { top: h, pageLayoutType: v, pageMarginLeft: w, pageMarginTop: S } = p;
2083
+ let O = o;
2020
2084
  this._liquid.reset();
2021
- for (const page of pages) {
2022
- const { marginBottom, pageHeight } = page, index = pages.indexOf(page), nextPage = pages[index + 1];
2023
- if (nextPage == null)
2085
+ for (const D of f) {
2086
+ const { marginBottom: x, pageHeight: b } = D, T = f.indexOf(D), N = f[T + 1];
2087
+ if (N == null)
2024
2088
  continue;
2025
- if (Tools.hasIntersectionBetweenTwoRanges(
2026
- top,
2027
- top + height,
2028
- this._liquid.y + docsTop + pageHeight - marginBottom,
2029
- this._liquid.y + docsTop + pageHeight + pageMarginTop + nextPage.marginTop
2089
+ if (Pe.hasIntersectionBetweenTwoRanges(
2090
+ o,
2091
+ o + a,
2092
+ this._liquid.y + h + b - x,
2093
+ this._liquid.y + h + b + S + N.marginTop
2030
2094
  )) {
2031
- const drawingVMiddle = top + height / 2, pagesMiddle = this._liquid.y + docsTop + pageHeight + pageMarginTop / 2;
2032
- drawingVMiddle < pagesMiddle ? newTop = Math.min(top, this._liquid.y + docsTop + pageHeight - marginBottom - height) : newTop = Math.max(top, this._liquid.y + docsTop + pageHeight + pageMarginTop + nextPage.marginTop);
2095
+ const R = o + a / 2, I = this._liquid.y + h + b + S / 2;
2096
+ R < I ? O = Math.min(o, this._liquid.y + h + b - x - a) : O = Math.max(o, this._liquid.y + h + b + S + N.marginTop);
2033
2097
  }
2034
- this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
2098
+ this._liquid.translatePage(D, v, w, S);
2035
2099
  }
2036
2100
  return {
2037
- left,
2038
- top: newTop,
2039
- width,
2040
- height,
2041
- angle
2101
+ left: r,
2102
+ top: O,
2103
+ width: s,
2104
+ height: a,
2105
+ angle: d
2042
2106
  };
2043
2107
  }
2044
- _nonInlineDrawingTransform(drawing, object, isMoving = !1) {
2045
- const objectPosition = drawing.isMultiTransform === BooleanNumber.TRUE ? object : this._limitDrawingInPage(drawing, object);
2046
- if (isMoving && objectPosition.top !== object.top)
2108
+ _nonInlineDrawingTransform(e, n, t = !1) {
2109
+ const r = e.isMultiTransform === re.TRUE ? n : this._limitDrawingInPage(e, n);
2110
+ if (t && r.top !== n.top)
2047
2111
  return;
2048
- const anchor = this._getDrawingAnchor(drawing, objectPosition), { offset, docTransform, segmentId, segmentPage } = anchor != null ? anchor : {};
2049
- return offset == null || docTransform == null ? this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[drawing.drawingId, object]])) : this._commandService.executeCommand(ITransformNonInlineDrawingCommand.id, {
2050
- unitId: drawing.unitId,
2051
- subUnitId: drawing.unitId,
2052
- drawing,
2053
- offset,
2054
- docTransform,
2055
- segmentId,
2056
- segmentPage
2112
+ const o = this._getDrawingAnchor(e, r), { offset: s, docTransform: a, segmentId: d, segmentPage: c } = o != null ? o : {};
2113
+ return s == null || a == null ? this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[e.drawingId, n]])) : this._commandService.executeCommand(ct.id, {
2114
+ unitId: e.unitId,
2115
+ subUnitId: e.unitId,
2116
+ drawing: e,
2117
+ offset: s,
2118
+ docTransform: a,
2119
+ segmentId: d,
2120
+ segmentPage: c
2057
2121
  });
2058
2122
  }
2059
- _getSceneAndTransformerByDrawingSearch(unitId) {
2060
- if (unitId == null)
2123
+ _getSceneAndTransformerByDrawingSearch(e) {
2124
+ if (e == null)
2061
2125
  return;
2062
- const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
2063
- if (scene == null)
2126
+ const n = this._renderManagerService.getRenderById(e), t = n == null ? void 0 : n.scene;
2127
+ if (t == null)
2064
2128
  return;
2065
- const transformer = scene.getTransformerByCreate();
2066
- return { scene, transformer };
2129
+ const r = t.getTransformerByCreate();
2130
+ return { scene: t, transformer: r };
2067
2131
  }
2068
- _getTransformCoordForDocumentOffset(document, viewport, evtOffsetX, evtOffsetY) {
2069
- const { documentTransform } = document.getOffsetConfig(), originCoord = viewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
2070
- if (originCoord)
2071
- return documentTransform.clone().invert().applyPoint(originCoord);
2132
+ _getTransformCoordForDocumentOffset(e, n, t, r) {
2133
+ const { documentTransform: o } = e.getOffsetConfig(), s = n.transformVector2SceneCoord(Jt.FromArray([t, r]));
2134
+ if (s)
2135
+ return o.clone().invert().applyPoint(s);
2072
2136
  }
2073
- _createOrUpdateInlineAnchor(unitId, pointsGroup) {
2074
- const currentRender = this._renderManagerService.getRenderById(unitId);
2075
- if (currentRender == null)
2137
+ _createOrUpdateInlineAnchor(e, n) {
2138
+ const t = this._renderManagerService.getRenderById(e);
2139
+ if (t == null)
2076
2140
  return;
2077
- const { mainComponent, scene } = currentRender, documentComponent = mainComponent, {
2078
- docsLeft,
2079
- docsTop
2080
- } = documentComponent.getOffsetConfig(), bounding = getAnchorBounding(pointsGroup), { left: boundingLeft, top: boundingTop, height } = bounding, left = boundingLeft + docsLeft, top = boundingTop + docsTop;
2141
+ const { mainComponent: r, scene: o } = t, s = r, {
2142
+ docsLeft: a,
2143
+ docsTop: d
2144
+ } = s.getOffsetConfig(), c = mi(n), { left: g, top: f, height: m } = c, p = g + a, h = f + d;
2081
2145
  if (this._anchorShape) {
2082
- this._anchorShape.transformByState({ left, top, height }), this._anchorShape.show();
2146
+ this._anchorShape.transformByState({ left: p, top: h, height: m }), this._anchorShape.show();
2083
2147
  return;
2084
2148
  }
2085
- const ID_LENGTH = 6, anchor = new Rect(INLINE_DRAWING_ANCHOR_KEY_PREFIX + Tools.generateRandomId(ID_LENGTH), {
2086
- left,
2087
- top,
2088
- height,
2149
+ const v = 6, w = new Qt(Pr + Pe.generateRandomId(v), {
2150
+ left: p,
2151
+ top: h,
2152
+ height: m,
2089
2153
  strokeWidth: 2,
2090
- stroke: getColor(COLORS.darkGray, 1),
2154
+ stroke: ei(Mt.darkGray, 1),
2091
2155
  evented: !1
2092
2156
  });
2093
- this._anchorShape = anchor, scene.addObject(anchor, TEXT_RANGE_LAYER_INDEX);
2157
+ this._anchorShape = w, o.addObject(w, ui);
2094
2158
  }
2095
2159
  _getDocObject() {
2096
- return getDocObject(this._univerInstanceService, this._renderManagerService);
2160
+ return fi(this._univerInstanceService, this._renderManagerService);
2097
2161
  }
2098
- _getPageContentSize(drawing) {
2099
- const currentRender = this._renderManagerService.getRenderById(drawing.unitId), skeleton = currentRender == null ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton(), MAX_WIDTH = 500, MAX_HEIGHT = 500, skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData();
2100
- if (skeletonData == null || currentRender == null)
2162
+ _getPageContentSize(e) {
2163
+ const n = this._renderManagerService.getRenderById(e.unitId), t = n == null ? void 0 : n.with(oe).getSkeleton(), r = 500, o = 500, s = t == null ? void 0 : t.getSkeletonData();
2164
+ if (s == null || n == null)
2101
2165
  return {
2102
- width: MAX_WIDTH,
2103
- height: MAX_HEIGHT
2166
+ width: r,
2167
+ height: o
2104
2168
  };
2105
- const { pages } = skeletonData;
2106
- let page = null;
2107
- for (const p of pages) {
2108
- const { skeDrawings } = p;
2109
- if (skeDrawings.has(drawing.drawingId)) {
2110
- page = p;
2169
+ const { pages: a } = s;
2170
+ let d = null;
2171
+ for (const c of a) {
2172
+ const { skeDrawings: g } = c;
2173
+ if (g.has(e.drawingId)) {
2174
+ d = c;
2111
2175
  break;
2112
2176
  }
2113
2177
  }
2114
- if (page) {
2115
- const { pageWidth, pageHeight, marginLeft, marginBottom, marginRight, marginTop } = page;
2178
+ if (d) {
2179
+ const { pageWidth: c, pageHeight: g, marginLeft: f, marginBottom: m, marginRight: p, marginTop: h } = d;
2116
2180
  return {
2117
- width: Math.max(MAX_WIDTH, pageWidth - marginLeft - marginRight),
2118
- height: Math.max(MAX_HEIGHT, pageHeight - marginTop - marginBottom)
2181
+ width: Math.max(r, c - f - p),
2182
+ height: Math.max(o, g - h - m)
2119
2183
  };
2120
2184
  } else
2121
2185
  return {
2122
- width: MAX_WIDTH,
2123
- height: MAX_HEIGHT
2186
+ width: r,
2187
+ height: o
2124
2188
  };
2125
2189
  }
2126
- }, __name(_a4, "DocDrawingTransformerController"), _a4);
2127
- DocDrawingTransformerController = __decorateClass$3([
2128
- __decorateParam$3(0, ICommandService),
2129
- __decorateParam$3(1, IUniverInstanceService),
2130
- __decorateParam$3(2, IDrawingManagerService),
2131
- __decorateParam$3(3, IRenderManagerService)
2132
- ], DocDrawingTransformerController);
2133
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2134
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2135
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2136
- return kind && result && __defProp$2(target, key, result), result;
2137
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a5;
2138
- let DocDrawingPopupMenuController = (_a5 = class extends RxDisposable {
2139
- constructor(_drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService) {
2190
+ };
2191
+ sn = xr([
2192
+ en(0, z),
2193
+ en(1, Z),
2194
+ en(2, ve),
2195
+ en(3, Q)
2196
+ ], sn);
2197
+ var Tr = Object.defineProperty, yr = Object.getOwnPropertyDescriptor, br = (i, e, n, t) => {
2198
+ for (var r = t > 1 ? void 0 : t ? yr(e, n) : e, o = i.length - 1, s; o >= 0; o--)
2199
+ (s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
2200
+ return t && r && Tr(e, n, r), r;
2201
+ }, Ge = (i, e) => (n, t) => e(n, t, i);
2202
+ let an = class extends Rt {
2203
+ constructor(e, n, t, r, o) {
2140
2204
  super();
2141
- __publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
2142
- this._drawingManagerService = _drawingManagerService, this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._init();
2205
+ Se(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
2206
+ this._drawingManagerService = e, this._canvasPopManagerService = n, this._renderManagerService = t, this._univerInstanceService = r, this._contextService = o, this._init();
2143
2207
  }
2144
2208
  _init() {
2145
- this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((documentDataModel) => this._create(documentDataModel)), this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((documentDataModel) => this._dispose(documentDataModel)), this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentDataModel) => this._create(documentDataModel));
2209
+ this._univerInstanceService.getCurrentTypeOfUnit$(Te.UNIVER_DOC).pipe(Ln(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(Te.UNIVER_DOC).pipe(Ln(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(Te.UNIVER_DOC).forEach((e) => this._create(e));
2146
2210
  }
2147
- _dispose(documentDataModel) {
2148
- const unitId = documentDataModel.getUnitId();
2149
- this._renderManagerService.removeRender(unitId);
2211
+ _dispose(e) {
2212
+ const n = e.getUnitId();
2213
+ this._renderManagerService.removeRender(n);
2150
2214
  }
2151
- _create(documentDataModel) {
2152
- if (!documentDataModel)
2215
+ _create(e) {
2216
+ if (!e)
2153
2217
  return;
2154
- const unitId = documentDataModel.getUnitId();
2155
- this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
2218
+ const n = e.getUnitId();
2219
+ this._renderManagerService.has(n) && !this._initImagePopupMenu.has(n) && (this._popupMenuListener(n), this._initImagePopupMenu.add(n));
2156
2220
  }
2157
- _hasCropObject(scene) {
2158
- const objects = scene.getAllObjects();
2159
- for (const object of objects)
2160
- if (object instanceof ImageCropperObject)
2221
+ _hasCropObject(e) {
2222
+ const n = e.getAllObjects();
2223
+ for (const t of n)
2224
+ if (t instanceof qt)
2161
2225
  return !0;
2162
2226
  return !1;
2163
2227
  }
2164
2228
  // eslint-disable-next-line max-lines-per-function
2165
- _popupMenuListener(unitId) {
2166
- var _a8;
2167
- const scene = (_a8 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a8.scene;
2168
- if (!scene)
2229
+ _popupMenuListener(e) {
2230
+ var o;
2231
+ const n = (o = this._renderManagerService.getRenderById(e)) == null ? void 0 : o.scene;
2232
+ if (!n)
2169
2233
  return;
2170
- const transformer = scene.getTransformerByCreate();
2171
- if (!transformer)
2234
+ const t = n.getTransformerByCreate();
2235
+ if (!t)
2172
2236
  return;
2173
- const disposePopups = [];
2237
+ const r = [];
2174
2238
  this.disposeWithMe(
2175
- toDisposable(
2176
- transformer.createControl$.subscribe(() => {
2177
- if (this._hasCropObject(scene))
2239
+ Ee(
2240
+ t.createControl$.subscribe(() => {
2241
+ if (this._hasCropObject(n))
2178
2242
  return;
2179
- const selectedObjects = transformer.getSelectedObjectMap();
2180
- if (disposePopups.forEach((dispose) => dispose.dispose()), disposePopups.length = 0, selectedObjects.size > 1)
2243
+ const s = t.getSelectedObjectMap();
2244
+ if (r.forEach((w) => w.dispose()), r.length = 0, s.size > 1)
2181
2245
  return;
2182
- const object = selectedObjects.values().next().value;
2183
- if (!object)
2246
+ const a = s.values().next().value;
2247
+ if (!a)
2184
2248
  return;
2185
- const oKey = object.oKey, drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
2186
- if (!drawingParam)
2249
+ const d = a.oKey, c = this._drawingManagerService.getDrawingOKey(d);
2250
+ if (!c)
2187
2251
  return;
2188
- const { unitId: unitId2, subUnitId, drawingId } = drawingParam, popup = this._canvasPopManagerService.attachPopupToObject(
2189
- object,
2252
+ const { unitId: g, subUnitId: f, drawingId: m } = c, p = this._canvasPopManagerService.attachPopupToObject(
2253
+ a,
2190
2254
  {
2191
- componentKey: COMPONENT_IMAGE_POPUP_MENU,
2255
+ componentKey: Xt,
2192
2256
  direction: "horizontal",
2193
2257
  offset: [2, 0],
2194
2258
  extraProps: {
2195
- menuItems: this._getImageMenuItems(unitId2, subUnitId, drawingId)
2259
+ menuItems: this._getImageMenuItems(g, f, m)
2196
2260
  }
2197
2261
  },
2198
- unitId2
2262
+ g
2199
2263
  );
2200
- disposePopups.push(this.disposeWithMe(popup)), !this._drawingManagerService.getFocusDrawings().find((drawing) => drawing.unitId === unitId2 && drawing.subUnitId === subUnitId && drawing.drawingId === drawingId) && this._drawingManagerService.focusDrawing([{
2201
- unitId: unitId2,
2202
- subUnitId,
2203
- drawingId
2264
+ r.push(this.disposeWithMe(p)), !this._drawingManagerService.getFocusDrawings().find((w) => w.unitId === g && w.subUnitId === f && w.drawingId === m) && this._drawingManagerService.focusDrawing([{
2265
+ unitId: g,
2266
+ subUnitId: f,
2267
+ drawingId: m
2204
2268
  }]);
2205
2269
  })
2206
2270
  )
2207
2271
  ), this.disposeWithMe(
2208
- toDisposable(
2209
- transformer.clearControl$.subscribe(() => {
2210
- disposePopups.forEach((dispose) => dispose.dispose()), disposePopups.length = 0, this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._drawingManagerService.focusDrawing(null);
2272
+ Ee(
2273
+ t.clearControl$.subscribe(() => {
2274
+ r.forEach((s) => s.dispose()), r.length = 0, this._contextService.setContextValue(nn, !1), this._drawingManagerService.focusDrawing(null);
2211
2275
  })
2212
2276
  )
2213
2277
  ), this.disposeWithMe(
2214
- toDisposable(
2215
- transformer.changing$.subscribe(() => {
2216
- disposePopups.forEach((dispose) => dispose.dispose()), disposePopups.length = 0;
2278
+ Ee(
2279
+ t.changing$.subscribe(() => {
2280
+ r.forEach((s) => s.dispose()), r.length = 0;
2217
2281
  })
2218
2282
  )
2219
2283
  ), this.disposeWithMe(
2220
- toDisposable(
2221
- transformer.changeStart$.subscribe(() => {
2222
- disposePopups.forEach((dispose) => dispose.dispose()), disposePopups.length = 0;
2284
+ Ee(
2285
+ t.changeStart$.subscribe(() => {
2286
+ r.forEach((s) => s.dispose()), r.length = 0;
2223
2287
  })
2224
2288
  )
2225
2289
  );
2226
2290
  }
2227
- _getImageMenuItems(unitId, subUnitId, drawingId) {
2291
+ _getImageMenuItems(e, n, t) {
2228
2292
  return [
2229
2293
  {
2230
2294
  label: "image-popup.edit",
2231
2295
  index: 0,
2232
- commandId: EditDocDrawingOperation.id,
2233
- commandParams: { unitId, subUnitId, drawingId },
2296
+ commandId: gt.id,
2297
+ commandParams: { unitId: e, subUnitId: n, drawingId: t },
2234
2298
  disable: !1
2235
2299
  },
2236
2300
  {
2237
2301
  label: "image-popup.delete",
2238
2302
  index: 1,
2239
- commandId: RemoveDocDrawingCommand.id,
2240
- commandParams: { unitId, drawings: [{ unitId, subUnitId, drawingId }] },
2303
+ commandId: Sn.id,
2304
+ commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: n, drawingId: t }] },
2241
2305
  disable: !1
2242
2306
  },
2243
2307
  {
2244
2308
  label: "image-popup.crop",
2245
2309
  index: 2,
2246
- commandId: OpenImageCropOperation.id,
2247
- commandParams: { unitId, subUnitId, drawingId },
2310
+ commandId: Kt.id,
2311
+ commandParams: { unitId: e, subUnitId: n, drawingId: t },
2248
2312
  disable: !0
2249
2313
  // TODO: @JOCS, feature is not ready.
2250
2314
  },
2251
2315
  {
2252
2316
  label: "image-popup.reset",
2253
2317
  index: 3,
2254
- commandId: ImageResetSizeOperation.id,
2255
- commandParams: [{ unitId, subUnitId, drawingId }],
2318
+ commandId: Yt.id,
2319
+ commandParams: [{ unitId: e, subUnitId: n, drawingId: t }],
2256
2320
  disable: !0
2257
2321
  // TODO: @JOCS, feature is not ready.
2258
2322
  }
2259
2323
  ];
2260
2324
  }
2261
- }, __name(_a5, "DocDrawingPopupMenuController"), _a5);
2262
- DocDrawingPopupMenuController = __decorateClass$2([
2263
- __decorateParam$2(0, IDrawingManagerService),
2264
- __decorateParam$2(1, Inject(DocCanvasPopManagerService)),
2265
- __decorateParam$2(2, IRenderManagerService),
2266
- __decorateParam$2(3, IUniverInstanceService),
2267
- __decorateParam$2(4, IContextService)
2268
- ], DocDrawingPopupMenuController);
2269
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2270
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2271
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2272
- return kind && result && __defProp$1(target, key, result), result;
2273
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a6;
2274
- let DocDrawingTransformUpdateController = (_a6 = class extends Disposable {
2275
- constructor(_context, _docSkeletonManagerService, _commandService, _editorService, _drawingManagerService, _docRefreshDrawingsService, _univerInstanceService, _lifecycleService) {
2325
+ };
2326
+ an = br([
2327
+ Ge(0, ve),
2328
+ Ge(1, we(hi)),
2329
+ Ge(2, Q),
2330
+ Ge(3, Z),
2331
+ Ge(4, Wn)
2332
+ ], an);
2333
+ var Mr = Object.defineProperty, Rr = Object.getOwnPropertyDescriptor, Nr = (i, e, n, t) => {
2334
+ for (var r = t > 1 ? void 0 : t ? Rr(e, n) : e, o = i.length - 1, s; o >= 0; o--)
2335
+ (s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
2336
+ return t && r && Mr(e, n, r), r;
2337
+ }, Ae = (i, e) => (n, t) => e(n, t, i);
2338
+ let wn = class extends qe {
2339
+ constructor(e, n, t, r, o, s, a, d) {
2276
2340
  super();
2277
- __publicField(this, "_liquid", new Liquid());
2278
- this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._editorService = _editorService, this._drawingManagerService = _drawingManagerService, this._docRefreshDrawingsService = _docRefreshDrawingsService, this._univerInstanceService = _univerInstanceService, this._lifecycleService = _lifecycleService, this._initialize(), this._commandExecutedListener();
2341
+ Se(this, "_liquid", new Gn());
2342
+ this._context = e, this._docSkeletonManagerService = n, this._commandService = t, this._editorService = r, this._drawingManagerService = o, this._docRefreshDrawingsService = s, this._univerInstanceService = a, this._lifecycleService = d, this._initialize(), this._commandExecutedListener();
2279
2343
  }
2280
2344
  _initialize() {
2281
2345
  this._initialRenderRefresh(), this._drawingInitializeListener(), this._initResize();
2282
2346
  }
2283
2347
  _initialRenderRefresh() {
2284
- this._docSkeletonManagerService.currentSkeleton$.subscribe((documentSkeleton) => {
2285
- documentSkeleton != null && this._refreshDrawing(documentSkeleton);
2286
- }), this._docRefreshDrawingsService.refreshDrawings$.subscribe((skeleton) => {
2287
- skeleton != null && this._refreshDrawing(skeleton);
2348
+ this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
2349
+ e != null && this._refreshDrawing(e);
2350
+ }), this._docRefreshDrawingsService.refreshDrawings$.subscribe((e) => {
2351
+ e != null && this._refreshDrawing(e);
2288
2352
  });
2289
2353
  }
2290
2354
  _commandExecutedListener() {
2291
- const updateCommandList = [RichTextEditingMutation.id, SetDocZoomRatioOperation.id];
2355
+ const e = [J.id, wi.id];
2292
2356
  this.disposeWithMe(
2293
- this._commandService.onCommandExecuted((command) => {
2294
- if (updateCommandList.includes(command.id)) {
2295
- const params = command.params, { unitId: commandUnitId } = params, { unitId, mainComponent } = this._context;
2296
- if (commandUnitId !== unitId)
2357
+ this._commandService.onCommandExecuted((n) => {
2358
+ if (e.includes(n.id)) {
2359
+ const t = n.params, { unitId: r } = t, { unitId: o, mainComponent: s } = this._context;
2360
+ if (r !== o)
2297
2361
  return;
2298
- const skeleton = this._docSkeletonManagerService.getSkeleton();
2299
- if (skeleton == null)
2362
+ const a = this._docSkeletonManagerService.getSkeleton();
2363
+ if (a == null)
2300
2364
  return;
2301
- if (this._editorService.isEditor(unitId)) {
2302
- mainComponent == null || mainComponent.makeDirty();
2365
+ if (this._editorService.isEditor(o)) {
2366
+ s == null || s.makeDirty();
2303
2367
  return;
2304
2368
  }
2305
- this._refreshDrawing(skeleton);
2369
+ this._refreshDrawing(a);
2306
2370
  }
2307
2371
  })
2308
2372
  );
2309
2373
  }
2310
2374
  _initResize() {
2311
2375
  this.disposeWithMe(
2312
- fromEventSubject(this._context.engine.onTransformChange$).pipe(
2313
- filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize),
2314
- debounceTime(16)
2376
+ At(this._context.engine.onTransformChange$).pipe(
2377
+ Bn((e) => e.type === ni.resize),
2378
+ Si(16)
2315
2379
  ).subscribe(() => {
2316
- var _a8;
2317
- const skeleton = this._docSkeletonManagerService.getSkeleton(), { scene } = this._context;
2318
- (_a8 = scene.getTransformer()) == null || _a8.refreshControls(), this._refreshDrawing(skeleton);
2380
+ var t;
2381
+ const e = this._docSkeletonManagerService.getSkeleton(), { scene: n } = this._context;
2382
+ (t = n.getTransformer()) == null || t.refreshControls(), this._refreshDrawing(e);
2319
2383
  })
2320
2384
  );
2321
2385
  }
2322
- _refreshDrawing(skeleton) {
2323
- var _a8, _b;
2324
- const skeletonData = skeleton == null ? void 0 : skeleton.getSkeletonData(), { mainComponent, unitId } = this._context, documentComponent = mainComponent;
2325
- if (!skeletonData)
2386
+ _refreshDrawing(e) {
2387
+ var O, D;
2388
+ const n = e == null ? void 0 : e.getSkeletonData(), { mainComponent: t, unitId: r } = this._context, o = t;
2389
+ if (!n)
2326
2390
  return;
2327
- const { left: docsLeft, top: docsTop, pageLayoutType, pageMarginLeft, pageMarginTop } = documentComponent, { pages, skeHeaders, skeFooters } = skeletonData, updateDrawingMap = {};
2391
+ const { left: s, top: a, pageLayoutType: d, pageMarginLeft: c, pageMarginTop: g } = o, { pages: f, skeHeaders: m, skeFooters: p } = n, h = {};
2328
2392
  this._liquid.reset();
2329
- for (let i = 0, len = pages.length; i < len; i++) {
2330
- const page = pages[i], { headerId, footerId, pageWidth } = page;
2331
- if (headerId) {
2332
- const headerPage = (_a8 = skeHeaders.get(headerId)) == null ? void 0 : _a8.get(pageWidth);
2333
- headerPage && this._calculateDrawingPosition(
2334
- unitId,
2335
- headerPage,
2336
- docsLeft,
2337
- docsTop,
2338
- updateDrawingMap,
2339
- headerPage.marginTop,
2340
- page.marginLeft
2393
+ for (let x = 0, b = f.length; x < b; x++) {
2394
+ const T = f[x], { headerId: N, footerId: B, pageWidth: R } = T;
2395
+ if (N) {
2396
+ const I = (O = m.get(N)) == null ? void 0 : O.get(R);
2397
+ I && this._calculateDrawingPosition(
2398
+ r,
2399
+ I,
2400
+ s,
2401
+ a,
2402
+ h,
2403
+ I.marginTop,
2404
+ T.marginLeft
2341
2405
  );
2342
2406
  }
2343
- if (footerId) {
2344
- const footerPage = (_b = skeFooters.get(footerId)) == null ? void 0 : _b.get(pageWidth);
2345
- footerPage && this._calculateDrawingPosition(
2346
- unitId,
2347
- footerPage,
2348
- docsLeft,
2349
- docsTop,
2350
- updateDrawingMap,
2351
- page.pageHeight - page.marginBottom + footerPage.marginTop,
2352
- page.marginLeft
2407
+ if (B) {
2408
+ const I = (D = p.get(B)) == null ? void 0 : D.get(R);
2409
+ I && this._calculateDrawingPosition(
2410
+ r,
2411
+ I,
2412
+ s,
2413
+ a,
2414
+ h,
2415
+ T.pageHeight - T.marginBottom + I.marginTop,
2416
+ T.marginLeft
2353
2417
  );
2354
2418
  }
2355
- this._calculateDrawingPosition(unitId, page, docsLeft, docsTop, updateDrawingMap, page.marginTop, page.marginLeft), this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
2419
+ this._calculateDrawingPosition(r, T, s, a, h, T.marginTop, T.marginLeft), this._liquid.translatePage(T, d, c, g);
2356
2420
  }
2357
- const updateDrawings = Object.values(updateDrawingMap), nonMultiDrawings = updateDrawings.filter((drawing) => !drawing.isMultiTransform), multiDrawings = updateDrawings.filter((drawing) => drawing.isMultiTransform);
2358
- nonMultiDrawings.length > 0 && this._drawingManagerService.refreshTransform(nonMultiDrawings), this._handleMultiDrawingsTransform(multiDrawings);
2359
- }
2360
- _handleMultiDrawingsTransform(multiDrawings) {
2361
- const { scene, unitId } = this._context, transformer = scene.getTransformerByCreate();
2362
- multiDrawings.forEach((updateParam) => {
2363
- const param = this._drawingManagerService.getDrawingByParam(updateParam);
2364
- param != null && (param.transform = updateParam.transform, param.transforms = updateParam.transforms, param.isMultiTransform = updateParam.isMultiTransform);
2421
+ const v = Object.values(h), w = v.filter((x) => !x.isMultiTransform), S = v.filter((x) => x.isMultiTransform);
2422
+ w.length > 0 && this._drawingManagerService.refreshTransform(w), this._handleMultiDrawingsTransform(S);
2423
+ }
2424
+ _handleMultiDrawingsTransform(e) {
2425
+ const { scene: n, unitId: t } = this._context, r = n.getTransformerByCreate();
2426
+ e.forEach((d) => {
2427
+ const c = this._drawingManagerService.getDrawingByParam(d);
2428
+ c != null && (c.transform = d.transform, c.transforms = d.transforms, c.isMultiTransform = d.isMultiTransform);
2365
2429
  });
2366
- const selectedObjectKeys = [...transformer.getSelectedObjectMap().keys()], allMultiDrawings = Object.values(this._drawingManagerService.getDrawingData(unitId, unitId)).filter((drawing) => drawing.isMultiTransform === BooleanNumber.TRUE);
2367
- this._drawingManagerService.removeNotification(allMultiDrawings), multiDrawings.length > 0 && this._drawingManagerService.addNotification(multiDrawings);
2368
- for (const key of selectedObjectKeys) {
2369
- const drawingShape = scene.getObject(key);
2370
- drawingShape && transformer.setSelectedControl(drawingShape);
2430
+ const s = [...r.getSelectedObjectMap().keys()], a = Object.values(this._drawingManagerService.getDrawingData(t, t)).filter((d) => d.isMultiTransform === re.TRUE);
2431
+ this._drawingManagerService.removeNotification(a), e.length > 0 && this._drawingManagerService.addNotification(e);
2432
+ for (const d of s) {
2433
+ const c = n.getObject(d);
2434
+ c && r.setSelectedControl(c);
2371
2435
  }
2372
2436
  }
2373
- _calculateDrawingPosition(unitId, page, docsLeft, docsTop, updateDrawingMap, marginTop, marginLeft) {
2374
- const { skeDrawings } = page;
2437
+ _calculateDrawingPosition(e, n, t, r, o, s, a) {
2438
+ const { skeDrawings: d } = n;
2375
2439
  this._liquid.translatePagePadding({
2376
- marginTop,
2377
- marginLeft
2378
- }), skeDrawings.forEach((drawing) => {
2379
- const { aLeft, aTop, height, width, angle, drawingId, drawingOrigin } = drawing, behindText = drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_NONE && drawingOrigin.behindDoc === BooleanNumber.TRUE, { isMultiTransform = BooleanNumber.FALSE } = drawingOrigin, transform = {
2380
- left: aLeft + docsLeft + this._liquid.x,
2381
- top: aTop + docsTop + this._liquid.y,
2382
- width,
2383
- height,
2384
- angle
2440
+ marginTop: s,
2441
+ marginLeft: a
2442
+ }), d.forEach((c) => {
2443
+ const { aLeft: g, aTop: f, height: m, width: p, angle: h, drawingId: v, drawingOrigin: w } = c, S = w.layoutType === k.WRAP_NONE && w.behindDoc === re.TRUE, { isMultiTransform: O = re.FALSE } = w, D = {
2444
+ left: g + t + this._liquid.x,
2445
+ top: f + r + this._liquid.y,
2446
+ width: p,
2447
+ height: m,
2448
+ angle: h
2385
2449
  };
2386
- updateDrawingMap[drawingId] == null ? updateDrawingMap[drawingId] = {
2387
- unitId,
2388
- subUnitId: unitId,
2389
- drawingId,
2390
- behindText,
2391
- transform,
2392
- transforms: [transform],
2393
- isMultiTransform
2394
- } : isMultiTransform === BooleanNumber.TRUE && updateDrawingMap[drawingId].transforms.push(transform);
2450
+ o[v] == null ? o[v] = {
2451
+ unitId: e,
2452
+ subUnitId: e,
2453
+ drawingId: v,
2454
+ behindText: S,
2455
+ transform: D,
2456
+ transforms: [D],
2457
+ isMultiTransform: O
2458
+ } : O === re.TRUE && o[v].transforms.push(D);
2395
2459
  }), this._liquid.restorePagePadding({
2396
- marginTop,
2397
- marginLeft
2460
+ marginTop: s,
2461
+ marginLeft: a
2398
2462
  });
2399
2463
  }
2400
2464
  _drawingInitializeListener() {
2401
- const init = /* @__PURE__ */ __name(() => {
2402
- const skeleton = this._docSkeletonManagerService.getSkeleton();
2403
- skeleton != null && (this._refreshDrawing(skeleton), this._drawingManagerService.initializeNotification(this._context.unitId));
2404
- }, "init");
2405
- this._lifecycleService.stage === LifecycleStages.Steady ? setTimeout(() => {
2406
- init();
2407
- }, 1e3) : this._lifecycleService.lifecycle$.pipe(filter((stage) => stage === LifecycleStages.Steady)).subscribe(init);
2408
- }
2409
- }, __name(_a6, "DocDrawingTransformUpdateController"), _a6);
2410
- DocDrawingTransformUpdateController = __decorateClass$1([
2411
- __decorateParam$1(1, Inject(DocSkeletonManagerService)),
2412
- __decorateParam$1(2, ICommandService),
2413
- __decorateParam$1(3, IEditorService),
2414
- __decorateParam$1(4, IDrawingManagerService),
2415
- __decorateParam$1(5, Inject(DocRefreshDrawingsService)),
2416
- __decorateParam$1(6, IUniverInstanceService),
2417
- __decorateParam$1(7, Inject(LifecycleService))
2418
- ], DocDrawingTransformUpdateController);
2419
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2420
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2421
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2422
- return kind && result && __defProp2(target, key, result), result;
2423
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
2424
- const PLUGIN_NAME = "DOC_DRAWING_UI_PLUGIN";
2425
- var _a7;
2426
- let UniverDocsDrawingUIPlugin = (_a7 = class extends Plugin {
2427
- constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
2428
- super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._configService = _configService;
2429
- const { ...rest } = this._config;
2430
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
2465
+ const e = () => {
2466
+ const n = this._docSkeletonManagerService.getSkeleton();
2467
+ n != null && (this._refreshDrawing(n), this._drawingManagerService.initializeNotification(this._context.unitId));
2468
+ };
2469
+ this._lifecycleService.stage === xn.Steady ? setTimeout(() => {
2470
+ e();
2471
+ }, 1e3) : this._lifecycleService.lifecycle$.pipe(Bn((n) => n === xn.Steady)).subscribe(e);
2472
+ }
2473
+ };
2474
+ wn = Nr([
2475
+ Ae(1, we(oe)),
2476
+ Ae(2, z),
2477
+ Ae(3, pi),
2478
+ Ae(4, ve),
2479
+ Ae(5, we(ln)),
2480
+ Ae(6, Z),
2481
+ Ae(7, we(Nt))
2482
+ ], wn);
2483
+ var vt = Object.defineProperty, Ar = Object.getOwnPropertyDescriptor, Er = (i, e, n) => e in i ? vt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, jr = (i, e, n, t) => {
2484
+ for (var r = t > 1 ? void 0 : t ? Ar(e, n) : e, o = i.length - 1, s; o >= 0; o--)
2485
+ (s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
2486
+ return t && r && vt(e, n, r), r;
2487
+ }, pn = (i, e) => (n, t) => e(n, t, i), It = (i, e, n) => Er(i, typeof e != "symbol" ? e + "" : e, n);
2488
+ const Lr = "DOC_DRAWING_UI_PLUGIN";
2489
+ let cn = class extends Lt {
2490
+ constructor(i = xi, e, n, t) {
2491
+ super(), this._config = i, this._injector = e, this._renderManagerSrv = n, this._configService = t;
2492
+ const { ...r } = this._config;
2493
+ this._configService.setConfig(Oi, r);
2431
2494
  }
2432
2495
  onStarting() {
2433
2496
  [
2434
- [DocDrawingUIController],
2435
- [DocDrawingPopupMenuController],
2436
- [DocDrawingTransformerController],
2437
- [DocDrawingAddRemoveController],
2438
- [DocRefreshDrawingsService]
2439
- ].forEach((dependency) => this._injector.add(dependency));
2497
+ [rn],
2498
+ [an],
2499
+ [sn],
2500
+ [on],
2501
+ [ln]
2502
+ ].forEach((e) => this._injector.add(e));
2440
2503
  }
2441
2504
  onReady() {
2442
2505
  [
2443
- [DocDrawingUpdateRenderController],
2444
- [DocDrawingTransformUpdateController]
2445
- ].forEach((m) => this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m)), this._injector.get(DocDrawingAddRemoveController), this._injector.get(DocDrawingUIController), this._injector.get(DocDrawingTransformerController);
2506
+ [tn],
2507
+ [wn]
2508
+ ].forEach((i) => this._renderManagerSrv.registerRenderModule(Te.UNIVER_DOC, i)), this._injector.get(on), this._injector.get(rn), this._injector.get(sn);
2446
2509
  }
2447
2510
  onRendered() {
2448
- this._injector.get(DocDrawingPopupMenuController);
2449
- }
2450
- }, __name(_a7, "UniverDocsDrawingUIPlugin"), _a7);
2451
- __publicField2(UniverDocsDrawingUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
2452
- __publicField2(UniverDocsDrawingUIPlugin, "pluginName", PLUGIN_NAME);
2453
- UniverDocsDrawingUIPlugin = __decorateClass([
2454
- DependentOn(UniverDrawingUIPlugin, UniverDrawingPlugin, UniverDocsDrawingPlugin, UniverUIPlugin),
2455
- __decorateParam(1, Inject(Injector)),
2456
- __decorateParam(2, IRenderManagerService),
2457
- __decorateParam(3, IConfigService)
2458
- ], UniverDocsDrawingUIPlugin);
2511
+ this._injector.get(an);
2512
+ }
2513
+ };
2514
+ It(cn, "type", Te.UNIVER_DOC);
2515
+ It(cn, "pluginName", Lr);
2516
+ cn = jr([
2517
+ Et(Zt, $t, Ut, di),
2518
+ pn(1, we(jt)),
2519
+ pn(2, Q),
2520
+ pn(3, Bt)
2521
+ ], cn);
2459
2522
  export {
2460
- ClearDocDrawingTransformerOperation,
2461
- DeleteDocDrawingsCommand,
2462
- EditDocDrawingOperation,
2463
- GroupDocDrawingCommand,
2464
- IMAGE_MENU_ID,
2465
- InsertDocDrawingCommand,
2466
- InsertDocImageCommand,
2467
- MoveDocDrawingsCommand,
2468
- RemoveDocDrawingCommand,
2469
- SetDocDrawingArrangeCommand,
2470
- SidebarDocDrawingOperation,
2471
- UngroupDocDrawingCommand,
2472
- UniverDocsDrawingUIPlugin
2523
+ ji as ClearDocDrawingTransformerOperation,
2524
+ Zn as DeleteDocDrawingsCommand,
2525
+ gt as EditDocDrawingOperation,
2526
+ Jn as GroupDocDrawingCommand,
2527
+ pt as IMAGE_MENU_ID,
2528
+ Qn as InsertDocDrawingCommand,
2529
+ tt as InsertDocImageCommand,
2530
+ Xe as MoveDocDrawingsCommand,
2531
+ Sn as RemoveDocDrawingCommand,
2532
+ et as SetDocDrawingArrangeCommand,
2533
+ lt as SidebarDocDrawingOperation,
2534
+ nt as UngroupDocDrawingCommand,
2535
+ cn as UniverDocsDrawingUIPlugin
2473
2536
  };