mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Changed multiline field to use new configuration (#3044)
* Changed multilineinput field to new configuration.
This commit is contained in:
committed by
Sam El-Husseini
parent
093467aed1
commit
a8a8c320d5
@@ -46,15 +46,20 @@ goog.require('Blockly.utils.userAgent');
|
||||
* to validate any constraints on what the user entered. Takes the new
|
||||
* text as an argument and returns either the accepted text, a replacement
|
||||
* text, or null to abort the change.
|
||||
* @param {Object=} opt_config A map of options used to configure the field.
|
||||
* See the [field creation documentation]{@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/text-input#creation}
|
||||
* for a list of properties this parameter supports.
|
||||
* @extends {Blockly.FieldTextInput}
|
||||
* @constructor
|
||||
*/
|
||||
Blockly.FieldMultilineInput = function(opt_value, opt_validator) {
|
||||
if (opt_value === null) {
|
||||
Blockly.FieldMultilineInput = function(opt_value, opt_validator, opt_config) {
|
||||
// TODO: Once this field is documented the opt_config link should point to its
|
||||
// creation documentation, rather than the text input field's.
|
||||
if (opt_value == null) {
|
||||
opt_value = '';
|
||||
}
|
||||
Blockly.FieldMultilineInput.superClass_.constructor.call(this,
|
||||
opt_value, opt_validator);
|
||||
opt_value, opt_validator, opt_config);
|
||||
};
|
||||
Blockly.utils.object.inherits(Blockly.FieldMultilineInput,
|
||||
Blockly.FieldTextInput);
|
||||
@@ -70,19 +75,14 @@ Blockly.FieldMultilineInput.LINE_HEIGHT = 20;
|
||||
/**
|
||||
* Construct a FieldMultilineInput from a JSON arg object,
|
||||
* dereferencing any string table references.
|
||||
* @param {!Object} options A JSON object with options (text, class, and
|
||||
* spellcheck).
|
||||
* @param {!Object} options A JSON object with options (text, and spellcheck).
|
||||
* @return {!Blockly.FieldMultilineInput} The new field instance.
|
||||
* @package
|
||||
* @nocollapse
|
||||
*/
|
||||
Blockly.FieldMultilineInput.fromJson = function(options) {
|
||||
var text = Blockly.utils.replaceMessageReferences(options['text']);
|
||||
var field = new Blockly.FieldMultilineInput(text);
|
||||
if (typeof options['spellcheck'] === 'boolean') {
|
||||
field.setSpellcheck(options['spellcheck']);
|
||||
}
|
||||
return field;
|
||||
return new Blockly.FieldMultilineInput(text, undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,8 +73,7 @@ Blockly.utils.object.inherits(Blockly.FieldTextInput, Blockly.Field);
|
||||
/**
|
||||
* Construct a FieldTextInput from a JSON arg object,
|
||||
* dereferencing any string table references.
|
||||
* @param {!Object} options A JSON object with options (text, class, and
|
||||
* spellcheck).
|
||||
* @param {!Object} options A JSON object with options (text, and spellcheck).
|
||||
* @return {!Blockly.FieldTextInput} The new field instance.
|
||||
* @package
|
||||
* @nocollapse
|
||||
|
||||
@@ -272,6 +272,19 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
|
||||
"tooltip": "",
|
||||
"helpUrl": ""
|
||||
},
|
||||
{
|
||||
"type": "test_fields_multilinetext",
|
||||
"message0": "code %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_multilinetext",
|
||||
"name": "CODE",
|
||||
"text": "default1\ndefault2"
|
||||
}
|
||||
],
|
||||
"style": "math_blocks",
|
||||
"tooltip": "test tooltip"
|
||||
},
|
||||
{
|
||||
"type": "test_fields_checkbox",
|
||||
"message0": "checkbox %1",
|
||||
|
||||
@@ -1435,6 +1435,7 @@ var spaghettiXml = [
|
||||
<block type="test_fields_colour"></block>
|
||||
<block type="test_fields_colour_options"></block>
|
||||
<block type="test_fields_text_input"></block>
|
||||
<block type="test_fields_multilinetext"></block>
|
||||
<block type="test_fields_variable"></block>
|
||||
<button text="randomize label text" callbackKey="randomizeLabelText"></button>
|
||||
<sep gap="12"></sep>
|
||||
|
||||
Reference in New Issue
Block a user