One feature that would be really handy is the ability to copy and paste Scratch blocks. At the moment (Scratch 2.0), you can already do this in some ways:
The last item there is similar to what I'm suggesting - copying actual block data to the system clipboard.
It's better than using the backpack, because:
I'm thinking it shouldn't be very difficult to implement this. Here's a quick code mockup:
// When a script, block, etc. is created:
// 'copy' is probably localized to 'Copy to clipboard'
block.contextMenu.addItem('copy', function() {
// This function doesn't exist with this name, of course. I'm not entirely certain what
// the exact code to copy is but it's possible and has been done on many sites
// and web applications before.
// Also, I don't know what the name of the function to convert a script to JSON is,
// so I'm using "serialize" :)
// I'm also assuming there's a "duplicate" method on blocks that behaves however
// we want duplicating scripts to be have, (copy child blocks, blocks below, etc.)
// Could probably name this method better but it's for the demo :)
copyToBrowserClipboard(block.duplicate().serialize())
})
The trouble is pasting. There are a couple of ways we could do this:
The nice thing about using a prompt is that it can be a custom dialog - for example, before a block is _actually_ pasted into the workspace, you might be able to see a picture of the block in the dialog. It can be triggered via context menu, or by listening for a Command/Control-V press.
Mockup code for prompt:
function pastePrompt() {
const prompt = makePastePrompt()
prompt.addEventListener('done', function() {
workspace.addScript(prompt.value) // see below section, "things to consider"
})
}
workspace.contextMenu.addItem('paste', pastePrompt)
workspace.addEventListener('key', function(key) {
// isCombo is a fake function here that will check if a key press is the right character,
// has the right modifiers (command/control), etc. for mockup
if (isCombo(key, 'Command+V')) {
pastePrompt()
}
})
Things to consider:
I guess this is getting kind of long.. that's all I have for this suggestion! What should be changed? (Probably the title of this issue.. maybe it would better fit as a "design" issue.)
edit: this could probably work with sprites, as well, but I'm not sure how to save costumes or sounds - maybe as data URIs? But those have length limits..
+1 -- I've spent a lot of time switching between projects to collect stuff into my backpack. This way I could just open the other projects in a new tab, copy the blocks I need, and paste them into my WIP project without navigating away from it
It's on our radar! In fact we already seem to support copy and paste within one page, it's just not well-exposed (hit control/command-C after clicking on a block, and then control-V).
Maybe there would be a placeholder block that you drag somewhere and a dialog pops up. Then, when you submit it, it'll replace that placeholder block with the copied scripts.
Also, are you able to adapt this for Scratch 2.0 mods?
Maybe have it stored in the scratchblocks format?
It would be slightly more complicated to implement, but it would make it very simple to copy things to/from the forums and wikis.
Trouble is, if the ST decides to make some huge thing like custom reporters _that have an entire new grammar_, they kind of have to _wait_ for @tjvr to update scratchblocks before they can publish the new feature, or else the whole "you can use 'copy' to copy Scratch blocks into the forums!" feature doesn't work.
So I don't think that would be particularly convenient. Maybe it would be better if there was an update to the scratchblocks generator that took sb3/JSON input instead of a project URL?
Might it be possible to accept multiple different inputs when pasting, so scratchblocks would be available, but not required as the sole interchange format?
I love this idea! Desmos does something similiar when copy & pasting:

Perhaps something could be learned from how it's done there?
@PullJosh Ironically, that's got nothing to do with clipboard-jacking - that's just the LaTex code it uses for rendering! :ghost:
Quoting @thisandagain from here:
Because in Scratch blocks execute on click, we don't have a "selection state" which makes implementing something like copy/paste require some design effort. Leaving this open as a feature request, but it's likely not something we'll get to in the short term.
Most helpful comment
I love this idea! Desmos does something similiar when copy & pasting:

Perhaps something could be learned from how it's done there?