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