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