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