From cbedbc262f80661e15a6aec12a521dc2bcb449ba Mon Sep 17 00:00:00 2001 From: Cosmo Myzrail Gorynych Date: Thu, 19 Sep 2024 14:15:05 +1200 Subject: [PATCH] :bug: Fix not being able to copy multiple blocks in catnip --- src/node_requires/catnip/index.ts | 3 +++ src/riotTags/catnip/catnip-block-list.tag | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/node_requires/catnip/index.ts b/src/node_requires/catnip/index.ts index 114f9e70a..8f7ac9451 100644 --- a/src/node_requires/catnip/index.ts +++ b/src/node_requires/catnip/index.ts @@ -669,6 +669,9 @@ export const clearSelection = (): void => { multipleSelection.clear(); redrawSelectedBlocks(previouslySelected, previousMap); }; +export const copySelected = () => { + clipboard = structuredClone(getTopBlocks([...multipleSelection.keys()])); +}; export const getSelectionHTML = (): void => { const html = []; const dummy = document.createElement('catnip-block'); diff --git a/src/riotTags/catnip/catnip-block-list.tag b/src/riotTags/catnip/catnip-block-list.tag index 8abc415e9..3d55a404f 100644 --- a/src/riotTags/catnip/catnip-block-list.tag +++ b/src/riotTags/catnip/catnip-block-list.tag @@ -48,7 +48,7 @@ catnip-block-list( this.namespace = 'catnip'; this.mixin(require('src/node_requires/riotMixins/voc').default); - const {getDeclaration, getMenuMutators, mutate, startBlocksTransmit, endBlocksTransmit, getTransmissionType, getSuggestedTarget, setSuggestedTarget, emptyTexture, copy, canPaste, paste, setSelection, toggleSelection, getSelectionHTML, isSelected, removeSelectedBlocks} = require('src/node_requires/catnip'); + const {getDeclaration, getMenuMutators, mutate, startBlocksTransmit, endBlocksTransmit, getTransmissionType, getSuggestedTarget, setSuggestedTarget, emptyTexture, copySelected, canPaste, paste, setSelection, toggleSelection, getSelectionHTML, isSelected, removeSelectedBlocks} = require('src/node_requires/catnip'); const {isDev} = require('src/node_requires/platformUtils'); this.getSuggestedTarget = getSuggestedTarget; @@ -149,7 +149,7 @@ catnip-block-list( label: this.voc.copySelection, icon: 'copy', click: () => { - copy([this.contextBlock]); + copySelected(); this.contextBlock = false; this.update(); }