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