ribrdb / desynced-tools

Tools for working with behaviors and blueprints from Desynced.
MIT License
4 stars 3 forks source link

Don't clear editor contents when writing to clipboard fails #62

Closed swazrgb closed 5 months ago

swazrgb commented 5 months ago

Instead present behavior string via a prompt dialogue where the user can copy it

swazrgb commented 5 months ago

Due to the async usage in the onclick method the user may interact with the page prior to the async block finishing, which has the effect of the browser not allowing us to set the clipboard.

Previously the text input would then be replaced with the behavior string. As a new user, this confused me a lot since it felt like I'd lose the behavior typescript I was working on.

My other PR has reduced the async in the onclick method which reduces the chance of this happening, but it can still happen. Personally I vastly prefer the prompt in case writing to the clipboard fails.

Somewhat related, in a future PR I'd like to move the compilation to the background, so we try to compile periodically as the user is typing, so the errors can be displayed inline as they are working on the behavior.

A benefit of doing this is that the export button can become non-async, simply copying the behavior string of the already compiled behavior to the clipboard.

ribrdb commented 5 months ago

Somewhat related, in a future PR I'd like to move the compilation to the background, so we try to compile periodically as the user is typing, so the errors can be displayed inline as they are working on the behavior.

Good idea!