examples/javascript/example_block.js
function(){
      var dataObj = {};

      var content = this.getTextBlock().html();
      if (content.length > 0) {
        dataObj.text = SirTrevor.toMarkdown(content, this.type);
      }

      this.setData(dataObj);
    }
function(){
      var dataObj = {};

      var content = this.getTextBlock().html();
      if (content.length > 0) {
        dataObj.text = SirTrevor.toMarkdown(content, this.type);
      }

      this.setData(dataObj);
    }
function ( ) { var dataObj = { } ; var content = this . getTextBlock ( ) . html ( ) ; if ( content . length > 0 ) { dataObj . text = SirTrevor . toMarkdown ( content , this . type ) ; } this . setData ( dataObj ) ; }
Function; Executed on save of the block, once the block is validated toData expects a way for the block to be transformed from inputs into structured data The default toData function provides a pretty comprehensive way of turning data into JSON In this example we take the text data and save it to the data object on the block
Function ; Executed on save of the block once the block is validated toData expects a way for the block to be transformed from inputs into structured data The default toData function provides a pretty comprehensive way of turning data into JSON In this example we take the text data and save it to the data object on the block