@univerjs/docs-drawing-ui 1.0.0-alpha.8 → 1.0.0-beta.1
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 +159 -114
- 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 +162 -117
- 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 +162 -117
- 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/doc-drawing-transformer-update.controller.d.ts +8 -1
- package/lib/types/controllers/doc-float-dom.controller.d.ts +1 -1
- package/lib/types/controllers/render-controllers/doc-drawing-transform-update.controller.d.ts +5 -2
- package/lib/types/locale/en-US.d.ts +0 -3
- 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 +12 -12
package/lib/es/index.js
CHANGED
|
@@ -2,11 +2,11 @@ import { AlignTypeH, AlignTypeV, BooleanNumber, COLORS, CommandType, DOC_DRAWING
|
|
|
2
2
|
import { IDocDrawingAdapterService, IDocDrawingService, InsertDocDrawingCommand, RemoveDocDrawingCommand, SetDocDrawingArrangeCommand, TextWrappingStyle, UniverDocsDrawingPlugin, UpdateDocDrawingWrappingStyleCommand, UpdateDrawingDocTransformCommand, getDocDrawingRenderOrder } from "@univerjs/docs-drawing";
|
|
3
3
|
import { CURSOR_TYPE, DocumentEditArea, DocumentSkeletonPageType, IRenderManagerService, Liquid, PageLayoutType, Rect, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, getColor, getCurrentTypeOfRenderer, getDocsTableRenderViewport, getTableIdAndSliceIndex } from "@univerjs/engine-render";
|
|
4
4
|
import { Checkbox, InputNumber, MessageType, Radio, RadioGroup, Select, clsx, render, unmount } from "@univerjs/design";
|
|
5
|
-
import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, UniverDocsPlugin, buildDocTransform, docDrawingPositionToTransform } from "@univerjs/docs";
|
|
5
|
+
import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, UniverDocsPlugin, buildDocTransform, docDrawingPositionToTransform, isSheetLikeDocsCustomBlockChildType } from "@univerjs/docs";
|
|
6
6
|
import { DOC_CONTENT_INSERT_MENU_ID, DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID, DOC_PARAGRAPH_T_INSERT_MENU_ID, DocCanvasPopManagerService, DocPrintInterceptorService, DocSelectionRenderService, EMPTY_PARAGRAPH_MENU_ID, IEditorService, INSERT_BELLOW_MENU_ID, NodePositionConvertToCursor, SetDocZoomRatioOperation, TEXT_RANGE_LAYER_INDEX, UniverDocsUIPlugin, VIEWPORT_KEY, getAnchorBounding, getOneTextSelectionRange, neoGetDocObject } from "@univerjs/docs-ui";
|
|
7
7
|
import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, IDrawingManagerService, UniverDrawingPlugin, getDrawingImageAllowSize, getDrawingShapeKeyByDrawingSearch, getImageSize } from "@univerjs/drawing";
|
|
8
|
-
import { CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonInsertGroup,
|
|
9
|
-
import { BehaviorSubject, Observable, debounceTime, filter, map, of, switchMap, takeUntil } from "rxjs";
|
|
8
|
+
import { CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonInsertGroup, connectInjector, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
9
|
+
import { BehaviorSubject, Observable, debounceTime, filter, map, merge as merge$1, of, switchMap, takeUntil } from "rxjs";
|
|
10
10
|
import { COMPONENT_IMAGE_POPUP_MENU, DrawingCommonPanel, DrawingRenderService, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
|
|
11
11
|
import { useEffect, useMemo, useState } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -226,7 +226,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
226
226
|
const scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
|
|
227
227
|
scale = Math.min(scaleWidth, scaleHeight);
|
|
228
228
|
}
|
|
229
|
-
const imagePosition = insertPosition
|
|
229
|
+
const imagePosition = insertPosition ?? this._getCurrentImageInsertPosition();
|
|
230
230
|
const docTransform = this._getImagePosition(width * scale, height * scale, imagePosition);
|
|
231
231
|
if (docTransform == null) return;
|
|
232
232
|
const transform = docDrawingPositionToTransform(docTransform);
|
|
@@ -269,8 +269,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
269
269
|
return editArea === DocumentEditArea.HEADER || editArea === DocumentEditArea.FOOTER;
|
|
270
270
|
}
|
|
271
271
|
_getImagePosition(imageWidth, imageHeight, insertPosition) {
|
|
272
|
-
|
|
273
|
-
return buildDocTransform(imageWidth, imageHeight, { left: ((_ref = insertPosition !== null && insertPosition !== void 0 ? insertPosition : this._getCurrentImageInsertPosition()) !== null && _ref !== void 0 ? _ref : {
|
|
272
|
+
return buildDocTransform(imageWidth, imageHeight, { left: (insertPosition ?? this._getCurrentImageInsertPosition() ?? {
|
|
274
273
|
left: 0,
|
|
275
274
|
top: 0
|
|
276
275
|
}).left });
|
|
@@ -324,8 +323,7 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
324
323
|
}
|
|
325
324
|
_focusDrawingListener() {
|
|
326
325
|
this.disposeWithMe(this._drawingManagerService.focus$.subscribe((params) => {
|
|
327
|
-
|
|
328
|
-
const { transformer, docsLeft, docsTop } = (_this$_getCurrentScen = this._getCurrentSceneAndTransformer()) !== null && _this$_getCurrentScen !== void 0 ? _this$_getCurrentScen : {};
|
|
326
|
+
const { transformer, docsLeft, docsTop } = this._getCurrentSceneAndTransformer() ?? {};
|
|
329
327
|
if (params == null || params.length === 0) {
|
|
330
328
|
this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, false);
|
|
331
329
|
this._docDrawingService.focusDrawing([]);
|
|
@@ -349,10 +347,9 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
349
347
|
}));
|
|
350
348
|
}
|
|
351
349
|
_findSegmentIdByDrawingId(drawingId) {
|
|
352
|
-
var _body$customBlocks;
|
|
353
350
|
const { unit: DocDataModel } = this._context;
|
|
354
351
|
const { body, headers = {}, footers = {} } = DocDataModel.getSnapshot();
|
|
355
|
-
if (((
|
|
352
|
+
if (((body === null || body === void 0 ? void 0 : body.customBlocks) ?? []).some((b) => b.blockId === drawingId)) return "";
|
|
356
353
|
for (const headerId of Object.keys(headers)) {
|
|
357
354
|
var _headers$headerId$bod;
|
|
358
355
|
if ((_headers$headerId$bod = headers[headerId].body.customBlocks) === null || _headers$headerId$bod === void 0 ? void 0 : _headers$headerId$bod.some((b) => b.blockId === drawingId)) return headerId;
|
|
@@ -426,9 +423,9 @@ let DocDrawingUpdateRenderController = class DocDrawingUpdateRenderController ex
|
|
|
426
423
|
}));
|
|
427
424
|
}
|
|
428
425
|
_setDrawingSelections(params) {
|
|
429
|
-
var _unit$getSnapshot$bod
|
|
426
|
+
var _unit$getSnapshot$bod;
|
|
430
427
|
const { unit } = this._context;
|
|
431
|
-
const customBlocks = (_unit$getSnapshot$bod =
|
|
428
|
+
const customBlocks = ((_unit$getSnapshot$bod = unit.getSnapshot().body) === null || _unit$getSnapshot$bod === void 0 ? void 0 : _unit$getSnapshot$bod.customBlocks) ?? [];
|
|
432
429
|
const ranges = params.map((item) => {
|
|
433
430
|
const id = item.drawingId;
|
|
434
431
|
const block = customBlocks.find((b) => b.blockId === id);
|
|
@@ -462,10 +459,10 @@ const InsertDocImageCommand = {
|
|
|
462
459
|
id: "doc.command.insert-float-image",
|
|
463
460
|
type: CommandType.COMMAND,
|
|
464
461
|
handler: (accessor) => {
|
|
465
|
-
var _getCurrentTypeOfRend
|
|
462
|
+
var _getCurrentTypeOfRend;
|
|
466
463
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
467
464
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
468
|
-
return (_getCurrentTypeOfRend =
|
|
465
|
+
return ((_getCurrentTypeOfRend = getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC, univerInstanceService, renderManagerService)) === null || _getCurrentTypeOfRend === void 0 ? void 0 : _getCurrentTypeOfRend.with(DocDrawingUpdateRenderController).insertDocImage()) ?? false;
|
|
469
466
|
}
|
|
470
467
|
};
|
|
471
468
|
|
|
@@ -542,19 +539,10 @@ const MoveDocDrawingsCommand = {
|
|
|
542
539
|
const { positionH, positionV } = drawingData.docTransform;
|
|
543
540
|
const newPositionH = { ...positionH };
|
|
544
541
|
const newPositionV = { ...positionV };
|
|
545
|
-
if (direction === Direction.UP)
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
var _newPositionV$posOffs2;
|
|
550
|
-
newPositionV.posOffset = ((_newPositionV$posOffs2 = newPositionV.posOffset) !== null && _newPositionV$posOffs2 !== void 0 ? _newPositionV$posOffs2 : 0) + 2;
|
|
551
|
-
} else if (direction === Direction.LEFT) {
|
|
552
|
-
var _newPositionH$posOffs;
|
|
553
|
-
newPositionH.posOffset = ((_newPositionH$posOffs = newPositionH.posOffset) !== null && _newPositionH$posOffs !== void 0 ? _newPositionH$posOffs : 0) - 2;
|
|
554
|
-
} else if (direction === Direction.RIGHT) {
|
|
555
|
-
var _newPositionH$posOffs2;
|
|
556
|
-
newPositionH.posOffset = ((_newPositionH$posOffs2 = newPositionH.posOffset) !== null && _newPositionH$posOffs2 !== void 0 ? _newPositionH$posOffs2 : 0) + 2;
|
|
557
|
-
}
|
|
542
|
+
if (direction === Direction.UP) newPositionV.posOffset = (newPositionV.posOffset ?? 0) - 2;
|
|
543
|
+
else if (direction === Direction.DOWN) newPositionV.posOffset = (newPositionV.posOffset ?? 0) + 2;
|
|
544
|
+
else if (direction === Direction.LEFT) newPositionH.posOffset = (newPositionH.posOffset ?? 0) - 2;
|
|
545
|
+
else if (direction === Direction.RIGHT) newPositionH.posOffset = (newPositionH.posOffset ?? 0) + 2;
|
|
558
546
|
return {
|
|
559
547
|
drawingId,
|
|
560
548
|
key: direction === Direction.UP || direction === Direction.DOWN ? "positionV" : "positionH",
|
|
@@ -669,7 +657,7 @@ function calcDocFloatDomPositionByRect(rect, scene, opacity = 1, angle = 0) {
|
|
|
669
657
|
left: false,
|
|
670
658
|
top: false
|
|
671
659
|
},
|
|
672
|
-
opacity: opacity
|
|
660
|
+
opacity: opacity ?? 1
|
|
673
661
|
};
|
|
674
662
|
}
|
|
675
663
|
function calcDocFloatDomPosition(object, renderUnit) {
|
|
@@ -696,6 +684,9 @@ function pickValidCustomBlockRenderViewport(viewport) {
|
|
|
696
684
|
if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.contentHeight)) result.contentHeight = viewport.contentHeight;
|
|
697
685
|
if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.contentWidth)) result.contentWidth = viewport.contentWidth;
|
|
698
686
|
if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.height)) result.height = viewport.height;
|
|
687
|
+
if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.pageContentWidth)) result.pageContentWidth = viewport.pageContentWidth;
|
|
688
|
+
const viewScale = viewport === null || viewport === void 0 ? void 0 : viewport.viewScale;
|
|
689
|
+
if (isPositiveNumber(viewScale)) result.viewScale = viewScale;
|
|
699
690
|
if (isPositiveNumber(viewport === null || viewport === void 0 ? void 0 : viewport.viewportHeight)) result.viewportHeight = viewport.viewportHeight;
|
|
700
691
|
return Object.keys(result).length ? result : void 0;
|
|
701
692
|
}
|
|
@@ -782,6 +773,10 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
|
|
|
782
773
|
position$,
|
|
783
774
|
id: rectParam.drawingId,
|
|
784
775
|
componentKey: rectParam.componentKey,
|
|
776
|
+
contentBox: isSheetLikeEmbedFloatDomRuntimeParam(runtimeParam) ? {
|
|
777
|
+
contentInset: 0,
|
|
778
|
+
wrapperInset: 0
|
|
779
|
+
} : void 0,
|
|
785
780
|
eventPassThrough: preserveRuntimeGeometry ? false : void 0,
|
|
786
781
|
preserveOnFocusChange: preserveRuntimeGeometry,
|
|
787
782
|
onPointerDown: (evt) => {
|
|
@@ -819,7 +814,7 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
|
|
|
819
814
|
params.forEach((param) => {
|
|
820
815
|
var _this$_canvasFloatDom;
|
|
821
816
|
const floatDomInfo = this._domLayerInfoMap.get(param.drawingId);
|
|
822
|
-
if (!floatDomInfo) return;
|
|
817
|
+
if (!floatDomInfo || floatDomInfo.unitId !== param.unitId) return;
|
|
823
818
|
const runtimeParam = param;
|
|
824
819
|
const runtimeViewport = pickValidCustomBlockRenderViewport(runtimeParam.customBlockRenderViewport);
|
|
825
820
|
if (runtimeViewport) floatDomInfo.runtimeViewport = runtimeViewport;
|
|
@@ -876,12 +871,14 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
|
|
|
876
871
|
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
877
872
|
if (commandInfo.id === SetDocZoomRatioOperation.id) {
|
|
878
873
|
const { unitId } = commandInfo.params;
|
|
879
|
-
|
|
874
|
+
globalThis.queueMicrotask(() => {
|
|
875
|
+
if (!this._disposed) updateDoc(unitId);
|
|
876
|
+
});
|
|
880
877
|
}
|
|
881
878
|
}));
|
|
882
879
|
}
|
|
883
880
|
insertFloatDom(floatDom, opts) {
|
|
884
|
-
var _skeleton$getSkeleton
|
|
881
|
+
var _skeleton$getSkeleton;
|
|
885
882
|
const currentDoc = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
886
883
|
if (!currentDoc) return false;
|
|
887
884
|
const render = this._getSceneAndTransformerByDrawingSearch(currentDoc.getUnitId());
|
|
@@ -892,7 +889,7 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
|
|
|
892
889
|
const width = pageWidth - marginLeft - marginRight;
|
|
893
890
|
const docTransform = {
|
|
894
891
|
size: {
|
|
895
|
-
width:
|
|
892
|
+
width: opts.width ?? width,
|
|
896
893
|
height: opts.height
|
|
897
894
|
},
|
|
898
895
|
positionH: {
|
|
@@ -905,7 +902,7 @@ let DocFloatDomController = class DocFloatDomController extends Disposable {
|
|
|
905
902
|
},
|
|
906
903
|
angle: 0
|
|
907
904
|
};
|
|
908
|
-
const drawingId =
|
|
905
|
+
const drawingId = opts.drawingId ?? generateRandomId();
|
|
909
906
|
const params = {
|
|
910
907
|
unitId: currentDoc.getUnitId(),
|
|
911
908
|
drawings: [{
|
|
@@ -940,20 +937,16 @@ function syncRectWithRuntimeParam(rect, param, fallbackViewport, fallbackTransfo
|
|
|
940
937
|
return true;
|
|
941
938
|
}
|
|
942
939
|
function getRuntimeTransform(param, rect, fallbackViewport, fallbackTransform, preserveRuntimeGeometry) {
|
|
943
|
-
var _param$
|
|
944
|
-
const transform =
|
|
945
|
-
const runtimeViewport =
|
|
946
|
-
if (!param.customBlockRenderViewport && preserveRuntimeGeometry && fallbackTransform && transform) {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
height: (_fallbackTransform$he = fallbackTransform.height) !== null && _fallbackTransform$he !== void 0 ? _fallbackTransform$he : transform.height
|
|
952
|
-
};
|
|
953
|
-
}
|
|
940
|
+
var _param$transforms;
|
|
941
|
+
const transform = param.transform ?? ((_param$transforms = param.transforms) === null || _param$transforms === void 0 ? void 0 : _param$transforms[0]);
|
|
942
|
+
const runtimeViewport = param.customBlockRenderViewport ?? fallbackViewport;
|
|
943
|
+
if (!param.customBlockRenderViewport && preserveRuntimeGeometry && fallbackTransform && transform) return {
|
|
944
|
+
...transform,
|
|
945
|
+
width: fallbackTransform.width ?? transform.width,
|
|
946
|
+
height: fallbackTransform.height ?? transform.height
|
|
947
|
+
};
|
|
954
948
|
if (!transform) {
|
|
955
|
-
|
|
956
|
-
const height = (_runtimeViewport$heig = runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.height) !== null && _runtimeViewport$heig !== void 0 ? _runtimeViewport$heig : runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.contentHeight;
|
|
949
|
+
const height = (runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.height) ?? (runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.contentHeight);
|
|
957
950
|
if (!isPositiveNumber(height)) return;
|
|
958
951
|
return {
|
|
959
952
|
left: rect.left,
|
|
@@ -963,7 +956,7 @@ function getRuntimeTransform(param, rect, fallbackViewport, fallbackTransform, p
|
|
|
963
956
|
angle: rect.angle
|
|
964
957
|
};
|
|
965
958
|
}
|
|
966
|
-
const height = (
|
|
959
|
+
const height = (runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.height) ?? (runtimeViewport === null || runtimeViewport === void 0 ? void 0 : runtimeViewport.contentHeight);
|
|
967
960
|
if (!isPositiveNumber(height)) return transform;
|
|
968
961
|
return {
|
|
969
962
|
...transform,
|
|
@@ -976,6 +969,11 @@ function isEmbedFloatDomRuntimeParam(param) {
|
|
|
976
969
|
const candidate = data;
|
|
977
970
|
return candidate.version === 1 && typeof candidate.embedId === "string" && typeof candidate.hostAnchorId === "string";
|
|
978
971
|
}
|
|
972
|
+
function isSheetLikeEmbedFloatDomRuntimeParam(param) {
|
|
973
|
+
if (!isEmbedFloatDomRuntimeParam(param)) return false;
|
|
974
|
+
const data = param.data;
|
|
975
|
+
return !!data && typeof data === "object" && "childType" in data && typeof data.childType === "number" && isSheetLikeDocsCustomBlockChildType(data.childType);
|
|
976
|
+
}
|
|
979
977
|
function createTransformFromRect(rect) {
|
|
980
978
|
return {
|
|
981
979
|
angle: rect.angle,
|
|
@@ -1035,7 +1033,8 @@ const getDisableWhenSelectionInTableObservable = (accessor) => {
|
|
|
1035
1033
|
function ImageMenuFactory(accessor) {
|
|
1036
1034
|
return {
|
|
1037
1035
|
id: DOCS_IMAGE_MENU_ID,
|
|
1038
|
-
|
|
1036
|
+
commandId: IMAGE_MENU_UPLOAD_FLOAT_ID,
|
|
1037
|
+
type: MenuItemType.BUTTON,
|
|
1039
1038
|
icon: "AddImageIcon",
|
|
1040
1039
|
tooltip: "docs-drawing-ui.title",
|
|
1041
1040
|
disabled$: getDisableWhenSelectionInTableObservable(accessor),
|
|
@@ -1129,11 +1128,7 @@ function InsertEllipseShapeBelowMenuFactory(accessor) {
|
|
|
1129
1128
|
const menuSchema = {
|
|
1130
1129
|
[RibbonInsertGroup.MEDIA]: { [DOCS_IMAGE_MENU_ID]: {
|
|
1131
1130
|
order: 0,
|
|
1132
|
-
menuItemFactory: ImageMenuFactory
|
|
1133
|
-
[IMAGE_MENU_UPLOAD_FLOAT_ID]: {
|
|
1134
|
-
order: 0,
|
|
1135
|
-
menuItemFactory: UploadFloatImageMenuFactory
|
|
1136
|
-
}
|
|
1131
|
+
menuItemFactory: ImageMenuFactory
|
|
1137
1132
|
} },
|
|
1138
1133
|
[ContextMenuPosition.PARAGRAPH]: {
|
|
1139
1134
|
[ContextMenuGroup.LAYOUT]: { [INSERT_BELLOW_MENU_ID]: { [IMAGE_MENU_UPLOAD_FLOAT_ID]: {
|
|
@@ -1196,7 +1191,7 @@ const menuSchema = {
|
|
|
1196
1191
|
//#endregion
|
|
1197
1192
|
//#region package.json
|
|
1198
1193
|
var name = "@univerjs/docs-drawing-ui";
|
|
1199
|
-
var version = "1.0.0-
|
|
1194
|
+
var version = "1.0.0-beta.1";
|
|
1200
1195
|
|
|
1201
1196
|
//#endregion
|
|
1202
1197
|
//#region src/config/config.ts
|
|
@@ -1359,7 +1354,7 @@ function DocDrawingPositionContent(props) {
|
|
|
1359
1354
|
else if (relativeFrom === ObjectRelativeFromH.PAGE) {}
|
|
1360
1355
|
handlePositionChange("positionH", {
|
|
1361
1356
|
relativeFrom,
|
|
1362
|
-
posOffset: (prevPosOffset
|
|
1357
|
+
posOffset: (prevPosOffset ?? 0) - delta
|
|
1363
1358
|
});
|
|
1364
1359
|
}
|
|
1365
1360
|
function handleVerticalRelativeFromChange(value) {
|
|
@@ -1394,7 +1389,7 @@ function DocDrawingPositionContent(props) {
|
|
|
1394
1389
|
else if (relativeFrom === ObjectRelativeFromV.PAGE) delta -= page.marginTop;
|
|
1395
1390
|
handlePositionChange("positionV", {
|
|
1396
1391
|
relativeFrom,
|
|
1397
|
-
posOffset: (prevPosOffset
|
|
1392
|
+
posOffset: (prevPosOffset ?? 0) - delta
|
|
1398
1393
|
});
|
|
1399
1394
|
}
|
|
1400
1395
|
function updateState(drawingParam) {
|
|
@@ -1706,7 +1701,7 @@ const IMoveInlineDrawingCommand = {
|
|
|
1706
1701
|
id: "doc.command.move-inline-drawing",
|
|
1707
1702
|
type: CommandType.COMMAND,
|
|
1708
1703
|
handler: (accessor, params) => {
|
|
1709
|
-
var _renderManagerService
|
|
1704
|
+
var _renderManagerService;
|
|
1710
1705
|
if (params == null) return false;
|
|
1711
1706
|
const { drawing, unitId, offset, segmentId: newSegmentId, segmentPage, needRefreshDrawings } = params;
|
|
1712
1707
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
@@ -1727,7 +1722,7 @@ const IMoveInlineDrawingCommand = {
|
|
|
1727
1722
|
}
|
|
1728
1723
|
const rawActions = [];
|
|
1729
1724
|
const { drawingId } = drawing;
|
|
1730
|
-
const actions = getDeleteAndInsertCustomBlockActions(newSegmentId,
|
|
1725
|
+
const actions = getDeleteAndInsertCustomBlockActions(newSegmentId, docSelectionRenderService.getSegment() ?? "", segmentPage, offset, drawingId, documentDataModel, docSelectionRenderService);
|
|
1731
1726
|
if (actions == null || actions.length === 0) {
|
|
1732
1727
|
docRefreshDrawingsService.refreshDrawings(skeleton);
|
|
1733
1728
|
transformer.refreshControls();
|
|
@@ -1757,7 +1752,7 @@ const ITransformNonInlineDrawingCommand = {
|
|
|
1757
1752
|
id: "doc.command.transform-non-inline-drawing",
|
|
1758
1753
|
type: CommandType.COMMAND,
|
|
1759
1754
|
handler: (accessor, params) => {
|
|
1760
|
-
var _renderManagerService2
|
|
1755
|
+
var _renderManagerService2;
|
|
1761
1756
|
if (params == null) return false;
|
|
1762
1757
|
const { drawing, unitId, offset, docTransform, segmentId: newSegmentId, segmentPage } = params;
|
|
1763
1758
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
@@ -1771,7 +1766,7 @@ const ITransformNonInlineDrawingCommand = {
|
|
|
1771
1766
|
if (documentDataModel == null) return false;
|
|
1772
1767
|
const rawActions = [];
|
|
1773
1768
|
const { drawingId } = drawing;
|
|
1774
|
-
const actions = getDeleteAndInsertCustomBlockActions(newSegmentId,
|
|
1769
|
+
const actions = getDeleteAndInsertCustomBlockActions(newSegmentId, docSelectionRenderService.getSegment() ?? "", segmentPage, offset, drawingId, documentDataModel, docSelectionRenderService);
|
|
1775
1770
|
if (actions == null) return false;
|
|
1776
1771
|
if (actions.length > 0) rawActions.push(...actions);
|
|
1777
1772
|
const jsonX = JSONX.getInstance();
|
|
@@ -2281,12 +2276,12 @@ let DocDrawingAddRemoveController = class DocDrawingAddRemoveController extends
|
|
|
2281
2276
|
if (unitId == null || focusedDrawings.length === 0) return;
|
|
2282
2277
|
const renderObject = this._renderManagerService.getRenderUnitById(unitId);
|
|
2283
2278
|
const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
|
|
2284
|
-
if (scene == null) return false;
|
|
2279
|
+
if (renderObject == null || scene == null) return false;
|
|
2280
|
+
this._docRefreshDrawingsService.refreshDrawings(renderObject.with(DocSkeletonManagerService).getSkeleton());
|
|
2285
2281
|
scene.getTransformerByCreate().refreshControls();
|
|
2286
2282
|
}));
|
|
2287
2283
|
}
|
|
2288
2284
|
_preserveWrappingStylePosition(params) {
|
|
2289
|
-
var _documentDataModel$ge;
|
|
2290
2285
|
if (params.wrappingStyle === TextWrappingStyle.INLINE) return;
|
|
2291
2286
|
const { unitId } = params;
|
|
2292
2287
|
const documentDataModel = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
@@ -2297,7 +2292,7 @@ let DocDrawingAddRemoveController = class DocDrawingAddRemoveController extends
|
|
|
2297
2292
|
if (!documentDataModel || !skeletonData || !viewModel) return;
|
|
2298
2293
|
const editArea = viewModel.getEditArea();
|
|
2299
2294
|
const { pages, skeHeaders, skeFooters } = skeletonData;
|
|
2300
|
-
const oldDrawings =
|
|
2295
|
+
const oldDrawings = documentDataModel.getDrawings() ?? {};
|
|
2301
2296
|
params.drawings = params.drawings.map((drawing) => {
|
|
2302
2297
|
const oldDrawing = oldDrawings[drawing.drawingId];
|
|
2303
2298
|
if (!oldDrawing) return drawing;
|
|
@@ -2595,8 +2590,7 @@ function getDocsTableCellDrawingOffset(unitId, table, row, cell) {
|
|
|
2595
2590
|
};
|
|
2596
2591
|
}
|
|
2597
2592
|
function hasHorizontalTableViewport(viewport) {
|
|
2598
|
-
|
|
2599
|
-
return viewport != null && ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0) + viewport.contentWidth + ((_viewport$trailingIns = viewport.trailingInsetRight) !== null && _viewport$trailingIns !== void 0 ? _viewport$trailingIns : 0) > viewport.viewportWidth;
|
|
2593
|
+
return viewport != null && (viewport.leadingInsetLeft ?? 0) + viewport.contentWidth + (viewport.trailingInsetRight ?? 0) > viewport.viewportWidth;
|
|
2600
2594
|
}
|
|
2601
2595
|
let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateController extends Disposable {
|
|
2602
2596
|
constructor(_context, _docSkeletonManagerService, _commandService, _editorService, _drawingManagerService, _docRefreshDrawingsService, _univerInstanceService, _lifecycleService) {
|
|
@@ -2610,13 +2604,14 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
|
|
|
2610
2604
|
this._univerInstanceService = _univerInstanceService;
|
|
2611
2605
|
this._lifecycleService = _lifecycleService;
|
|
2612
2606
|
_defineProperty(this, "_liquid", new Liquid());
|
|
2607
|
+
_defineProperty(this, "_changesetDrawingRefreshScheduled", false);
|
|
2613
2608
|
this._initialize();
|
|
2614
2609
|
this._commandExecutedListener();
|
|
2615
2610
|
}
|
|
2616
2611
|
_initialize() {
|
|
2617
2612
|
this._initialRenderRefresh();
|
|
2618
2613
|
this._drawingInitializeListener();
|
|
2619
|
-
this.
|
|
2614
|
+
this._initTransformRefresh();
|
|
2620
2615
|
}
|
|
2621
2616
|
_initialRenderRefresh() {
|
|
2622
2617
|
this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe((documentSkeleton) => {
|
|
@@ -2630,23 +2625,42 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
|
|
|
2630
2625
|
}
|
|
2631
2626
|
_commandExecutedListener() {
|
|
2632
2627
|
const updateCommandList = [RichTextEditingMutation.id, SetDocZoomRatioOperation.id];
|
|
2633
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
2628
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command, options) => {
|
|
2634
2629
|
if (updateCommandList.includes(command.id)) {
|
|
2635
2630
|
const { unitId: commandUnitId } = command.params;
|
|
2636
|
-
const { unitId
|
|
2631
|
+
const { unitId } = this._context;
|
|
2637
2632
|
if (commandUnitId !== unitId) return;
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
if (this._editorService.isEditor(unitId)) {
|
|
2641
|
-
mainComponent === null || mainComponent === void 0 || mainComponent.makeDirty();
|
|
2633
|
+
if (command.id === RichTextEditingMutation.id && (options === null || options === void 0 ? void 0 : options.fromChangeset)) {
|
|
2634
|
+
this._scheduleChangesetDrawingRefresh();
|
|
2642
2635
|
return;
|
|
2643
2636
|
}
|
|
2644
|
-
this.
|
|
2637
|
+
this._refreshCurrentDrawing();
|
|
2645
2638
|
}
|
|
2646
2639
|
}));
|
|
2647
2640
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2641
|
+
_scheduleChangesetDrawingRefresh() {
|
|
2642
|
+
if (this._changesetDrawingRefreshScheduled) return;
|
|
2643
|
+
this._changesetDrawingRefreshScheduled = true;
|
|
2644
|
+
queueMicrotask(() => {
|
|
2645
|
+
queueMicrotask(() => {
|
|
2646
|
+
this._changesetDrawingRefreshScheduled = false;
|
|
2647
|
+
if (this._disposed) return;
|
|
2648
|
+
this._refreshCurrentDrawing();
|
|
2649
|
+
});
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
_refreshCurrentDrawing() {
|
|
2653
|
+
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
2654
|
+
if (skeleton == null) return;
|
|
2655
|
+
const { unitId, mainComponent } = this._context;
|
|
2656
|
+
if (this._editorService.isEditor(unitId)) {
|
|
2657
|
+
mainComponent === null || mainComponent === void 0 || mainComponent.makeDirty();
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
this._refreshDrawing(skeleton);
|
|
2661
|
+
}
|
|
2662
|
+
_initTransformRefresh() {
|
|
2663
|
+
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(() => {
|
|
2650
2664
|
var _scene$getTransformer;
|
|
2651
2665
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
2652
2666
|
const { scene } = this._context;
|
|
@@ -2700,21 +2714,17 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
|
|
|
2700
2714
|
this._handleMultiDrawingsTransform(multiDrawings);
|
|
2701
2715
|
}
|
|
2702
2716
|
_getStaleNonMultiDrawings(unitId, updateDrawingMap) {
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
transforms: (_drawing$transforms = drawing.transforms) !== null && _drawing$transforms !== void 0 ? _drawing$transforms : [],
|
|
2715
|
-
isMultiTransform: (_drawing$isMultiTrans = drawing.isMultiTransform) !== null && _drawing$isMultiTrans !== void 0 ? _drawing$isMultiTrans : BooleanNumber.FALSE
|
|
2716
|
-
};
|
|
2717
|
-
});
|
|
2717
|
+
const drawingData = this._drawingManagerService.getDrawingData(unitId, unitId) ?? {};
|
|
2718
|
+
return Object.values(drawingData).filter((drawing) => drawing.isMultiTransform !== BooleanNumber.TRUE).filter((drawing) => updateDrawingMap[drawing.drawingId] == null).map((drawing) => ({
|
|
2719
|
+
unitId,
|
|
2720
|
+
subUnitId: unitId,
|
|
2721
|
+
drawingId: drawing.drawingId,
|
|
2722
|
+
behindText: false,
|
|
2723
|
+
hidden: true,
|
|
2724
|
+
transform: drawing.transform,
|
|
2725
|
+
transforms: drawing.transforms ?? [],
|
|
2726
|
+
isMultiTransform: drawing.isMultiTransform ?? BooleanNumber.FALSE
|
|
2727
|
+
}));
|
|
2718
2728
|
}
|
|
2719
2729
|
_handleMultiDrawingsTransform(multiDrawings) {
|
|
2720
2730
|
const { scene, unitId } = this._context;
|
|
@@ -2786,8 +2796,8 @@ let DocDrawingTransformUpdateController = class DocDrawingTransformUpdateControl
|
|
|
2786
2796
|
height
|
|
2787
2797
|
}) : void 0;
|
|
2788
2798
|
const transform = {
|
|
2789
|
-
left: (pageRelativeLeft
|
|
2790
|
-
top: (pageRelativeTop
|
|
2799
|
+
left: (pageRelativeLeft ?? aLeft) + docsLeft + (pageRelativeLeft == null ? this._liquid.x : pageOffsetLeft),
|
|
2800
|
+
top: (pageRelativeTop ?? aTop) + docsTop + (pageRelativeTop == null ? this._liquid.y : pageOffsetTop),
|
|
2791
2801
|
width,
|
|
2792
2802
|
height,
|
|
2793
2803
|
angle,
|
|
@@ -2868,6 +2878,28 @@ function getDocsTableCellAnchorContext(unitId, cell) {
|
|
|
2868
2878
|
table
|
|
2869
2879
|
};
|
|
2870
2880
|
}
|
|
2881
|
+
function shouldUseDocsDrawingOuterPageOrigin(config) {
|
|
2882
|
+
const { drawing, height, hostPage, page, width } = config;
|
|
2883
|
+
if (drawing.layoutType !== PositionedObjectLayoutType.WRAP_NONE) return false;
|
|
2884
|
+
return getDocsPageRelativeDrawingAnchorPage({
|
|
2885
|
+
page,
|
|
2886
|
+
clipPage: getDocsDrawingClipPage({
|
|
2887
|
+
drawing: {
|
|
2888
|
+
behindText: getDocsDrawingBehindText({
|
|
2889
|
+
drawingOrigin: drawing,
|
|
2890
|
+
hostPage
|
|
2891
|
+
}),
|
|
2892
|
+
transform: {
|
|
2893
|
+
width,
|
|
2894
|
+
height
|
|
2895
|
+
}
|
|
2896
|
+
},
|
|
2897
|
+
hostPage,
|
|
2898
|
+
page
|
|
2899
|
+
}),
|
|
2900
|
+
hostPage
|
|
2901
|
+
}) != null;
|
|
2902
|
+
}
|
|
2871
2903
|
let DocDrawingTransformerController = class DocDrawingTransformerController extends Disposable {
|
|
2872
2904
|
constructor(_commandService, _univerInstanceService, _drawingManagerService, _renderManagerService) {
|
|
2873
2905
|
super();
|
|
@@ -2924,7 +2956,6 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
2924
2956
|
}
|
|
2925
2957
|
})));
|
|
2926
2958
|
const throttleMultipleDrawingUpdate = throttle(this._updateMultipleDrawingDocTransform.bind(this), 50);
|
|
2927
|
-
throttle(this._nonInlineDrawingTransform.bind(this), 50);
|
|
2928
2959
|
this.disposeWithMe(toDisposable(transformer.changing$.subscribe((state) => {
|
|
2929
2960
|
const { objects, offsetX, offsetY } = state;
|
|
2930
2961
|
if (objects.size > 1) throttleMultipleDrawingUpdate(objects);
|
|
@@ -2932,7 +2963,6 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
2932
2963
|
const drawingCache = this._transformerCache.values().next().value;
|
|
2933
2964
|
const { width, height, top, left, angle } = objects.values().next().value;
|
|
2934
2965
|
if (drawingCache && width === drawingCache.width && height === drawingCache.height && top === drawingCache.top && left === drawingCache.left && angle === drawingCache.angle) return;
|
|
2935
|
-
if (drawingCache && drawingCache.drawing.layoutType !== PositionedObjectLayoutType.INLINE) {}
|
|
2936
2966
|
if (drawingCache && drawingCache.drawing.layoutType === PositionedObjectLayoutType.INLINE && offsetX != null && offsetY != null) this._updateInlineDrawingAnchor(drawingCache.drawing, offsetX, offsetY);
|
|
2937
2967
|
}
|
|
2938
2968
|
})));
|
|
@@ -3026,14 +3056,13 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3026
3056
|
this._getDrawingAnchor(drawingCache.drawing, object);
|
|
3027
3057
|
}
|
|
3028
3058
|
_updateInlineDrawingAnchor(drawing, offsetX, offsetY) {
|
|
3029
|
-
var _this$_getInlineDrawi;
|
|
3030
3059
|
if (this._transformerCache.size !== 1) return;
|
|
3031
|
-
const { contentBoxPointGroup } =
|
|
3060
|
+
const { contentBoxPointGroup } = this._getInlineDrawingAnchor(drawing, offsetX, offsetY) ?? {};
|
|
3032
3061
|
if (contentBoxPointGroup == null) return;
|
|
3033
3062
|
this._createOrUpdateInlineAnchor(drawing.unitId, contentBoxPointGroup);
|
|
3034
3063
|
}
|
|
3035
3064
|
_getInlineDrawingAnchor(drawing, offsetX, offsetY) {
|
|
3036
|
-
var _this$_renderManagerS
|
|
3065
|
+
var _this$_renderManagerS;
|
|
3037
3066
|
const currentRender = this._renderManagerService.getRenderUnitById(drawing.unitId);
|
|
3038
3067
|
const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
|
|
3039
3068
|
if (currentRender == null) return;
|
|
@@ -3071,7 +3100,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3071
3100
|
isBack
|
|
3072
3101
|
};
|
|
3073
3102
|
const { cursorList, contentBoxPointGroup } = new NodePositionConvertToCursor(docObject.document.getOffsetConfig(), skeleton).getRangePointData(positionWithIsBack, positionWithIsBack);
|
|
3074
|
-
const { startOffset } =
|
|
3103
|
+
const { startOffset } = getOneTextSelectionRange(cursorList) ?? {};
|
|
3075
3104
|
if (startOffset == null) return;
|
|
3076
3105
|
return {
|
|
3077
3106
|
offset: startOffset,
|
|
@@ -3081,7 +3110,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3081
3110
|
};
|
|
3082
3111
|
}
|
|
3083
3112
|
_getDrawingAnchor(drawing, object) {
|
|
3084
|
-
var _this$_renderManagerS2, _glyphAnchor$parent, _column$parent
|
|
3113
|
+
var _this$_renderManagerS2, _glyphAnchor$parent, _column$parent, _column$parent2;
|
|
3085
3114
|
const currentRender = this._renderManagerService.getRenderUnitById(drawing.unitId);
|
|
3086
3115
|
const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
|
|
3087
3116
|
const skeletonData = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getSkeletonData();
|
|
@@ -3128,18 +3157,30 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3128
3157
|
if (glyphAnchor == null) return;
|
|
3129
3158
|
const line = (_glyphAnchor$parent = glyphAnchor.parent) === null || _glyphAnchor$parent === void 0 ? void 0 : _glyphAnchor$parent.parent;
|
|
3130
3159
|
const column = line === null || line === void 0 ? void 0 : line.parent;
|
|
3131
|
-
const sectionTop = (
|
|
3132
|
-
const paragraphStartLine = (
|
|
3160
|
+
const sectionTop = (column === null || column === void 0 || (_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : _column$parent.top) ?? 0;
|
|
3161
|
+
const paragraphStartLine = (column === null || column === void 0 ? void 0 : column.lines.find((l) => l.paragraphIndex === (line === null || line === void 0 ? void 0 : line.paragraphIndex) && l.paragraphStart)) ?? (column === null || column === void 0 ? void 0 : column.lines[0]);
|
|
3133
3162
|
const page = column === null || column === void 0 || (_column$parent2 = column.parent) === null || _column$parent2 === void 0 ? void 0 : _column$parent2.parent;
|
|
3134
3163
|
if (line == null || column == null || paragraphStartLine == null || page == null) return;
|
|
3135
3164
|
this._liquid.reset();
|
|
3136
3165
|
const tableCellContext = page.type === DocumentSkeletonPageType.CELL ? getDocsTableCellAnchorContext(drawing.unitId, page) : null;
|
|
3137
|
-
const anchorPage = (
|
|
3166
|
+
const anchorPage = (tableCellContext === null || tableCellContext === void 0 ? void 0 : tableCellContext.hostPage) ?? page;
|
|
3138
3167
|
const pageType = anchorPage.type;
|
|
3168
|
+
const drawingHostPage = (page.type === DocumentSkeletonPageType.HEADER || page.type === DocumentSkeletonPageType.FOOTER) && segmentPage > -1 ? pages[segmentPage] : void 0;
|
|
3169
|
+
const useOuterPageOrigin = shouldUseDocsDrawingOuterPageOrigin({
|
|
3170
|
+
drawing,
|
|
3171
|
+
height: object.height,
|
|
3172
|
+
hostPage: drawingHostPage,
|
|
3173
|
+
page,
|
|
3174
|
+
width: object.width
|
|
3175
|
+
});
|
|
3176
|
+
let pageOffsetLeft = this._liquid.x;
|
|
3177
|
+
let pageOffsetTop = this._liquid.y;
|
|
3139
3178
|
for (const p of pages) {
|
|
3140
3179
|
const { headerId, footerId, pageHeight, pageWidth, marginLeft, marginBottom } = p;
|
|
3141
3180
|
const pIndex = pages.indexOf(p);
|
|
3142
3181
|
if (segmentPage > -1 && pIndex === segmentPage) {
|
|
3182
|
+
pageOffsetLeft = this._liquid.x;
|
|
3183
|
+
pageOffsetTop = this._liquid.y;
|
|
3143
3184
|
switch (pageType) {
|
|
3144
3185
|
case DocumentSkeletonPageType.HEADER: {
|
|
3145
3186
|
var _skeHeaders$get;
|
|
@@ -3167,6 +3208,10 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3167
3208
|
}
|
|
3168
3209
|
break;
|
|
3169
3210
|
}
|
|
3211
|
+
if (p === anchorPage) {
|
|
3212
|
+
pageOffsetLeft = this._liquid.x;
|
|
3213
|
+
pageOffsetTop = this._liquid.y;
|
|
3214
|
+
}
|
|
3170
3215
|
this._liquid.translatePagePadding(p);
|
|
3171
3216
|
if (p === anchorPage) break;
|
|
3172
3217
|
this._liquid.restorePagePadding(p);
|
|
@@ -3175,14 +3220,17 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3175
3220
|
if (tableCellContext) this._liquid.translate(tableCellContext.offset.left, tableCellContext.offset.top);
|
|
3176
3221
|
if (positionV.relativeFrom === ObjectRelativeFromV.LINE) glyphAnchor = line.divides[0].glyphGroup[0];
|
|
3177
3222
|
else {
|
|
3178
|
-
var _paragraphStartLine$d
|
|
3179
|
-
glyphAnchor = (_paragraphStartLine$d =
|
|
3223
|
+
var _paragraphStartLine$d;
|
|
3224
|
+
glyphAnchor = ((_paragraphStartLine$d = paragraphStartLine.divides) === null || _paragraphStartLine$d === void 0 || (_paragraphStartLine$d = _paragraphStartLine$d[0]) === null || _paragraphStartLine$d === void 0 || (_paragraphStartLine$d = _paragraphStartLine$d.glyphGroup) === null || _paragraphStartLine$d === void 0 ? void 0 : _paragraphStartLine$d[0]) ?? glyphAnchor;
|
|
3180
3225
|
}
|
|
3181
3226
|
docTransform.positionH = {
|
|
3182
3227
|
relativeFrom: positionH.relativeFrom,
|
|
3183
3228
|
posOffset: left - this._liquid.x - docsLeft
|
|
3184
3229
|
};
|
|
3185
3230
|
switch (positionH.relativeFrom) {
|
|
3231
|
+
case ObjectRelativeFromH.PAGE:
|
|
3232
|
+
if (useOuterPageOrigin) docTransform.positionH.posOffset = left - pageOffsetLeft - docsLeft;
|
|
3233
|
+
break;
|
|
3186
3234
|
case ObjectRelativeFromH.MARGIN:
|
|
3187
3235
|
docTransform.positionH.posOffset = left - this._liquid.x - docsLeft - page.marginLeft;
|
|
3188
3236
|
break;
|
|
@@ -3196,7 +3244,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3196
3244
|
};
|
|
3197
3245
|
switch (positionV.relativeFrom) {
|
|
3198
3246
|
case ObjectRelativeFromV.PAGE:
|
|
3199
|
-
docTransform.positionV.posOffset = top - this._liquid.y - docsTop
|
|
3247
|
+
docTransform.positionV.posOffset = useOuterPageOrigin ? top - pageOffsetTop - docsTop : top - this._liquid.y - docsTop + page.marginTop;
|
|
3200
3248
|
break;
|
|
3201
3249
|
case ObjectRelativeFromV.LINE:
|
|
3202
3250
|
docTransform.positionV.posOffset = top - this._liquid.y - docsTop - sectionTop - line.top;
|
|
@@ -3214,7 +3262,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3214
3262
|
isBack
|
|
3215
3263
|
};
|
|
3216
3264
|
const { cursorList } = new NodePositionConvertToCursor(docObject.document.getOffsetConfig(), skeleton).getRangePointData(positionWithIsBack, positionWithIsBack);
|
|
3217
|
-
const { startOffset } =
|
|
3265
|
+
const { startOffset } = getOneTextSelectionRange(cursorList) ?? {};
|
|
3218
3266
|
if (startOffset == null) return;
|
|
3219
3267
|
return {
|
|
3220
3268
|
offset: startOffset,
|
|
@@ -3251,8 +3299,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3251
3299
|
});
|
|
3252
3300
|
}
|
|
3253
3301
|
_moveInlineDrawing(drawing, offsetX, offsetY) {
|
|
3254
|
-
const
|
|
3255
|
-
const { offset, segmentId, segmentPage } = anchor !== null && anchor !== void 0 ? anchor : {};
|
|
3302
|
+
const { offset, segmentId, segmentPage } = this._getInlineDrawingAnchor(drawing, offsetX, offsetY) ?? {};
|
|
3256
3303
|
return this._commandService.executeCommand(IMoveInlineDrawingCommand.id, {
|
|
3257
3304
|
unitId: drawing.unitId,
|
|
3258
3305
|
subUnitId: drawing.unitId,
|
|
@@ -3268,7 +3315,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3268
3315
|
const { left, top, width, height, angle } = object;
|
|
3269
3316
|
const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
|
|
3270
3317
|
const skeletonData = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getSkeletonData();
|
|
3271
|
-
const { pages } = skeletonData
|
|
3318
|
+
const { pages } = skeletonData ?? {};
|
|
3272
3319
|
if (skeletonData == null || currentRender == null || pages == null) return {
|
|
3273
3320
|
left,
|
|
3274
3321
|
top,
|
|
@@ -3299,8 +3346,7 @@ let DocDrawingTransformerController = class DocDrawingTransformerController exte
|
|
|
3299
3346
|
_nonInlineDrawingTransform(drawing, object, isMoving = false) {
|
|
3300
3347
|
const objectPosition = drawing.isMultiTransform === BooleanNumber.TRUE ? object : this._limitDrawingInPage(drawing, object);
|
|
3301
3348
|
if (isMoving && objectPosition.top !== object.top) return;
|
|
3302
|
-
const
|
|
3303
|
-
const { offset, docTransform, segmentId, segmentPage } = anchor !== null && anchor !== void 0 ? anchor : {};
|
|
3349
|
+
const { offset, docTransform, segmentId, segmentPage } = this._getDrawingAnchor(drawing, objectPosition) ?? {};
|
|
3304
3350
|
if (offset == null || docTransform == null) return this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[drawing.drawingId, object]]));
|
|
3305
3351
|
return this._commandService.executeCommand(ITransformNonInlineDrawingCommand.id, {
|
|
3306
3352
|
unitId: drawing.unitId,
|
|
@@ -3660,7 +3706,6 @@ let DocDrawingPopupMenuController = class DocDrawingPopupMenuController extends
|
|
|
3660
3706
|
}));
|
|
3661
3707
|
}
|
|
3662
3708
|
_getDrawingPopupMenuItems(unitId, subUnitId, drawingId, drawingType) {
|
|
3663
|
-
var _editCommandInfo$labe, _editCommandInfo$comm, _editCommandInfo$comm2, _editCommandInfo$disa;
|
|
3664
3709
|
const drawing = this._drawingManagerService.getDrawingByParam({
|
|
3665
3710
|
unitId,
|
|
3666
3711
|
subUnitId,
|
|
@@ -3679,15 +3724,15 @@ let DocDrawingPopupMenuController = class DocDrawingPopupMenuController extends
|
|
|
3679
3724
|
}) : null;
|
|
3680
3725
|
return [
|
|
3681
3726
|
{
|
|
3682
|
-
label: (
|
|
3727
|
+
label: (editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.label) ?? "docs-drawing-ui.image-popup.edit",
|
|
3683
3728
|
index: 0,
|
|
3684
|
-
commandId: (
|
|
3685
|
-
commandParams: (
|
|
3729
|
+
commandId: (editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.commandId) ?? EditDocDrawingOperation.id,
|
|
3730
|
+
commandParams: (editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.commandParams) ?? {
|
|
3686
3731
|
unitId,
|
|
3687
3732
|
subUnitId,
|
|
3688
3733
|
drawingId
|
|
3689
3734
|
},
|
|
3690
|
-
disable: (
|
|
3735
|
+
disable: (editCommandInfo === null || editCommandInfo === void 0 ? void 0 : editCommandInfo.disable) ?? drawingType === DrawingTypeEnum.DRAWING_DOM,
|
|
3691
3736
|
hideOnClick: true,
|
|
3692
3737
|
icon: "DrawingEditIcon"
|
|
3693
3738
|
},
|
|
@@ -3786,7 +3831,7 @@ _defineProperty(UniverDocsDrawingUIPlugin, "pluginName", "DOC_DRAWING_UI_PLUGIN"
|
|
|
3786
3831
|
_defineProperty(UniverDocsDrawingUIPlugin, "packageName", name);
|
|
3787
3832
|
_defineProperty(UniverDocsDrawingUIPlugin, "version", version);
|
|
3788
3833
|
UniverDocsDrawingUIPlugin = __decorate([
|
|
3789
|
-
DependentOn(UniverDocsPlugin, UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsDrawingPlugin,
|
|
3834
|
+
DependentOn(UniverDocsPlugin, UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsDrawingPlugin, UniverDocsUIPlugin, UniverDrawingUIPlugin),
|
|
3790
3835
|
__decorateParam(1, Inject(Injector)),
|
|
3791
3836
|
__decorateParam(2, IRenderManagerService),
|
|
3792
3837
|
__decorateParam(3, IConfigService)
|