Skip to content

Commit c0e57e9

Browse files
committed
fix: duplicate now works in spatial view
1 parent 692468f commit c0e57e9

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

products/app/src/views/spatial/MicrocosmSpatialView.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,20 @@ const handleCreateNode = async () => {
288288
}
289289
290290
// Handler for entity duplication with overlap prevention
291-
const handleDuplicateEntity = async (entity: Entity) => {
292-
if (EntitySchema.utils.isType(entity, 'html')) {
293-
const htmlData = entity.data as Extract<Entity['data'], { type: 'html' }>
291+
const handleDuplicateEntity = async (entityOrData: Entity | Entity['data']) => {
292+
// Handle case where HTMLEntity component passes entity.data directly
293+
let entityData: Entity['data']
294+
295+
if ('data' in entityOrData) {
296+
// Full entity object
297+
entityData = entityOrData.data
298+
} else {
299+
// Just entity data
300+
entityData = entityOrData
301+
}
302+
303+
if (entityData.type === 'html') {
304+
const htmlData = entityData as Extract<Entity['data'], { type: 'html' }>
294305
295306
// Try to place the duplicate near the original with some offset
296307
const preferredPosition = {
@@ -313,8 +324,8 @@ const handleDuplicateEntity = async (entity: Entity) => {
313324
x: position.x,
314325
y: position.y
315326
})
316-
} else if (EntitySchema.utils.isType(entity, 'emoji')) {
317-
const emojiData = entity.data as Extract<Entity['data'], { type: 'emoji' }>
327+
} else if (entityData.type === 'emoji') {
328+
const emojiData = entityData as Extract<Entity['data'], { type: 'emoji' }>
318329
319330
// For emoji nodes, place them near the original
320331
const preferredPosition = {

0 commit comments

Comments
 (0)