-
Notifications
You must be signed in to change notification settings - Fork 418
New addon: Copy scratchblocks text from editor #7748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
New addon: Copy scratchblocks text from editor #7748
Conversation
|
@TheColaber Do you know how to fix the bugs mentioned in this PR? |
|
i am not familiar with this library, maybe @apple502j can help since they made it. otherwise, the best solution to make a library that converts ScratchBlocks to bbcode. |
|
I think the right way to implement this is to serialize the sprite to JSON, then pass the result to the parse-sb3-blocks library. |
Maximouse and GarboMuffin save the day again!
…nhasapatch/ScratchAddons into editor-copy-scratchblocks
|
The library should be minified and stored in |
The parse-sb3-blocks library was already minified. When I uploaded it here the GitHub Actions code bot tried to format the entire minified file and slightly increased the file size. (Now fixed by moving it to The library is also very big because it contains the text for all blocks in every language Scratch supports. Blocks in languages other than English do not render correctly on the Discussion Forums and I could remove other languages from parse-sb3-blocks, but they might be useful for some people on Scratch Wiki or other places where scratchblocks is supported. |
|
Any more feedback? |
|
I'm not sure if these are bugs with the library but the stop block includes the text |
@Samq64 These are issues with the parse-sb3-blocks library. All Scratch blocks are defined in this block mapping: The addon does not work on loose reporter or boolean blocks. The library only supports square-shaped parent blocks, so you have to put other types of blocks inside an input to properly recognise them and get the block text. This should not affect complete scripts but I could make a workaround in the addon's code that fixes this. My addon just finds selected blocks in the Scratch editor and gives it to the library, the addon does not do the actual block-to-text conversion. |
|
May I ask if this process can be reversed, i.e., from Scratchblocks text to blocks? For example, the graphical kittenN editor similar to scratch, they can convert blocks and text, which is a very useful function. |
|
No, but there's an issue for that: #8573 |
Resolves #2336
Closes #7988
Changes
This addon adds a right-click option to blocks in the Scratch Project Editor to convert them into scratchblocks text pseudocode. It finds the JSON code of the selected blocks loaded in the Scratch editor and uses parse-sb3-blocks by @apple502j to convert them into scratchblocks text, then copies it to the user's clipboard for easy use on other websites or text editors.
Features:
< [] \> [] >andturn @turnRight (15) degrees::motionso your scratchblocks are always rendered correctly.[scratchblocks]around generated text to easily paste it on Discussion Forums or Scratch Wiki.Reason for changes
It would be convenient for users to be able to copy and paste blocks from the Project Editor in places where only scratchblocks text is supported, like the Scratch Forums using BBCode tags or Scratch Wiki pages using the Block Plugin. There is also the scratchblocks playground for testing the output with 2.0 and 3.0 style blocks in different languages.
Tests
Tested on latest Chromium with Scratch Addons v1.39.0-pre and v1.40.0-pre.
Download addon fork - Installation instructions
Known issues:
Block input serialization errors(resolved)