webr icon indicating copy to clipboard operation
webr copied to clipboard

Consider adding "Share" feature to webR REPL

Open coatless opened this issue 5 months ago • 3 comments

It would be the bee's knees for demo purposes if the webR REPL editor could receive the "Share" feature that the shinylive editor has. Perhaps add it next to the save button in the editor?

Mockup of the webR REPL environment with a 'share' button present

I think this could be taken out from the ShareModal.tsx (for the popup), share.ts (for encoding), and App.tsx (for loading)

  • https://github.com/posit-dev/shinylive/blob/a941a51e364a8f12ecd6072e48a144e06b2230b2/src/Components/ShareModal.tsx
  • https://github.com/posit-dev/shinylive/blob/a941a51e364a8f12ecd6072e48a144e06b2230b2/src/Components/ShareModal.css
  • https://github.com/posit-dev/shinylive/blob/a941a51e364a8f12ecd6072e48a144e06b2230b2/src/Components/share.ts
  • https://github.com/posit-dev/shinylive/blob/a941a51e364a8f12ecd6072e48a144e06b2230b2/src/Components/App.tsx#L311-L320

Happy to try my hand at this given the other awesome work going on.

coatless avatar Jan 27 '24 10:01 coatless

@coatless I've made something like that here, it's my attempt at a minimal IDE + embedded BI component.

I'm doing it all in R/Shiny though! Depending on when you look at this link I've been sharing in 2 ways currently, 1) sketchy way POST json object to API with a base64 encoded string + md5 hash of that string (how I currently do it). This is good in that it allows for very large strings of code, but bad in that my API could be abused in its current state. 2) Don't POST anything just use the base64 encoded string... should be good for well over 1000 lines of code (what I'm going to do now).

A delayed copy of the source code can be found here. Working on transitioning from a mostly closed source github to an open source one, so sorry for the delay.

seanbirchall avatar Jan 31 '24 19:01 seanbirchall

Hi @coatless,

I agree, this would be a great feature to have. Another thing that the shinylive editor is able to do that would be useful here is interacting with the GitHub API and loading code via a gist ID encoded in the URL - see, for example, https://shinylive.io/py/editor/#gist=e62218aa28bf26e785fc6cb99efe8efe

Yes, do feel free to work on this and submit a PR, if you'd like.

georgestagg avatar Feb 01 '24 09:02 georgestagg

@seanbirchall nice work on the shiny app & deploying via shinylive! Cool to see an IDE created in Shiny!

@georgestagg okidokie; I'll probably send over a PR this weekend. (I may also port in the resize window feature as well 😄 )

coatless avatar Feb 01 '24 20:02 coatless