You are reading a single comment by @JumJum and its replies. Click here to read the full conversation.
  • @neshanjo
    A simple example how to add a formatter.
    I used beautifier, because its so easy to add.
    And it does not need an internet connection.
    Steps:

    • add a file to js/plugins with following code
    • add a script tag in main.html to the new plugin
    • add beautify folder in js/libs
    • add beautify-file from github into this new folder
    • add script tag in main.html to beautify-file

      "use strict";
      (function(){
      var iconFolder;
      function init() {
        showIcon();
      }
      function showIcon(){
        iconFolder = Espruino.Core.App.addIcon({
          id: 'formatCode',icon: 'snippets',title: 'Prettyfie',order: 510,
          area: { name: "code",position: "top"},
          click: prettyfie
       });
      }
      function prettyfie(){
         var code = Espruino.Core.EditorJavaScript.getCode()­;
         code = js_beautify(code);
         Espruino.Core.EditorJavaScript.setCode(c­ode);
      }
      Espruino.Plugins.FormatCode = {
        init : init,  
      };
      }());
      
      

      ```

About

Avatar for JumJum @JumJum started