@univerjs/drawing 1.0.0-alpha.1 → 1.0.0-alpha.3
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 +184 -43
- package/lib/es/index.js +187 -34
- package/lib/index.js +187 -34
- package/lib/types/index.d.ts +4 -2
- package/lib/types/services/drawing-manager-impl.service.d.ts +1 -0
- package/lib/types/utils/drawing-group.d.ts +32 -0
- package/lib/types/utils/rotate-enabled.d.ts +28 -0
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandType, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService,
|
|
1
|
+
import { CommandType, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService, IURLImageService, ImageSourceType, ImageUploadStatusType, Inject, Injector, Plugin, createIdentifier, generateRandomId, merge, mergeOverrideWithDependencies, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
2
2
|
import * as json1 from "ot-json1";
|
|
3
3
|
import { Subject } from "rxjs";
|
|
4
4
|
|
|
@@ -56,7 +56,7 @@ const SetDrawingSelectedOperation = {
|
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region package.json
|
|
58
58
|
var name = "@univerjs/drawing";
|
|
59
|
-
var version = "1.0.0-alpha.
|
|
59
|
+
var version = "1.0.0-alpha.3";
|
|
60
60
|
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/config/config.ts
|
|
@@ -108,6 +108,23 @@ function _defineProperty(e, r, t) {
|
|
|
108
108
|
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region src/services/drawing-manager-impl.service.ts
|
|
111
|
+
function isNonEmptyOp(op) {
|
|
112
|
+
return Array.isArray(op) && op.length > 0;
|
|
113
|
+
}
|
|
114
|
+
function isJsonValueEqual(left, right) {
|
|
115
|
+
if (left === right) return true;
|
|
116
|
+
if (left == null || right == null || typeof left !== "object" || typeof right !== "object") return false;
|
|
117
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
118
|
+
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;
|
|
119
|
+
return left.every((item, index) => isJsonValueEqual(item, right[index]));
|
|
120
|
+
}
|
|
121
|
+
const leftRecord = left;
|
|
122
|
+
const rightRecord = right;
|
|
123
|
+
const leftKeys = Object.keys(leftRecord);
|
|
124
|
+
const rightKeys = Object.keys(rightRecord);
|
|
125
|
+
if (leftKeys.length !== rightKeys.length) return false;
|
|
126
|
+
return leftKeys.every((key) => Object.prototype.hasOwnProperty.call(rightRecord, key) && isJsonValueEqual(leftRecord[key], rightRecord[key]));
|
|
127
|
+
}
|
|
111
128
|
/**
|
|
112
129
|
* unitId -> subUnitId -> drawingId -> drawingParam
|
|
113
130
|
*/
|
|
@@ -208,6 +225,7 @@ var UnitDrawingService = class {
|
|
|
208
225
|
Object.keys(data).forEach((subUnitId) => {
|
|
209
226
|
this._establishDrawingMap(unitId, subUnitId);
|
|
210
227
|
const subUnitData = data[subUnitId];
|
|
228
|
+
if ((subUnitData === null || subUnitData === void 0 ? void 0 : subUnitData.data) == null) return;
|
|
211
229
|
Object.keys(subUnitData.data).forEach((drawingId) => {
|
|
212
230
|
const drawing = subUnitData.data[drawingId];
|
|
213
231
|
drawing.unitId = unitId;
|
|
@@ -267,10 +285,23 @@ var UnitDrawingService = class {
|
|
|
267
285
|
});
|
|
268
286
|
return this.getBatchRemoveOp(removeParams);
|
|
269
287
|
}
|
|
270
|
-
|
|
271
|
-
var _allToRemove$;
|
|
288
|
+
_getExpandedBatchRemoveParams(removeParams) {
|
|
272
289
|
const seenIds = /* @__PURE__ */ new Set();
|
|
273
290
|
const allToRemove = [];
|
|
291
|
+
const addDrawing = (drawing) => {
|
|
292
|
+
if (seenIds.has(drawing.drawingId)) return;
|
|
293
|
+
seenIds.add(drawing.drawingId);
|
|
294
|
+
allToRemove.push({
|
|
295
|
+
unitId: drawing.unitId,
|
|
296
|
+
subUnitId: drawing.subUnitId,
|
|
297
|
+
drawingId: drawing.drawingId
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
const addSearch = (search) => {
|
|
301
|
+
if (seenIds.has(search.drawingId)) return;
|
|
302
|
+
seenIds.add(search.drawingId);
|
|
303
|
+
allToRemove.push(search);
|
|
304
|
+
};
|
|
274
305
|
removeParams.forEach((removeParam) => {
|
|
275
306
|
const drawing = this.getDrawingByParam(removeParam);
|
|
276
307
|
if ((drawing === null || drawing === void 0 ? void 0 : drawing.drawingType) === DrawingTypeEnum.DRAWING_GROUP) {
|
|
@@ -278,25 +309,28 @@ var UnitDrawingService = class {
|
|
|
278
309
|
if (nested) {
|
|
279
310
|
const { flatChildren, groups } = nested;
|
|
280
311
|
[...flatChildren !== null && flatChildren !== void 0 ? flatChildren : [], ...groups].forEach((d) => {
|
|
281
|
-
|
|
282
|
-
seenIds.add(d.drawingId);
|
|
283
|
-
allToRemove.push({
|
|
284
|
-
unitId: d.unitId,
|
|
285
|
-
subUnitId: d.subUnitId,
|
|
286
|
-
drawingId: d.drawingId
|
|
287
|
-
});
|
|
288
|
-
}
|
|
312
|
+
addDrawing(d);
|
|
289
313
|
});
|
|
290
|
-
} else
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
} else if (!seenIds.has(removeParam.drawingId)) {
|
|
295
|
-
seenIds.add(removeParam.drawingId);
|
|
296
|
-
allToRemove.push(removeParam);
|
|
297
|
-
}
|
|
314
|
+
} else addDrawing(drawing);
|
|
315
|
+
} else if (drawing) addDrawing(drawing);
|
|
316
|
+
else addSearch(removeParam);
|
|
298
317
|
});
|
|
299
|
-
|
|
318
|
+
return allToRemove;
|
|
319
|
+
}
|
|
320
|
+
getBatchRemoveOp(removeParams) {
|
|
321
|
+
var _ref, _allToRemove$;
|
|
322
|
+
const allToRemove = this._getExpandedBatchRemoveParams(removeParams);
|
|
323
|
+
const { unitId, subUnitId } = (_ref = (_allToRemove$ = allToRemove[0]) !== null && _allToRemove$ !== void 0 ? _allToRemove$ : removeParams[0]) !== null && _ref !== void 0 ? _ref : {
|
|
324
|
+
unitId: "",
|
|
325
|
+
subUnitId: ""
|
|
326
|
+
};
|
|
327
|
+
if (allToRemove.length === 0) return {
|
|
328
|
+
undo: null,
|
|
329
|
+
redo: null,
|
|
330
|
+
unitId,
|
|
331
|
+
subUnitId,
|
|
332
|
+
objects: []
|
|
333
|
+
};
|
|
300
334
|
const orderArr = this._getDrawingOrder(unitId, subUnitId);
|
|
301
335
|
const orderIndexMap = /* @__PURE__ */ new Map();
|
|
302
336
|
orderArr.forEach((id, idx) => orderIndexMap.set(id, idx));
|
|
@@ -335,6 +369,7 @@ var UnitDrawingService = class {
|
|
|
335
369
|
const invertOps = [];
|
|
336
370
|
updateParams.forEach((updateParam) => {
|
|
337
371
|
const { op, invertOp } = this._updateByParam(updateParam);
|
|
372
|
+
if (!isNonEmptyOp(op)) return;
|
|
338
373
|
objects.push({
|
|
339
374
|
unitId: updateParam.unitId,
|
|
340
375
|
subUnitId: updateParam.subUnitId,
|
|
@@ -343,6 +378,16 @@ var UnitDrawingService = class {
|
|
|
343
378
|
ops.push(op);
|
|
344
379
|
invertOps.push(invertOp);
|
|
345
380
|
});
|
|
381
|
+
if (ops.length === 0) {
|
|
382
|
+
const { unitId, subUnitId } = updateParams[0];
|
|
383
|
+
return {
|
|
384
|
+
undo: null,
|
|
385
|
+
redo: null,
|
|
386
|
+
unitId,
|
|
387
|
+
subUnitId,
|
|
388
|
+
objects
|
|
389
|
+
};
|
|
390
|
+
}
|
|
346
391
|
const op = ops.reduce(json1.type.compose, null);
|
|
347
392
|
const invertOp = invertOps.reduce(json1.type.compose, null);
|
|
348
393
|
const { unitId, subUnitId } = updateParams[0];
|
|
@@ -834,7 +879,12 @@ var UnitDrawingService = class {
|
|
|
834
879
|
op: [],
|
|
835
880
|
invertOp: []
|
|
836
881
|
};
|
|
837
|
-
const
|
|
882
|
+
const ops = this._getUpdateParamCompareOp(updateParam, object);
|
|
883
|
+
if (ops.length === 0) return {
|
|
884
|
+
op: [],
|
|
885
|
+
invertOp: []
|
|
886
|
+
};
|
|
887
|
+
const op = ops.reduce(json1.type.compose, null);
|
|
838
888
|
return {
|
|
839
889
|
op,
|
|
840
890
|
invertOp: json1.type.invertWithDoc(op, this.drawingManagerData)
|
|
@@ -845,15 +895,29 @@ var UnitDrawingService = class {
|
|
|
845
895
|
const ops = [];
|
|
846
896
|
Object.keys(newParam).forEach((key) => {
|
|
847
897
|
const newVal = newParam[key];
|
|
898
|
+
const hasOldKey = Object.prototype.hasOwnProperty.call(oldParam, key);
|
|
848
899
|
const oldVal = oldParam[key];
|
|
849
|
-
if (oldVal
|
|
850
|
-
|
|
900
|
+
if (hasOldKey && isJsonValueEqual(oldVal, newVal)) return;
|
|
901
|
+
const path = [
|
|
851
902
|
unitId,
|
|
852
903
|
subUnitId,
|
|
853
904
|
"data",
|
|
854
905
|
drawingId,
|
|
855
906
|
key
|
|
856
|
-
]
|
|
907
|
+
];
|
|
908
|
+
if (!hasOldKey) {
|
|
909
|
+
if (newVal === void 0) return;
|
|
910
|
+
const op = json1.insertOp(path, newVal);
|
|
911
|
+
if (isNonEmptyOp(op)) ops.push(op);
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
if (newVal === void 0) {
|
|
915
|
+
const op = json1.removeOp(path, true);
|
|
916
|
+
if (isNonEmptyOp(op)) ops.push(op);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
const op = json1.replaceOp(path, oldVal, newVal);
|
|
920
|
+
if (isNonEmptyOp(op)) ops.push(op);
|
|
857
921
|
});
|
|
858
922
|
return ops;
|
|
859
923
|
}
|
|
@@ -896,7 +960,7 @@ var ImageIoService = class {
|
|
|
896
960
|
getImageSourceCache(source, imageSourceType) {
|
|
897
961
|
const cachedImage = this._imageSourceCache.get(source);
|
|
898
962
|
if (cachedImage != null) return cachedImage;
|
|
899
|
-
if (imageSourceType === ImageSourceType
|
|
963
|
+
if (imageSourceType === ImageSourceType.BASE64) {
|
|
900
964
|
const image = new Image();
|
|
901
965
|
image.onload = () => this._change$.next(this._waitCount);
|
|
902
966
|
image.onerror = () => this._change$.next(this._waitCount);
|
|
@@ -906,7 +970,7 @@ var ImageIoService = class {
|
|
|
906
970
|
}
|
|
907
971
|
}
|
|
908
972
|
addImageSourceCache(source, imageSourceType, imageSource) {
|
|
909
|
-
if (imageSourceType === ImageSourceType
|
|
973
|
+
if (imageSourceType === ImageSourceType.BASE64 || imageSource == null) return;
|
|
910
974
|
this._imageSourceCache.set(source, imageSource);
|
|
911
975
|
}
|
|
912
976
|
async getImage(imageId) {
|
|
@@ -915,12 +979,12 @@ var ImageIoService = class {
|
|
|
915
979
|
async saveImage(imageFile) {
|
|
916
980
|
return new Promise((resolve, reject) => {
|
|
917
981
|
if (!DRAWING_IMAGE_ALLOW_IMAGE_LIST.includes(imageFile.type)) {
|
|
918
|
-
reject(new Error(ImageUploadStatusType
|
|
982
|
+
reject(new Error(ImageUploadStatusType.ERROR_IMAGE_TYPE));
|
|
919
983
|
this._decreaseWaiting();
|
|
920
984
|
return;
|
|
921
985
|
}
|
|
922
986
|
if (imageFile.size > getDrawingImageAllowSize()) {
|
|
923
|
-
reject(new Error(ImageUploadStatusType
|
|
987
|
+
reject(new Error(ImageUploadStatusType.ERROR_EXCEED_SIZE));
|
|
924
988
|
this._decreaseWaiting();
|
|
925
989
|
return;
|
|
926
990
|
}
|
|
@@ -930,16 +994,16 @@ var ImageIoService = class {
|
|
|
930
994
|
var _evt$target;
|
|
931
995
|
const replaceSrc = (_evt$target = evt.target) === null || _evt$target === void 0 ? void 0 : _evt$target.result;
|
|
932
996
|
if (replaceSrc == null) {
|
|
933
|
-
reject(new Error(ImageUploadStatusType
|
|
997
|
+
reject(new Error(ImageUploadStatusType.ERROR_IMAGE));
|
|
934
998
|
this._decreaseWaiting();
|
|
935
999
|
return;
|
|
936
1000
|
}
|
|
937
1001
|
resolve({
|
|
938
1002
|
imageId: generateRandomId(6),
|
|
939
|
-
imageSourceType: ImageSourceType
|
|
1003
|
+
imageSourceType: ImageSourceType.BASE64,
|
|
940
1004
|
source: replaceSrc,
|
|
941
1005
|
base64Cache: replaceSrc,
|
|
942
|
-
status: ImageUploadStatusType
|
|
1006
|
+
status: ImageUploadStatusType.SUCCUSS
|
|
943
1007
|
});
|
|
944
1008
|
this._decreaseWaiting();
|
|
945
1009
|
};
|
|
@@ -1020,7 +1084,7 @@ let UniverDrawingPlugin = class UniverDrawingPlugin extends Plugin {
|
|
|
1020
1084
|
_initDependencies() {
|
|
1021
1085
|
var _this$_config;
|
|
1022
1086
|
mergeOverrideWithDependencies([
|
|
1023
|
-
[IImageIoService
|
|
1087
|
+
[IImageIoService, { useClass: ImageIoService }],
|
|
1024
1088
|
[IURLImageService, { useClass: URLImageService }],
|
|
1025
1089
|
[IDrawingManagerService, { useClass: DrawingManagerService }]
|
|
1026
1090
|
], (_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.override).forEach((d) => this._injector.add(d));
|
|
@@ -1038,6 +1102,69 @@ UniverDrawingPlugin = __decorate([
|
|
|
1038
1102
|
__decorateParam(3, ICommandService)
|
|
1039
1103
|
], UniverDrawingPlugin);
|
|
1040
1104
|
|
|
1105
|
+
//#endregion
|
|
1106
|
+
//#region src/utils/drawing-group.ts
|
|
1107
|
+
const DRAWING_GROUPABLE_TYPES = [
|
|
1108
|
+
DrawingTypeEnum.DRAWING_IMAGE,
|
|
1109
|
+
DrawingTypeEnum.DRAWING_SHAPE,
|
|
1110
|
+
DrawingTypeEnum.DRAWING_CHART,
|
|
1111
|
+
DrawingTypeEnum.DRAWING_GROUP
|
|
1112
|
+
];
|
|
1113
|
+
function isGroupableDrawingType(type) {
|
|
1114
|
+
return DRAWING_GROUPABLE_TYPES.includes(type);
|
|
1115
|
+
}
|
|
1116
|
+
const DRAWING_COPY_CONTEXT_KEY = "univer.drawing.copy-plan";
|
|
1117
|
+
function cloneDrawing(drawing) {
|
|
1118
|
+
return JSON.parse(JSON.stringify(drawing));
|
|
1119
|
+
}
|
|
1120
|
+
function copyDrawingWithIdMap(drawing, idMap, options) {
|
|
1121
|
+
const copied = cloneDrawing(drawing);
|
|
1122
|
+
const copiedDrawingId = idMap.get(drawing.drawingId);
|
|
1123
|
+
if (copiedDrawingId == null) return copied;
|
|
1124
|
+
copied.unitId = options.unitId;
|
|
1125
|
+
copied.subUnitId = options.targetSubUnitId;
|
|
1126
|
+
copied.drawingId = copiedDrawingId;
|
|
1127
|
+
if (copied.groupId) {
|
|
1128
|
+
const copiedGroupId = idMap.get(copied.groupId);
|
|
1129
|
+
if (copiedGroupId) copied.groupId = copiedGroupId;
|
|
1130
|
+
else delete copied.groupId;
|
|
1131
|
+
}
|
|
1132
|
+
return copied;
|
|
1133
|
+
}
|
|
1134
|
+
function createDrawingCopyPlan(drawings, options) {
|
|
1135
|
+
const { generateId = () => generateRandomId(10) } = options;
|
|
1136
|
+
const idMap = /* @__PURE__ */ new Map();
|
|
1137
|
+
drawings.forEach((drawing) => {
|
|
1138
|
+
if (!idMap.has(drawing.drawingId)) idMap.set(drawing.drawingId, generateId());
|
|
1139
|
+
});
|
|
1140
|
+
return {
|
|
1141
|
+
idMap,
|
|
1142
|
+
drawings: drawings.map((drawing) => copyDrawingWithIdMap(drawing, idMap, options))
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
function getOrCreateDrawingCopyPlan(copyContext, drawings, options) {
|
|
1146
|
+
if (copyContext == null) return createDrawingCopyPlan(drawings, options);
|
|
1147
|
+
const cached = copyContext.get(DRAWING_COPY_CONTEXT_KEY);
|
|
1148
|
+
if (cached) {
|
|
1149
|
+
const { generateId = () => generateRandomId(10) } = options;
|
|
1150
|
+
if (!drawings.some((drawing) => !cached.idMap.has(drawing.drawingId))) return cached;
|
|
1151
|
+
drawings.forEach((drawing) => {
|
|
1152
|
+
if (!cached.idMap.has(drawing.drawingId)) cached.idMap.set(drawing.drawingId, generateId());
|
|
1153
|
+
});
|
|
1154
|
+
const incomingDrawingIds = new Set(drawings.map((drawing) => drawing.drawingId));
|
|
1155
|
+
const originalIdByCopiedId = new Map(Array.from(cached.idMap.entries()).map(([drawingId, copiedDrawingId]) => [copiedDrawingId, drawingId]));
|
|
1156
|
+
const retainedDrawings = cached.drawings.filter((drawing) => {
|
|
1157
|
+
const originalDrawingId = originalIdByCopiedId.get(drawing.drawingId);
|
|
1158
|
+
return originalDrawingId == null || !incomingDrawingIds.has(originalDrawingId);
|
|
1159
|
+
});
|
|
1160
|
+
cached.drawings = [...drawings.map((drawing) => copyDrawingWithIdMap(drawing, cached.idMap, options)), ...retainedDrawings];
|
|
1161
|
+
return cached;
|
|
1162
|
+
}
|
|
1163
|
+
const plan = createDrawingCopyPlan(drawings, options);
|
|
1164
|
+
copyContext.set(DRAWING_COPY_CONTEXT_KEY, plan);
|
|
1165
|
+
return plan;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1041
1168
|
//#endregion
|
|
1042
1169
|
//#region src/utils/get-image-shape-key.ts
|
|
1043
1170
|
function getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }, index) {
|
|
@@ -1064,4 +1191,30 @@ const getImageSize = async (src) => {
|
|
|
1064
1191
|
};
|
|
1065
1192
|
|
|
1066
1193
|
//#endregion
|
|
1067
|
-
|
|
1194
|
+
//#region src/utils/rotate-enabled.ts
|
|
1195
|
+
function getDrawingKey(drawing) {
|
|
1196
|
+
return `${drawing.unitId}\u0000${drawing.subUnitId}\u0000${drawing.drawingId}`;
|
|
1197
|
+
}
|
|
1198
|
+
function resolveDrawingRotateEnabled(drawing, options = {}, visiting = /* @__PURE__ */ new Set()) {
|
|
1199
|
+
var _drawing$transform, _options$getRenderObj, _options$isKnownNonRo;
|
|
1200
|
+
const drawingKey = getDrawingKey(drawing);
|
|
1201
|
+
if (visiting.has(drawingKey)) return true;
|
|
1202
|
+
if (drawing.drawingType === DrawingTypeEnum.DRAWING_GROUP) {
|
|
1203
|
+
var _options$getChildren;
|
|
1204
|
+
visiting.add(drawingKey);
|
|
1205
|
+
const children = (_options$getChildren = options.getChildren) === null || _options$getChildren === void 0 ? void 0 : _options$getChildren.call(options, drawing);
|
|
1206
|
+
if (children != null) {
|
|
1207
|
+
const enabled = children.every((child) => resolveDrawingRotateEnabled(child, options, visiting));
|
|
1208
|
+
visiting.delete(drawingKey);
|
|
1209
|
+
return enabled;
|
|
1210
|
+
}
|
|
1211
|
+
visiting.delete(drawingKey);
|
|
1212
|
+
}
|
|
1213
|
+
if (((_drawing$transform = drawing.transform) === null || _drawing$transform === void 0 ? void 0 : _drawing$transform.rotateEnabled) === false) return false;
|
|
1214
|
+
if (((_options$getRenderObj = options.getRenderObject) === null || _options$getRenderObj === void 0 || (_options$getRenderObj = _options$getRenderObj.call(options, drawing)) === null || _options$getRenderObj === void 0 || (_options$getRenderObj = _options$getRenderObj.transformerConfig) === null || _options$getRenderObj === void 0 ? void 0 : _options$getRenderObj.rotateEnabled) === false) return false;
|
|
1215
|
+
if ((_options$isKnownNonRo = options.isKnownNonRotatableType) === null || _options$isKnownNonRo === void 0 ? void 0 : _options$isKnownNonRo.call(options, drawing.drawingType)) return false;
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
//#endregion
|
|
1220
|
+
export { DRAWING_COPY_CONTEXT_KEY, DRAWING_GROUPABLE_TYPES, DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, DrawingManagerService, IDrawingManagerService, ImageIoService, SetDrawingSelectedOperation, URLImageService, UnitDrawingService, UniverDrawingPlugin, createDrawingCopyPlan, getDrawingImageAllowSize, getDrawingShapeKeyByDrawingSearch, getImageSize, getOrCreateDrawingCopyPlan, isGroupableDrawingType, resolveDrawingRotateEnabled };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -24,7 +24,9 @@ export type { IDrawingGroupUpdateParam, IDrawingMap, IDrawingMapItem, IDrawingMa
|
|
|
24
24
|
export { IDrawingManagerService } from './services/drawing-manager.service';
|
|
25
25
|
export { ImageIoService } from './services/image-io-impl.service';
|
|
26
26
|
export { URLImageService } from './services/url-image.service';
|
|
27
|
+
export { createDrawingCopyPlan, DRAWING_COPY_CONTEXT_KEY, DRAWING_GROUPABLE_TYPES, getOrCreateDrawingCopyPlan, isGroupableDrawingType } from './utils/drawing-group';
|
|
28
|
+
export type { ICreateDrawingCopyPlanOptions, IDrawingCopyPlan } from './utils/drawing-group';
|
|
27
29
|
export { getDrawingShapeKeyByDrawingSearch } from './utils/get-image-shape-key';
|
|
28
30
|
export { getImageSize } from './utils/get-image-size';
|
|
29
|
-
export {
|
|
30
|
-
export type {
|
|
31
|
+
export { resolveDrawingRotateEnabled } from './utils/rotate-enabled';
|
|
32
|
+
export type { IDrawingRotateEnabledResolverOptions } from './utils/rotate-enabled';
|
|
@@ -80,6 +80,7 @@ export declare class UnitDrawingService<T extends IDrawingParam> implements IUni
|
|
|
80
80
|
setDrawingData(unitId: string, subUnitId: string, data: IDrawingMapItemData<T>): void;
|
|
81
81
|
getBatchAddOp(insertParams: T[]): IDrawingJsonUndo1;
|
|
82
82
|
getBatchRemoveOpInOder(removeParams: IDrawingSearch[]): IDrawingJsonUndo1;
|
|
83
|
+
private _getExpandedBatchRemoveParams;
|
|
83
84
|
getBatchRemoveOp(removeParams: IDrawingSearch[]): IDrawingJsonUndo1;
|
|
84
85
|
getBatchUpdateOp(updateParams: T[]): IDrawingJsonUndo1;
|
|
85
86
|
removeNotification(removeParams: IDrawingSearch[]): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { DrawingType, IDrawingParam } from '@univerjs/core';
|
|
17
|
+
import { DrawingTypeEnum } from '@univerjs/core';
|
|
18
|
+
export declare const DRAWING_GROUPABLE_TYPES: readonly [DrawingTypeEnum.DRAWING_IMAGE, DrawingTypeEnum.DRAWING_SHAPE, DrawingTypeEnum.DRAWING_CHART, DrawingTypeEnum.DRAWING_GROUP];
|
|
19
|
+
export declare function isGroupableDrawingType(type: DrawingType): boolean;
|
|
20
|
+
export declare const DRAWING_COPY_CONTEXT_KEY = "univer.drawing.copy-plan";
|
|
21
|
+
export interface ICreateDrawingCopyPlanOptions {
|
|
22
|
+
unitId: string;
|
|
23
|
+
sourceSubUnitId: string;
|
|
24
|
+
targetSubUnitId: string;
|
|
25
|
+
generateId?: () => string;
|
|
26
|
+
}
|
|
27
|
+
export interface IDrawingCopyPlan<T extends IDrawingParam = IDrawingParam> {
|
|
28
|
+
idMap: Map<string, string>;
|
|
29
|
+
drawings: T[];
|
|
30
|
+
}
|
|
31
|
+
export declare function createDrawingCopyPlan<T extends IDrawingParam>(drawings: readonly T[], options: ICreateDrawingCopyPlanOptions): IDrawingCopyPlan<T>;
|
|
32
|
+
export declare function getOrCreateDrawingCopyPlan<T extends IDrawingParam>(copyContext: Map<string, unknown> | undefined, drawings: readonly T[], options: ICreateDrawingCopyPlanOptions): IDrawingCopyPlan<T>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { DrawingType, IDrawingParam } from '@univerjs/core';
|
|
17
|
+
interface IRotateRenderObject {
|
|
18
|
+
transformerConfig?: {
|
|
19
|
+
rotateEnabled?: boolean;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface IDrawingRotateEnabledResolverOptions {
|
|
23
|
+
getChildren?: (drawing: IDrawingParam) => readonly IDrawingParam[] | null | undefined;
|
|
24
|
+
getRenderObject?: (drawing: IDrawingParam) => IRotateRenderObject | null | undefined;
|
|
25
|
+
isKnownNonRotatableType?: (drawingType: DrawingType) => boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function resolveDrawingRotateEnabled(drawing: IDrawingParam, options?: IDrawingRotateEnabledResolverOptions, visiting?: Set<string>): boolean;
|
|
28
|
+
export {};
|