# Using backpack to copy blocks from one Blockly node to another

**URL:** <https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566>\
**Category:** Share Your Projects\
**Created:** [3 November 2023 09:09 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566 "2023-11-03T09:09:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 November 2023 09:09 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/1 "2023-11-03T09:09:41Z")

</div>

I've just discovered that the Blocky node has a backpack facility

Backpacks are used in block coding environments to stash commonly used scripts and then reused in other projects.

I hadn't realised it was available in NR Blockly and therefore it can be used as workaround fom the in-ablilty to copy/paste blocks between nodes

To enable it - go into your config (or create one if not already got one)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bfb6a1ec8793bf7c92c1d1d45bee1ab7a1ce2cc8.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/758cca1caab20b3417589a6c973d4fe6fa6ef365.png)

Then to use it to copy something like a complicated function

![BackpackSmall](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c50672a329f516e3cdb9c4b5c3c93de2fcffefa5.gif)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [3 November 2023 10:59 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/2 "2023-11-03T10:59:32Z")

</div>

> [@cymplecy](#):
>
> I've just discovered that the Blocky node has a backpack facility

I had especially developed that feature for you two years ago, as a christmas gift. What a shame you only discovered it now...

Merry Christmas Simon 🎄 🎁 🍾

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 November 2023 11:03 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/3 "2023-11-03T11:03:11Z")

</div>

Thank you

Now if you could implement the copy/paste plugin for this Christmas , I'd be even more grateful

> <https://github.com/google/blockly-samples/tree/master/plugins/cross-tab-copy-paste>
>
> //github.com/google/blockly-samples/tree/master/plugins/cross-tab-copy-paste

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [3 November 2023 12:42 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/4 "2023-11-03T12:42:40Z")

</div>

> [@cymplecy](#):
>
> Now if you could implement the copy/paste plugin for this Christmas , I'd be even more grateful

You know from experience that I am always very busy during the Christmas period...  
But you are lucky, that I have holiday today and this was very easy to implement 🍾

See demo how to copy paste blocks between separate blockly nodes:

![blockly_copy_paste](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/554ce27de8a1c09bad13498808e1bdd0fa29ce68.gif)

Please install the "copy-paste" branch:

```auto
npm install bartbutenaers/node-red-contrib-blockly#copy-paste

```

Also a Happy Christmas for this year 🎄 🎁 🍾

P.S. Now quickly back to my wife her TODO list 🤫

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 November 2023 13:24 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/5 "2023-11-03T13:24:55Z")

</div>

Thank you very much 🙂

But that means I just wasted my whole morning on the backpack documentation!

Took me 5 attempts to get the gif down to \<4MB! 🙂

PS See github issue I raised today while your about 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 November 2023 18:04 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/6 "2023-11-03T18:04:54Z")

</div>

Unfortunately, clicking on expand button causes an error  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57488113eb63020a24938809dad2e11e24f13501.png)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [3 November 2023 22:21 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/7 "2023-11-03T22:21:59Z")

</div>

Oeps, please contact the head of the QA department of the blockly node for fast support.

Meanwhile I have registered an [issue](https://github.com/google/blockly-samples/issues/2058). Hopefully they can offer soon a `dispose` function to cleanup.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 November 2023 08:50 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/8 "2023-11-04T08:50:43Z")

</div>

@cymplecy,  
I have added a temporary fix on the copy-paste branch.  
In the Blockly issue I have also shared my code, which needs to be implemented in the plugin as a `dispose` function. As soon as the Blockly team has released that, all our plugins have a dispose function and we are done. To be continued...

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [4 November 2023 09:29 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/9 "2023-11-04T09:29:24Z")

</div>

Works now thank you 🙂

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [6 November 2023 20:37 UTC](https://discourse.nodered.org/t/using-backpack-to-copy-blocks-from-one-blockly-node-to-another/82566/10 "2023-11-06T20:37:01Z")

</div>

> [@BartButenaers](#):
>
> In the Blockly issue I have also shared my code, which needs to be implemented in the plugin as a `dispose` function. As soon as the Blockly team has released that, all our plugins have a dispose function and we are done. To be continued...

For anybody following this discussion.  
I have created a [pull request](https://github.com/google/blockly-samples/pull/2061) to add a `dispose` function to the Blockly copy-paste plugin.
