Commit 4fa3dd80 authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Merge branch '4-create-in-blockly-a-multiline-text-block' into 'develop'

Resolve "Create in Blockly a multiline text block"

See merge request !2
parents f6a9dd61 cc1400a4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49,3 +49,4 @@ src/assets/config/config.prod.json
src/assets/config/config.theming.json
/src/assets/config/theming.scss
/.angular
/.tmp/
+4 −2
Original line number Diff line number Diff line
@@ -129,7 +129,9 @@
          
  
            <category name="Text" colour="160">    
                              
              <block type="literal_text"></block>   
              <block type="literal_text_multiline"></block>    
              <block type="variable_declare_string"></block>  
              <block type="variable_get_string"></block>  
              <block type="variable_set_string"></block>  
+8 −1
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ export class ServiceRuleDesignComponent implements OnInit {

      this.workspace = Blockly.inject('blocklyDiv', {
        toolbox: document.getElementById('toolbox'),
        theme: Blockly.Themes.Halloween,
        trashcan: true,
        scrollbars: true
      });
@@ -601,6 +602,12 @@ export class ServiceRuleDesignComponent implements OnInit {
      // workspace.registerToolboxCategoryCallback( 'SPECCHARVARIABLES_BOOL', this.charvarsBool);
      // workspace.registerToolboxCategoryCallback( 'SPECCHARVARIABLES_SET', this.charvarsSet);
      
      Blockly.Java['literal_text_multiline'] = function(block: { getFieldValue: (arg0: string) => any; }) {
        // Text value.
        var code = '"""\n' +  block.getFieldValue('TEXT') + '\n"""\n';

        return [code, Blockly.Java.ORDER_ATOMIC];
      };
      
  
      Blockly.Java['changecharacteristicvalue'] = function (block: any) {
+5 −0
Original line number Diff line number Diff line
@@ -2108,6 +2108,11 @@ Blockly.Java['lists_getSublist'] = function(block: { getFieldValue: (arg0: strin



    
    



Blockly.Java['literal_text'] = function(block: { getFieldValue: (arg0: string) => any; }) {
  // Text value.
  var code = Blockly.Java.quote_(block.getFieldValue('TEXT'));
+38 −1
Original line number Diff line number Diff line
@@ -42,8 +42,45 @@ Blockly.defineBlocksWithJsonArray([
    }
  ]);

  /*************************************************************************** 
  *
  *   Text RELATED
  * 
  ****************************************************************************/

  Blockly.Blocks['literal_text_multiline'] = {
    /**
     * Block for text value.
     * @this Blockly.Block
     */
    init: function() {
  
      var bff = new Blockly.FieldMultilineInput('');
      bff.maxLines_ = 15;
  
      this.appendDummyInput()
          .appendField(this.newQuote_(true))
          .appendField( bff, 'TEXT')
          .appendField(this.newQuote_(false));
      this.setOutput(true, 'String');
      this.setColour(180);
      this.setTooltip("A multi-line text input");
    },
    /**
     * Create an image of an open or closed quote.
     * @param {boolean} open True if open quote, false if closed.
     * @return {!Blockly.FieldImage} The field image of the quote.
     * @private
     */
    newQuote_: function(open) {
      if (open == Blockly.RTL) {
        var file = 'quote1.png';
      } else {
        var file = 'quote0.png';
      }
      return new Blockly.FieldImage(Blockly.pathToMedia + file, 12, 12, '"');
    }
  };
  
  /*************************************************************************** 
  *
Loading