fix: pasting/dropping image issues

pull/7248/head
Peng Xiao 2022-11-08 16:07:09 +08:00 committed by Tienson Qin
parent c3611ef77c
commit 1d9b3e7d17
1 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,4 @@
import {
BoundsUtils,
getSizeFromSrc,
isNonNullable,
TLAsset,
@ -174,6 +173,7 @@ export function usePaste() {
asset.type === 'video' ? VideoShape.defaultProps : ImageShape.defaultProps
const newShape = {
...defaultProps,
id: uniqueId(),
// TODO: Should be place near the last edited shape
assetId: asset.id,
opacity: 1,
@ -372,8 +372,9 @@ export function usePaste() {
})
app.wrapUpdate(() => {
if (assetsToClone.length > 0) {
app.createAssets(assetsToClone)
const allAssets = [...imageAssetsToCreate, ...assetsToClone]
if (allAssets.length > 0) {
app.createAssets(allAssets)
}
if (newShapes.length > 0) {
app.createShapes(newShapes)
@ -389,6 +390,10 @@ export function usePaste() {
app.setSelectedShapes(allShapesToAdd.map(s => s.id))
app.selectedTool.transition('idle') // clears possible editing states
app.cursors.setCursor(TLCursor.Default)
if (fromDrop) {
app.packIntoRectangle()
}
})
},
[]