Skip to content

Commit

Permalink
Merge pull request #25 from pihart/master
Browse files Browse the repository at this point in the history
Fix #23
  • Loading branch information
cjquines committed Oct 9, 2020
2 parents b174710 + 15ac085 commit a2b840c
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/lib/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export class ClipboardHandler {
clipboard: fabric.Object;

constructor(
public canvas: Page,
public history: HistoryHandler,
public canvasWidth: number,
public canvasHeight: number
public canvas: Page,
public history: HistoryHandler,
public canvasWidth: number,
public canvasHeight: number
) {
window.addEventListener("paste", this.pasteExternal);
}
Expand Down Expand Up @@ -63,29 +63,29 @@ export class ClipboardHandler {
placeObject = async (obj: any): Promise<void> => {
const { x, y } = this.canvas.cursor;
this.canvas.discardActiveObject();
await this.canvas.getNextId().then((id) => {
obj.set({
id,
left: x,
top: y,
originX: "center",
originY: "center",
});
if (obj._objects) {
obj.canvas = this.canvas;
await obj.forEachObject((object) => {
this.canvas.getNextId().then((id) => {
object.id = id;
this.canvas.add(object);
});
});
obj.setCoords();
} else {
this.canvas.add(obj);
}
this.canvas.setActiveObject(obj);
await this.history.add(obj._objects || [obj]);
this.canvas.requestRenderAll();
const id = await this.canvas.getNextId();

obj.set({
id,
left: x,
top: y,
originX: "center",
originY: "center",
});
if (obj._objects) {
obj.canvas = this.canvas;
obj.forEachObject((object) => {
this.canvas.getNextId().then((id) => {
object.id = id;
this.canvas.add(object);
});
});
obj.setCoords();
} else {
this.canvas.add(obj);
}
this.canvas.setActiveObject(obj);
await this.history.add(obj._objects || [obj]);
this.canvas.requestRenderAll();
};
}

0 comments on commit a2b840c

Please sign in to comment.