@univerjs/docs-drawing-ui 1.0.0-beta.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +187 -72
- package/lib/cjs/locale/ar-SA.js +0 -3
- package/lib/cjs/locale/ca-ES.js +0 -3
- package/lib/cjs/locale/de-DE.js +0 -3
- package/lib/cjs/locale/en-US.js +0 -3
- package/lib/cjs/locale/es-ES.js +0 -3
- package/lib/cjs/locale/fa-IR.js +0 -3
- package/lib/cjs/locale/fr-FR.js +0 -3
- package/lib/cjs/locale/id-ID.js +0 -3
- package/lib/cjs/locale/it-IT.js +0 -3
- package/lib/cjs/locale/ja-JP.js +0 -3
- package/lib/cjs/locale/ko-KR.js +0 -3
- package/lib/cjs/locale/pl-PL.js +0 -3
- package/lib/cjs/locale/pt-BR.js +0 -3
- package/lib/cjs/locale/ru-RU.js +0 -3
- package/lib/cjs/locale/sk-SK.js +0 -3
- package/lib/cjs/locale/vi-VN.js +0 -3
- package/lib/cjs/locale/zh-CN.js +0 -3
- package/lib/cjs/locale/zh-HK.js +0 -3
- package/lib/cjs/locale/zh-TW.js +0 -3
- package/lib/es/index.js +187 -72
- package/lib/es/locale/ar-SA.js +0 -3
- package/lib/es/locale/ca-ES.js +0 -3
- package/lib/es/locale/de-DE.js +0 -3
- package/lib/es/locale/en-US.js +0 -3
- package/lib/es/locale/es-ES.js +0 -3
- package/lib/es/locale/fa-IR.js +0 -3
- package/lib/es/locale/fr-FR.js +0 -3
- package/lib/es/locale/id-ID.js +0 -3
- package/lib/es/locale/it-IT.js +0 -3
- package/lib/es/locale/ja-JP.js +0 -3
- package/lib/es/locale/ko-KR.js +0 -3
- package/lib/es/locale/pl-PL.js +0 -3
- package/lib/es/locale/pt-BR.js +0 -3
- package/lib/es/locale/ru-RU.js +0 -3
- package/lib/es/locale/sk-SK.js +0 -3
- package/lib/es/locale/vi-VN.js +0 -3
- package/lib/es/locale/zh-CN.js +0 -3
- package/lib/es/locale/zh-HK.js +0 -3
- package/lib/es/locale/zh-TW.js +0 -3
- package/lib/index.js +187 -72
- package/lib/locale/ar-SA.js +0 -3
- package/lib/locale/ca-ES.js +0 -3
- package/lib/locale/de-DE.js +0 -3
- package/lib/locale/en-US.js +0 -3
- package/lib/locale/es-ES.js +0 -3
- package/lib/locale/fa-IR.js +0 -3
- package/lib/locale/fr-FR.js +0 -3
- package/lib/locale/id-ID.js +0 -3
- package/lib/locale/it-IT.js +0 -3
- package/lib/locale/ja-JP.js +0 -3
- package/lib/locale/ko-KR.js +0 -3
- package/lib/locale/pl-PL.js +0 -3
- package/lib/locale/pt-BR.js +0 -3
- package/lib/locale/ru-RU.js +0 -3
- package/lib/locale/sk-SK.js +0 -3
- package/lib/locale/vi-VN.js +0 -3
- package/lib/locale/zh-CN.js +0 -3
- package/lib/locale/zh-HK.js +0 -3
- package/lib/locale/zh-TW.js +0 -3
- package/lib/types/controllers/render-controllers/doc-drawing-transform-update.controller.d.ts +3 -0
- package/lib/types/controllers/render-controllers/doc-drawing-update.render-controller.d.ts +4 -0
- package/lib/types/locale/en-US.d.ts +0 -3
- package/lib/types/menu/drawing-popup-menu.controller.d.ts +3 -0
- package/lib/types/services/doc-drawing-floating-toolbar-adapter.service.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +11 -11
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -10,7 +10,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
10
10
|
} },
|
|
11
11
|
panel: { title: "Редактировать изображение" },
|
|
12
12
|
"image-popup": {
|
|
13
|
-
replace: "Заменить",
|
|
14
13
|
delete: "Удалить",
|
|
15
14
|
edit: "Редактировать",
|
|
16
15
|
crop: "Обрезать",
|
|
@@ -39,9 +38,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
39
38
|
horizontal: "По горизонтали",
|
|
40
39
|
vertical: "По вертикали",
|
|
41
40
|
absolutePosition: "Абсолютное положение (px)",
|
|
42
|
-
relativePosition: "Относительное положение",
|
|
43
41
|
toTheRightOf: "справа от",
|
|
44
|
-
relativeTo: "относительно",
|
|
45
42
|
bellow: "снизу",
|
|
46
43
|
options: "Параметры",
|
|
47
44
|
moveObjectWithText: "Перемещать объект с текстом",
|
package/lib/cjs/locale/sk-SK.js
CHANGED
|
@@ -10,7 +10,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
10
10
|
} },
|
|
11
11
|
panel: { title: "Upraviť obrázok" },
|
|
12
12
|
"image-popup": {
|
|
13
|
-
replace: "Nahradiť",
|
|
14
13
|
delete: "Odstrániť",
|
|
15
14
|
edit: "Upraviť",
|
|
16
15
|
crop: "Orezať",
|
|
@@ -39,9 +38,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
39
38
|
horizontal: "Vodorovne",
|
|
40
39
|
vertical: "Zvisle",
|
|
41
40
|
absolutePosition: "Absolútna pozícia (px)",
|
|
42
|
-
relativePosition: "Relatívna pozícia",
|
|
43
41
|
toTheRightOf: "vpravo od",
|
|
44
|
-
relativeTo: "vzhľadom na",
|
|
45
42
|
bellow: "pod",
|
|
46
43
|
options: "Možnosti",
|
|
47
44
|
moveObjectWithText: "Presunúť objekt s textom",
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -10,7 +10,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
10
10
|
} },
|
|
11
11
|
panel: { title: "Chỉnh sửa hình ảnh" },
|
|
12
12
|
"image-popup": {
|
|
13
|
-
replace: "Thay thế",
|
|
14
13
|
delete: "Xóa",
|
|
15
14
|
edit: "Chỉnh sửa",
|
|
16
15
|
crop: "Cắt",
|
|
@@ -39,9 +38,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
39
38
|
horizontal: "Ngang",
|
|
40
39
|
vertical: "Dọc",
|
|
41
40
|
absolutePosition: "Vị trí tuyệt đối (px)",
|
|
42
|
-
relativePosition: "Vị trí tương đối",
|
|
43
41
|
toTheRightOf: "ở bên phải",
|
|
44
|
-
relativeTo: "tương đối với",
|
|
45
42
|
bellow: "bên dưới",
|
|
46
43
|
options: "Tùy chọn",
|
|
47
44
|
moveObjectWithText: "Di chuyển đối tượng cùng văn bản",
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -10,7 +10,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
10
10
|
} },
|
|
11
11
|
panel: { title: "编辑图片" },
|
|
12
12
|
"image-popup": {
|
|
13
|
-
replace: "替换",
|
|
14
13
|
delete: "删除",
|
|
15
14
|
edit: "编辑",
|
|
16
15
|
crop: "裁剪",
|
|
@@ -39,9 +38,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
39
38
|
horizontal: "水平",
|
|
40
39
|
vertical: "垂直",
|
|
41
40
|
absolutePosition: "绝对位置(px)",
|
|
42
|
-
relativePosition: "相对位置",
|
|
43
41
|
toTheRightOf: "右侧",
|
|
44
|
-
relativeTo: "相对于",
|
|
45
42
|
bellow: "下方",
|
|
46
43
|
options: "选项",
|
|
47
44
|
moveObjectWithText: "对象随文字移动",
|
package/lib/cjs/locale/zh-HK.js
CHANGED
|
@@ -10,7 +10,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
10
10
|
} },
|
|
11
11
|
panel: { title: "編圖" },
|
|
12
12
|
"image-popup": {
|
|
13
|
-
replace: "替換",
|
|
14
13
|
delete: "刪除",
|
|
15
14
|
edit: "編輯",
|
|
16
15
|
crop: "裁切",
|
|
@@ -39,9 +38,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
39
38
|
horizontal: "水平",
|
|
40
39
|
vertical: "垂直",
|
|
41
40
|
absolutePosition: "絕對位置(px)",
|
|
42
|
-
relativePosition: "相對位置",
|
|
43
41
|
toTheRightOf: "右側",
|
|
44
|
-
relativeTo: "相對於",
|
|
45
42
|
bellow: "下方",
|
|
46
43
|
options: "選項",
|
|
47
44
|
moveObjectWithText: "物件隨文字移動",
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -10,7 +10,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
10
10
|
} },
|
|
11
11
|
panel: { title: "編圖" },
|
|
12
12
|
"image-popup": {
|
|
13
|
-
replace: "替換",
|
|
14
13
|
delete: "刪除",
|
|
15
14
|
edit: "編輯",
|
|
16
15
|
crop: "裁切",
|
|
@@ -39,9 +38,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
39
38
|
horizontal: "水平",
|
|
40
39
|
vertical: "垂直",
|
|
41
40
|
absolutePosition: "絕對位置(px)",
|
|
42
|
-
relativePosition: "相對位置",
|
|
43
41
|
toTheRightOf: "右側",
|
|
44
|
-
relativeTo: "相對於",
|
|
45
42
|
bellow: "下方",
|
|
46
43
|
options: "選項",
|
|
47
44
|
moveObjectWithText: "物件隨文字移動",
|
package/lib/es/index.js
CHANGED
|
@@ -162,6 +162,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
162
162
|
this._docRefreshDrawingsService = _docRefreshDrawingsService;
|
|
163
163
|
this._fileOpenerService = _fileOpenerService;
|
|
164
164
|
this._updateOrderListener();
|
|
165
|
+
this._updateImageCropListener();
|
|
165
166
|
this._groupDrawingListener();
|
|
166
167
|
this._focusDrawingListener();
|
|
167
168
|
this._transformDrawingListener();
|
|
@@ -173,10 +174,12 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
173
174
|
}
|
|
174
175
|
async insertDocImage() {
|
|
175
176
|
const insertPosition = this._getCurrentImageInsertPosition();
|
|
177
|
+
const textRange = this._getCurrentImageInsertTextRange();
|
|
176
178
|
const files = await this._fileOpenerService.openFile({
|
|
177
179
|
multiple: true,
|
|
178
180
|
accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
|
|
179
181
|
});
|
|
182
|
+
if (this._disposed) return false;
|
|
180
183
|
const fileLength = files.length;
|
|
181
184
|
if (fileLength > DRAWING_IMAGE_COUNT_LIMIT) {
|
|
182
185
|
this._messageService.show({
|
|
@@ -185,10 +188,9 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
185
188
|
});
|
|
186
189
|
return false;
|
|
187
190
|
} else if (fileLength === 0) return false;
|
|
188
|
-
await this._insertFloatImages(files, insertPosition);
|
|
189
|
-
return true;
|
|
191
|
+
return await this._insertFloatImages(files, insertPosition, textRange);
|
|
190
192
|
}
|
|
191
|
-
async _insertFloatImages(files, insertPosition) {
|
|
193
|
+
async _insertFloatImages(files, insertPosition, textRange) {
|
|
192
194
|
let imageParams = [];
|
|
193
195
|
try {
|
|
194
196
|
imageParams = await Promise.all(files.map((file) => this._imageIoService.saveImage(file)));
|
|
@@ -212,13 +214,14 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
212
214
|
content
|
|
213
215
|
});
|
|
214
216
|
}
|
|
215
|
-
if (imageParams.length === 0) return;
|
|
217
|
+
if (this._disposed || imageParams.length === 0) return false;
|
|
216
218
|
const { unitId } = this._context;
|
|
217
219
|
const docDrawingParams = [];
|
|
218
220
|
for (const imageParam of imageParams) {
|
|
219
221
|
if (imageParam == null) continue;
|
|
220
222
|
const { imageId, imageSourceType, source, base64Cache } = imageParam;
|
|
221
223
|
const { width, height, image } = await getImageSize(base64Cache || "");
|
|
224
|
+
if (this._disposed) return false;
|
|
222
225
|
this._imageIoService.addImageSourceCache(imageId, imageSourceType, image);
|
|
223
226
|
let scale = 1;
|
|
224
227
|
if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
|
|
@@ -228,7 +231,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
228
231
|
}
|
|
229
232
|
const imagePosition = insertPosition ?? this._getCurrentImageInsertPosition();
|
|
230
233
|
const docTransform = this._getImagePosition(width * scale, height * scale, imagePosition);
|
|
231
|
-
if (docTransform == null) return;
|
|
234
|
+
if (docTransform == null) return false;
|
|
232
235
|
const transform = docDrawingPositionToTransform(docTransform);
|
|
233
236
|
if (transform != null && imagePosition != null) transform.top = imagePosition.top;
|
|
234
237
|
const docDrawingParam = {
|
|
@@ -256,9 +259,10 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
256
259
|
}
|
|
257
260
|
docDrawingParams.push(docDrawingParam);
|
|
258
261
|
}
|
|
259
|
-
this._commandService.executeCommand(InsertDocDrawingCommand.id, {
|
|
262
|
+
return await this._commandService.executeCommand(InsertDocDrawingCommand.id, {
|
|
260
263
|
unitId,
|
|
261
|
-
drawings: docDrawingParams
|
|
264
|
+
drawings: docDrawingParams,
|
|
265
|
+
textRange: textRange ?? void 0
|
|
262
266
|
});
|
|
263
267
|
}
|
|
264
268
|
_isInsertInHeaderFooter() {
|
|
@@ -283,6 +287,9 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
283
287
|
top: position.top
|
|
284
288
|
};
|
|
285
289
|
}
|
|
290
|
+
_getCurrentImageInsertTextRange() {
|
|
291
|
+
return this._docSelectionRenderService.getAllTextRanges().find((range) => range.isActive) ?? this._docSelectionManagerService.getActiveTextRange();
|
|
292
|
+
}
|
|
286
293
|
_updateOrderListener() {
|
|
287
294
|
this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe((params) => {
|
|
288
295
|
const { unitId, subUnitId, drawingIds, arrangeType } = params;
|
|
@@ -294,6 +301,73 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
294
301
|
});
|
|
295
302
|
}));
|
|
296
303
|
}
|
|
304
|
+
_updateImageCropListener() {
|
|
305
|
+
this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe((params) => {
|
|
306
|
+
const drawings = params.flatMap((param) => this._getImageCropUpdates(param));
|
|
307
|
+
if (drawings.length > 0) {
|
|
308
|
+
const { unitId } = this._context;
|
|
309
|
+
this._commandService.executeCommand(UpdateDrawingDocTransformCommand.id, {
|
|
310
|
+
unitId,
|
|
311
|
+
subUnitId: unitId,
|
|
312
|
+
drawings
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
_getImageCropUpdates(param) {
|
|
318
|
+
const { unitId, subUnitId, drawingId, transform } = param;
|
|
319
|
+
if ([unitId, subUnitId].some((id) => id !== this._context.unitId)) return [];
|
|
320
|
+
if (transform == null || !Object.prototype.hasOwnProperty.call(param, "srcRect")) return [];
|
|
321
|
+
const docDrawing = this._getDocDrawing(drawingId);
|
|
322
|
+
const renderDrawing = this._drawingManagerService.getDrawingByParam({
|
|
323
|
+
unitId,
|
|
324
|
+
subUnitId,
|
|
325
|
+
drawingId
|
|
326
|
+
});
|
|
327
|
+
if ((docDrawing === null || docDrawing === void 0 ? void 0 : docDrawing.drawingType) !== DrawingTypeEnum.DRAWING_IMAGE || (renderDrawing === null || renderDrawing === void 0 ? void 0 : renderDrawing.transform) == null) return [];
|
|
328
|
+
const nextTransform = {
|
|
329
|
+
...renderDrawing.transform,
|
|
330
|
+
...transform
|
|
331
|
+
};
|
|
332
|
+
const drawings = [{
|
|
333
|
+
drawingId,
|
|
334
|
+
key: "srcRect",
|
|
335
|
+
value: param.srcRect
|
|
336
|
+
}];
|
|
337
|
+
if (nextTransform.width != null && nextTransform.height != null) drawings.push({
|
|
338
|
+
drawingId,
|
|
339
|
+
key: "size",
|
|
340
|
+
value: {
|
|
341
|
+
width: nextTransform.width,
|
|
342
|
+
height: nextTransform.height
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
if (docDrawing.layoutType === PositionedObjectLayoutType.INLINE || renderDrawing.isMultiTransform === BooleanNumber.TRUE) return drawings;
|
|
346
|
+
const horizontalDelta = (nextTransform.left ?? 0) - (renderDrawing.transform.left ?? 0);
|
|
347
|
+
const verticalDelta = (nextTransform.top ?? 0) - (renderDrawing.transform.top ?? 0);
|
|
348
|
+
const { positionH, positionV } = docDrawing.docTransform;
|
|
349
|
+
if (horizontalDelta !== 0 && positionH.posOffset != null) drawings.push({
|
|
350
|
+
drawingId,
|
|
351
|
+
key: "positionH",
|
|
352
|
+
value: {
|
|
353
|
+
relativeFrom: positionH.relativeFrom,
|
|
354
|
+
posOffset: positionH.posOffset + horizontalDelta
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
if (verticalDelta !== 0 && positionV.posOffset != null) drawings.push({
|
|
358
|
+
drawingId,
|
|
359
|
+
key: "positionV",
|
|
360
|
+
value: {
|
|
361
|
+
relativeFrom: positionV.relativeFrom,
|
|
362
|
+
posOffset: positionV.posOffset + verticalDelta
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
return drawings;
|
|
366
|
+
}
|
|
367
|
+
_getDocDrawing(drawingId) {
|
|
368
|
+
var _this$_context$unit$g;
|
|
369
|
+
return (_this$_context$unit$g = this._context.unit.getDrawings()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g[drawingId];
|
|
370
|
+
}
|
|
297
371
|
_groupDrawingListener() {
|
|
298
372
|
this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe((params) => {
|
|
299
373
|
this._commandService.executeCommand(GroupDocDrawingCommand.id, params);
|
|
@@ -316,7 +390,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
316
390
|
}
|
|
317
391
|
_transformDrawingListener() {
|
|
318
392
|
const res = this._getCurrentSceneAndTransformer();
|
|
319
|
-
if (res && res.transformer) this.disposeWithMe(res.transformer.changeEnd$.pipe(debounceTime(30)).subscribe((
|
|
393
|
+
if (res && res.transformer) this.disposeWithMe(res.transformer.changeEnd$.pipe(debounceTime(30)).subscribe(() => {
|
|
320
394
|
this._docSelectionManagerService.refreshSelection();
|
|
321
395
|
}));
|
|
322
396
|
else throw new Error("transformer is not init");
|
|
@@ -381,13 +455,13 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
381
455
|
scene.detachTransformerFrom(shape);
|
|
382
456
|
try {
|
|
383
457
|
shape.setOpacity(isDocInputFocusing ? .5 : 1);
|
|
384
|
-
} catch
|
|
458
|
+
} catch {}
|
|
385
459
|
if (!isDocInputFocusing) continue;
|
|
386
460
|
if (isEditBody && drawing.isMultiTransform !== BooleanNumber.TRUE || !isEditBody && drawing.isMultiTransform === BooleanNumber.TRUE) {
|
|
387
461
|
if (drawing.allowTransform !== false) scene.attachTransformerTo(shape);
|
|
388
462
|
try {
|
|
389
463
|
shape.setOpacity(1);
|
|
390
|
-
} catch
|
|
464
|
+
} catch {}
|
|
391
465
|
}
|
|
392
466
|
}
|
|
393
467
|
}
|
|
@@ -1033,7 +1107,8 @@ const getDisableWhenSelectionInTableObservable = (accessor) => {
|
|
|
1033
1107
|
function ImageMenuFactory(accessor) {
|
|
1034
1108
|
return {
|
|
1035
1109
|
id: DOCS_IMAGE_MENU_ID,
|
|
1036
|
-
|
|
1110
|
+
commandId: IMAGE_MENU_UPLOAD_FLOAT_ID,
|
|
1111
|
+
type: MenuItemType.BUTTON,
|
|
1037
1112
|
icon: "AddImageIcon",
|
|
1038
1113
|
tooltip: "docs-drawing-ui.title",
|
|
1039
1114
|
disabled$: getDisableWhenSelectionInTableObservable(accessor),
|
|
@@ -1127,11 +1202,7 @@ function InsertEllipseShapeBelowMenuFactory(accessor) {
|
|
|
1127
1202
|
const menuSchema = {
|
|
1128
1203
|
[RibbonInsertGroup.MEDIA]: { [DOCS_IMAGE_MENU_ID]: {
|
|
1129
1204
|
order: 0,
|
|
1130
|
-
menuItemFactory: ImageMenuFactory
|
|
1131
|
-
[IMAGE_MENU_UPLOAD_FLOAT_ID]: {
|
|
1132
|
-
order: 0,
|
|
1133
|
-
menuItemFactory: UploadFloatImageMenuFactory
|
|
1134
|
-
}
|
|
1205
|
+
menuItemFactory: ImageMenuFactory
|
|
1135
1206
|
} },
|
|
1136
1207
|
[ContextMenuPosition.PARAGRAPH]: {
|
|
1137
1208
|
[ContextMenuGroup.LAYOUT]: { [INSERT_BELLOW_MENU_ID]: { [IMAGE_MENU_UPLOAD_FLOAT_ID]: {
|
|
@@ -1194,7 +1265,7 @@ const menuSchema = {
|
|
|
1194
1265
|
//#endregion
|
|
1195
1266
|
//#region package.json
|
|
1196
1267
|
var name = "@univerjs/docs-drawing-ui";
|
|
1197
|
-
var version = "1.0.0-beta.
|
|
1268
|
+
var version = "1.0.0-beta.2";
|
|
1198
1269
|
|
|
1199
1270
|
//#endregion
|
|
1200
1271
|
//#region src/config/config.ts
|
|
@@ -2607,6 +2678,7 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
|
|
|
2607
2678
|
this._univerInstanceService = _univerInstanceService;
|
|
2608
2679
|
this._lifecycleService = _lifecycleService;
|
|
2609
2680
|
_defineProperty(this, "_liquid", new Liquid());
|
|
2681
|
+
_defineProperty(this, "_changesetDrawingRefreshScheduled", false);
|
|
2610
2682
|
this._initialize();
|
|
2611
2683
|
this._commandExecutedListener();
|
|
2612
2684
|
}
|
|
@@ -2627,21 +2699,40 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
|
|
|
2627
2699
|
}
|
|
2628
2700
|
_commandExecutedListener() {
|
|
2629
2701
|
const updateCommandList = [RichTextEditingMutation.id, SetDocZoomRatioOperation.id];
|
|
2630
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
2702
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command, options) => {
|
|
2631
2703
|
if (updateCommandList.includes(command.id)) {
|
|
2632
2704
|
const { unitId: commandUnitId } = command.params;
|
|
2633
|
-
const { unitId
|
|
2705
|
+
const { unitId } = this._context;
|
|
2634
2706
|
if (commandUnitId !== unitId) return;
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
if (this._editorService.isEditor(unitId)) {
|
|
2638
|
-
mainComponent === null || mainComponent === void 0 || mainComponent.makeDirty();
|
|
2707
|
+
if (command.id === RichTextEditingMutation.id && (options === null || options === void 0 ? void 0 : options.fromChangeset)) {
|
|
2708
|
+
this._scheduleChangesetDrawingRefresh();
|
|
2639
2709
|
return;
|
|
2640
2710
|
}
|
|
2641
|
-
this.
|
|
2711
|
+
this._refreshCurrentDrawing();
|
|
2642
2712
|
}
|
|
2643
2713
|
}));
|
|
2644
2714
|
}
|
|
2715
|
+
_scheduleChangesetDrawingRefresh() {
|
|
2716
|
+
if (this._changesetDrawingRefreshScheduled) return;
|
|
2717
|
+
this._changesetDrawingRefreshScheduled = true;
|
|
2718
|
+
queueMicrotask(() => {
|
|
2719
|
+
queueMicrotask(() => {
|
|
2720
|
+
this._changesetDrawingRefreshScheduled = false;
|
|
2721
|
+
if (this._disposed) return;
|
|
2722
|
+
this._refreshCurrentDrawing();
|
|
2723
|
+
});
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
2726
|
+
_refreshCurrentDrawing() {
|
|
2727
|
+
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
2728
|
+
if (skeleton == null) return;
|
|
2729
|
+
const { unitId, mainComponent } = this._context;
|
|
2730
|
+
if (this._editorService.isEditor(unitId)) {
|
|
2731
|
+
mainComponent === null || mainComponent === void 0 || mainComponent.makeDirty();
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
this._refreshDrawing(skeleton);
|
|
2735
|
+
}
|
|
2645
2736
|
_initTransformRefresh() {
|
|
2646
2737
|
this.disposeWithMe(merge$1(fromEventSubject(this._context.engine.onTransformChange$).pipe(filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize)), fromEventSubject(this._context.scene.onTransformChange$).pipe(filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale))).pipe(debounceTime(16)).subscribe(() => {
|
|
2647
2738
|
var _scene$getTransformer;
|
|
@@ -3585,6 +3676,8 @@ let DocDrawingPopupMenuController = class DocDrawingPopupMenuController extends
|
|
|
3585
3676
|
this._floatingToolbarAdapterService = _floatingToolbarAdapterService;
|
|
3586
3677
|
this._commandService = _commandService;
|
|
3587
3678
|
_defineProperty(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
3679
|
+
_defineProperty(this, "_embeddedRenderUnits", /* @__PURE__ */ new Set());
|
|
3680
|
+
_defineProperty(this, "_popupMenuListeners", /* @__PURE__ */ new Map());
|
|
3588
3681
|
_defineProperty(this, "_disposePopups", []);
|
|
3589
3682
|
_defineProperty(this, "_isDrawingPanelOpen", false);
|
|
3590
3683
|
this._init();
|
|
@@ -3606,11 +3699,21 @@ let DocDrawingPopupMenuController = class DocDrawingPopupMenuController extends
|
|
|
3606
3699
|
}));
|
|
3607
3700
|
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((documentDataModel) => this._create(documentDataModel)));
|
|
3608
3701
|
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_DOC).pipe(takeUntil(this.dispose$)).subscribe((documentDataModel) => this._dispose(documentDataModel)));
|
|
3702
|
+
this.disposeWithMe(this._renderManagerService.created$.pipe(takeUntil(this.dispose$)).subscribe((render) => {
|
|
3703
|
+
if (render.type !== UniverInstanceType.UNIVER_DOC || render.isMainScene) return;
|
|
3704
|
+
this._embeddedRenderUnits.add(render.unitId);
|
|
3705
|
+
this._create(this._univerInstanceService.getUnit(render.unitId, UniverInstanceType.UNIVER_DOC));
|
|
3706
|
+
}));
|
|
3707
|
+
this.disposeWithMe(this._renderManagerService.disposed$.pipe(takeUntil(this.dispose$)).subscribe((unitId) => {
|
|
3708
|
+
if (!this._embeddedRenderUnits.delete(unitId)) return;
|
|
3709
|
+
this._disposePopupMenuListener(unitId);
|
|
3710
|
+
}));
|
|
3609
3711
|
this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_DOC).forEach((documentDataModel) => this._create(documentDataModel));
|
|
3610
3712
|
}
|
|
3611
3713
|
_dispose(documentDataModel) {
|
|
3612
3714
|
const unitId = documentDataModel.getUnitId();
|
|
3613
3715
|
this._clearPopups();
|
|
3716
|
+
this._disposePopupMenuListener(unitId);
|
|
3614
3717
|
this._renderManagerService.removeRender(unitId);
|
|
3615
3718
|
}
|
|
3616
3719
|
_clearPopups() {
|
|
@@ -3622,10 +3725,20 @@ let DocDrawingPopupMenuController = class DocDrawingPopupMenuController extends
|
|
|
3622
3725
|
const unitId = documentDataModel.getUnitId();
|
|
3623
3726
|
if (isInternalEditorID(unitId)) return;
|
|
3624
3727
|
if (this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId)) {
|
|
3625
|
-
this._popupMenuListener(unitId);
|
|
3626
|
-
|
|
3728
|
+
const listener = this._popupMenuListener(unitId);
|
|
3729
|
+
if (listener) {
|
|
3730
|
+
this._popupMenuListeners.set(unitId, listener);
|
|
3731
|
+
this._initImagePopupMenu.add(unitId);
|
|
3732
|
+
}
|
|
3627
3733
|
}
|
|
3628
3734
|
}
|
|
3735
|
+
_disposePopupMenuListener(unitId) {
|
|
3736
|
+
var _this$_popupMenuListe;
|
|
3737
|
+
(_this$_popupMenuListe = this._popupMenuListeners.get(unitId)) === null || _this$_popupMenuListe === void 0 || _this$_popupMenuListe.dispose();
|
|
3738
|
+
this._popupMenuListeners.delete(unitId);
|
|
3739
|
+
this._initImagePopupMenu.delete(unitId);
|
|
3740
|
+
this._clearPopups();
|
|
3741
|
+
}
|
|
3629
3742
|
_hasCropObject(scene) {
|
|
3630
3743
|
const objects = scene.getAllObjects();
|
|
3631
3744
|
for (const object of objects) if (object instanceof ImageCropperObject) return true;
|
|
@@ -3638,55 +3751,57 @@ let DocDrawingPopupMenuController = class DocDrawingPopupMenuController extends
|
|
|
3638
3751
|
const transformer = scene.getTransformerByCreate();
|
|
3639
3752
|
if (!transformer) return;
|
|
3640
3753
|
const disposePopups = this._disposePopups;
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3754
|
+
const subscriptions = [
|
|
3755
|
+
transformer.createControl$.subscribe(() => {
|
|
3756
|
+
if (this._hasCropObject(scene)) return;
|
|
3757
|
+
const selectedObjects = transformer.getSelectedObjectMap();
|
|
3758
|
+
disposePopups.forEach((dispose) => dispose.dispose());
|
|
3759
|
+
disposePopups.length = 0;
|
|
3760
|
+
if (this._isDrawingPanelOpen || selectedObjects.size > 1) return;
|
|
3761
|
+
const object = selectedObjects.values().next().value;
|
|
3762
|
+
if (!object) return;
|
|
3763
|
+
const drawingParam = this._drawingManagerService.getDrawingOKey(object.oKey);
|
|
3764
|
+
if (!drawingParam || drawingParam.drawingType === DrawingTypeEnum.DRAWING_DOM || drawingParam.drawingType === DrawingTypeEnum.DRAWING_SHAPE) return;
|
|
3765
|
+
const { unitId, subUnitId, drawingId, drawingType } = drawingParam;
|
|
3766
|
+
const isImage = drawingType === DrawingTypeEnum.DRAWING_IMAGE;
|
|
3767
|
+
const isChart = drawingType === DrawingTypeEnum.DRAWING_CHART;
|
|
3768
|
+
const popup = this._canvasPopManagerService.attachPopupToObject(object, {
|
|
3769
|
+
componentKey: COMPONENT_IMAGE_POPUP_MENU,
|
|
3770
|
+
direction: isImage || isChart ? "top-center" : "horizontal",
|
|
3771
|
+
offset: isImage || isChart ? [0, 8] : [2, 0],
|
|
3772
|
+
extraProps: {
|
|
3773
|
+
menuItems: this._getDrawingPopupMenuItems(unitId, subUnitId, drawingId, drawingType),
|
|
3774
|
+
variant: isImage ? "doc-floating-toolbar" : isChart ? "doc-chart-floating-toolbar" : void 0,
|
|
3775
|
+
unitId,
|
|
3776
|
+
subUnitId,
|
|
3777
|
+
drawingId
|
|
3778
|
+
}
|
|
3779
|
+
}, unitId);
|
|
3780
|
+
disposePopups.push(this.disposeWithMe(popup));
|
|
3781
|
+
if (!this._drawingManagerService.getFocusDrawings().find((drawing) => drawing.unitId === unitId && drawing.subUnitId === subUnitId && drawing.drawingId === drawingId)) this._drawingManagerService.focusDrawing([{
|
|
3663
3782
|
unitId,
|
|
3664
3783
|
subUnitId,
|
|
3665
3784
|
drawingId
|
|
3666
|
-
}
|
|
3667
|
-
},
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
this.disposeWithMe(transformer.changeStart$.subscribe(() => {
|
|
3687
|
-
disposePopups.forEach((dispose) => dispose.dispose());
|
|
3688
|
-
disposePopups.length = 0;
|
|
3689
|
-
}));
|
|
3785
|
+
}]);
|
|
3786
|
+
}),
|
|
3787
|
+
transformer.clearControl$.subscribe(() => {
|
|
3788
|
+
disposePopups.forEach((dispose) => dispose.dispose());
|
|
3789
|
+
disposePopups.length = 0;
|
|
3790
|
+
this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, false);
|
|
3791
|
+
this._drawingManagerService.focusDrawing(null);
|
|
3792
|
+
}),
|
|
3793
|
+
transformer.changing$.subscribe(() => {
|
|
3794
|
+
disposePopups.forEach((dispose) => dispose.dispose());
|
|
3795
|
+
disposePopups.length = 0;
|
|
3796
|
+
}),
|
|
3797
|
+
transformer.changeStart$.subscribe(() => {
|
|
3798
|
+
disposePopups.forEach((dispose) => dispose.dispose());
|
|
3799
|
+
disposePopups.length = 0;
|
|
3800
|
+
})
|
|
3801
|
+
];
|
|
3802
|
+
const disposable = toDisposable(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
|
|
3803
|
+
this.disposeWithMe(disposable);
|
|
3804
|
+
return disposable;
|
|
3690
3805
|
}
|
|
3691
3806
|
_getDrawingPopupMenuItems(unitId, subUnitId, drawingId, drawingType) {
|
|
3692
3807
|
const drawing = this._drawingManagerService.getDrawingByParam({
|
package/lib/es/locale/ar-SA.js
CHANGED
|
@@ -9,7 +9,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
9
9
|
} },
|
|
10
10
|
panel: { title: "تحرير الصورة" },
|
|
11
11
|
"image-popup": {
|
|
12
|
-
replace: "استبدال",
|
|
13
12
|
delete: "حذف",
|
|
14
13
|
edit: "تحرير",
|
|
15
14
|
crop: "قص",
|
|
@@ -38,9 +37,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
38
37
|
horizontal: "أفقي",
|
|
39
38
|
vertical: "عمودي",
|
|
40
39
|
absolutePosition: "موضع مطلق(بكسل)",
|
|
41
|
-
relativePosition: "موضع نسبي",
|
|
42
40
|
toTheRightOf: "إلى يمين",
|
|
43
|
-
relativeTo: "بالنسبة إلى",
|
|
44
41
|
bellow: "أسفل",
|
|
45
42
|
options: "خيارات",
|
|
46
43
|
moveObjectWithText: "نقل الكائن مع النص",
|
package/lib/es/locale/ca-ES.js
CHANGED
|
@@ -9,7 +9,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
9
9
|
} },
|
|
10
10
|
panel: { title: "Edita la imatge" },
|
|
11
11
|
"image-popup": {
|
|
12
|
-
replace: "Reemplaça",
|
|
13
12
|
delete: "Elimina",
|
|
14
13
|
edit: "Edita",
|
|
15
14
|
crop: "Retalla",
|
|
@@ -38,9 +37,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
38
37
|
horizontal: "Horitzontal",
|
|
39
38
|
vertical: "Vertical",
|
|
40
39
|
absolutePosition: "Posició absoluta(px)",
|
|
41
|
-
relativePosition: "Posició relativa",
|
|
42
40
|
toTheRightOf: "a la dreta de",
|
|
43
|
-
relativeTo: "relatiu a",
|
|
44
41
|
bellow: "a sota",
|
|
45
42
|
options: "Opcions",
|
|
46
43
|
moveObjectWithText: "Mou l'objecte amb el text",
|
package/lib/es/locale/de-DE.js
CHANGED
|
@@ -9,7 +9,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
9
9
|
} },
|
|
10
10
|
panel: { title: "Bild bearbeiten" },
|
|
11
11
|
"image-popup": {
|
|
12
|
-
replace: "Ersetzen",
|
|
13
12
|
delete: "Löschen",
|
|
14
13
|
edit: "Bearbeiten",
|
|
15
14
|
crop: "Zuschneiden",
|
|
@@ -38,9 +37,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
38
37
|
horizontal: "Horizontal",
|
|
39
38
|
vertical: "Vertikal",
|
|
40
39
|
absolutePosition: "Absolute Position(px)",
|
|
41
|
-
relativePosition: "Relative Position",
|
|
42
40
|
toTheRightOf: "rechts von",
|
|
43
|
-
relativeTo: "relativ zu",
|
|
44
41
|
bellow: "unterhalb",
|
|
45
42
|
options: "Optionen",
|
|
46
43
|
moveObjectWithText: "Objekt mit Text verschieben",
|
package/lib/es/locale/en-US.js
CHANGED
|
@@ -24,7 +24,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
24
24
|
} },
|
|
25
25
|
panel: { title: "Edit Image" },
|
|
26
26
|
"image-popup": {
|
|
27
|
-
replace: "Replace",
|
|
28
27
|
delete: "Delete",
|
|
29
28
|
edit: "Edit",
|
|
30
29
|
crop: "Crop",
|
|
@@ -53,9 +52,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
53
52
|
horizontal: "Horizontal",
|
|
54
53
|
vertical: "Vertical",
|
|
55
54
|
absolutePosition: "Absolute Position(px)",
|
|
56
|
-
relativePosition: "Relative Position",
|
|
57
55
|
toTheRightOf: "to the right of",
|
|
58
|
-
relativeTo: "relative to",
|
|
59
56
|
bellow: "bellow",
|
|
60
57
|
options: "Options",
|
|
61
58
|
moveObjectWithText: "Move object with text",
|
package/lib/es/locale/es-ES.js
CHANGED
|
@@ -9,7 +9,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
9
9
|
} },
|
|
10
10
|
panel: { title: "Editar imagen" },
|
|
11
11
|
"image-popup": {
|
|
12
|
-
replace: "Reemplazar",
|
|
13
12
|
delete: "Eliminar",
|
|
14
13
|
edit: "Editar",
|
|
15
14
|
crop: "Recortar",
|
|
@@ -38,9 +37,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
38
37
|
horizontal: "Horizontal",
|
|
39
38
|
vertical: "Vertical",
|
|
40
39
|
absolutePosition: "Posición absoluta(px)",
|
|
41
|
-
relativePosition: "Posición relativa",
|
|
42
40
|
toTheRightOf: "a la derecha de",
|
|
43
|
-
relativeTo: "relativo a",
|
|
44
41
|
bellow: "debajo",
|
|
45
42
|
options: "Opciones",
|
|
46
43
|
moveObjectWithText: "Mover objeto con el texto",
|
package/lib/es/locale/fa-IR.js
CHANGED
|
@@ -9,7 +9,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
9
9
|
} },
|
|
10
10
|
panel: { title: "ویرایش تصویر" },
|
|
11
11
|
"image-popup": {
|
|
12
|
-
replace: "تعویض",
|
|
13
12
|
delete: "حذف",
|
|
14
13
|
edit: "ویرایش",
|
|
15
14
|
crop: "کراپ",
|
|
@@ -38,9 +37,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
38
37
|
horizontal: "افقی",
|
|
39
38
|
vertical: "عمودی",
|
|
40
39
|
absolutePosition: "موقعیت مطلق(px)",
|
|
41
|
-
relativePosition: "موقعیت نسبی",
|
|
42
40
|
toTheRightOf: "سمت راست",
|
|
43
|
-
relativeTo: "نسبت به",
|
|
44
41
|
bellow: "زیر",
|
|
45
42
|
options: "گزینهها",
|
|
46
43
|
moveObjectWithText: "جابهجایی شیء با متن",
|
package/lib/es/locale/fr-FR.js
CHANGED
|
@@ -9,7 +9,6 @@ const locale = { "docs-drawing-ui": {
|
|
|
9
9
|
} },
|
|
10
10
|
panel: { title: "Modifier l'image" },
|
|
11
11
|
"image-popup": {
|
|
12
|
-
replace: "Remplacer",
|
|
13
12
|
delete: "Supprimer",
|
|
14
13
|
edit: "Modifier",
|
|
15
14
|
crop: "Rogner",
|
|
@@ -38,9 +37,7 @@ const locale = { "docs-drawing-ui": {
|
|
|
38
37
|
horizontal: "Horizontal",
|
|
39
38
|
vertical: "Vertical",
|
|
40
39
|
absolutePosition: "Position absolue(px)",
|
|
41
|
-
relativePosition: "Position relative",
|
|
42
40
|
toTheRightOf: "à droite de",
|
|
43
|
-
relativeTo: "par rapport à",
|
|
44
41
|
bellow: "en dessous",
|
|
45
42
|
options: "Options",
|
|
46
43
|
moveObjectWithText: "Déplacer l'objet avec le texte",
|