Fix selected shapes shifting to canvas origin (#2729)
* Fix selected shapes shifting to canvas origin * Make only newly added shape selected even if it... ... overlaps with another
This commit is contained in:
parent
6c2205663e
commit
7cf19ea213
@ -36,6 +36,10 @@ export function exportShapesToClozeDeletions(occludeInactive: boolean): {
|
||||
*/
|
||||
function baseShapesFromFabric(occludeInactive: boolean): ShapeOrShapes[] {
|
||||
const canvas = globalThis.canvas as Canvas;
|
||||
|
||||
// Prevents multiple shapes in 'activeSelection' from shifting to the canvas origin
|
||||
canvas.discardActiveObject();
|
||||
|
||||
makeMaskTransparent(canvas, false);
|
||||
const objects = canvas.getObjects() as FabricObject[];
|
||||
return objects
|
||||
|
@ -115,6 +115,7 @@ export const drawEllipse = (canvas: fabric.Canvas): void => {
|
||||
}
|
||||
|
||||
ellipse.setCoords();
|
||||
canvas.setActiveObject(ellipse);
|
||||
undoStack.onObjectAdded(ellipse.id);
|
||||
});
|
||||
};
|
||||
|
@ -189,6 +189,7 @@ const generatePolygon = (canvas: fabric.Canvas, pointsList): void => {
|
||||
if (polygon.width > 5 && polygon.height > 5) {
|
||||
disableRotation(polygon);
|
||||
canvas.add(polygon);
|
||||
canvas.setActiveObject(polygon);
|
||||
// view undo redo tools
|
||||
undoStack.onObjectAdded(polygon.id);
|
||||
emitChangeSignal();
|
||||
|
@ -109,6 +109,7 @@ export const drawRectangle = (canvas: fabric.Canvas): void => {
|
||||
}
|
||||
|
||||
rect.setCoords();
|
||||
canvas.setActiveObject(rect);
|
||||
undoStack.onObjectAdded(rect.id);
|
||||
});
|
||||
};
|
||||
|
@ -38,6 +38,7 @@ export const drawText = (canvas: fabric.Canvas): void => {
|
||||
disableRotation(text);
|
||||
enableUniformScaling(canvas, text);
|
||||
canvas.add(text);
|
||||
canvas.setActiveObject(text);
|
||||
undoStack.onObjectAdded(text.id);
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user