elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.49k stars 1.2k forks source link

JS Activity Beautifier #2424

Open jwillmer opened 3 years ago

jwillmer commented 3 years ago

I like to have a button to beautify my JS code.

@SipkeSchoorstraRTL Maybe an option to beautify on enter (if no errors are detected)?

tomy2105 commented 3 years ago

May I add one idea to this one..... Every expression (if activity allows) can be changed to be Javascript expression. And inside this expressions one might write complex JS (closures, etc, as long at it returns value of good type). However this is hard to do since editor is single line only. Would be nice to have some ability to extend editor area if you need such complex expressions. And add ability to beautify it as well, not just to JS Activity, but all JS Expressions.

jwillmer commented 3 years ago

yes, agree. Should be implemented in the js editor that is used by all activities. And a switch to JS expression should increase the input field / let the user increase it.

jeremycook commented 3 years ago

FYI:

  1. Right click in editor and select "Format Document"
  2. ALT+SHIFT+F will format the document
  3. editor.getAction('editor.action.formatDocument').run() will format the document
  4. The Monaco editor supports two reactive autoformatting options as demonstrated below.
monaco.editor.create(document.getElementById("container"), {
    value: "function hello() {\n\talert('Hello world!');\n}",
    language: "javascript",
    formatOnType: true,
    formatOnPaste: true
});

Try at: https://microsoft.github.io/monaco-editor/playground.html