microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
711 stars 589 forks source link

Magic URL to open a project directly in a text based editor(JavaScript or Python) #5398

Closed Vegz78 closed 7 months ago

Vegz78 commented 10 months ago

Is your feature request related to a problem? Please describe. It would be nice sometimes, even for block based projects, to be able to open shared projects directly in a text based editor(JavaScript or Python).

Describe the solution you'd like I'd like to be able to make a link that opens a shared project directly in a text based editor using a custom magic URL, maybe like this: https://makecode.microbit.org/_YTbKYAAimAxz#JavaScript

Describe alternatives you've considered I have found no alternatives.

Additional context The feature has been discussed on the forum: https://forum.makecode.com/t/editor-magic-url-flags/10743/5?u=vegz78

microbit-carlos commented 10 months ago

If the project is shared when the code view is opened, the preview and the editable project should open in the same view.

For example, by resharing that project in the javascript view, it generates a link where the default view is javascript: https://makecode.microbit.org/_gJof4qbXLK2C

I believe this is controlled via the preferredEditor key in pxt.json, which changes every time you change between code and blocks:

image
abchatra commented 7 months ago

There is a way to generate text based URL using a project which is a text based project.

image
Vegz78 commented 7 months ago

@abchatra: Your answer does not really apply, since the problem at hand was to share a regular project with blocks(Blocks, JavaScript and Python) in the JavaScript or Python editor "view", not to make it a "JavaScript only" project.

However, @microbit-carlos' solution does apply, thank you for the explanation! Never thought it was that easy and already supported, hehe...