diff --git a/Changelog.md b/Changelog.md index f0fc2ef..a71dacb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,8 @@ +# 0.7.7-alpha: +Bugfixes: +- Fix pasting multiple times +- Hack around broken files + # 0.7.6-alpha: Bugfixes: - Fix errors when images are not present in a saved file diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index d2aee76..59cf689 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Lightningbeam", - "version": "0.7.6-alpha", + "version": "0.7.7-alpha", "identifier": "org.lightningbeam.core", "build": { "frontendDist": "../src" diff --git a/src/main.js b/src/main.js index 710be1b..878a09d 100644 --- a/src/main.js +++ b/src/main.js @@ -705,8 +705,32 @@ let actions = { duplicateObject: { create: (items) => { redoStack.length = 0; + function deepCopyWithIdxMapping(obj, dictionary = {}) { + if (Array.isArray(obj)) { + return obj.map(item => deepCopyWithIdxMapping(item, dictionary)); + } + if (obj === null || typeof obj !== 'object') { + return obj; + } + + const newObj = {}; + for (const key in obj) { + let value = obj[key]; + + if (key === 'idx' && !(value in dictionary)) { + dictionary[value] = uuidv4(); + } + + newObj[key] = value in dictionary ? dictionary[value] : value; + if (typeof newObj[key] === 'object' && newObj[key] !== null) { + newObj[key] = deepCopyWithIdxMapping(newObj[key], dictionary); + } + } + + return newObj; + } let action = { - items: items, + items: deepCopyWithIdxMapping(items), object: context.activeObject.idx, frame: context.activeObject.currentFrame.idx, uuid: uuidv4(), @@ -2940,7 +2964,7 @@ class BaseShape { // } if (this.filled) { ctx.beginPath(); - if (this.fillImage) { + if (this.fillImage && this.fillImage instanceof Element) { let pat; if (this.fillImage instanceof Element || Object.keys(this.fillImage).length !== 0) { @@ -3315,7 +3339,11 @@ class Shape extends BaseShape { // } newShape.updateVertices(); newShape.fillStyle = this.fillStyle; - newShape.fillImage = this.fillImage; + if (this.fillImage instanceof Element) { + newShape.fillImage = this.fillImage.cloneNode(true) + } else { + newShape.fillImage = this.fillImage; + } newShape.strokeStyle = this.strokeStyle; newShape.lineWidth = this.lineWidth; newShape.filled = this.filled;