Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Blockly.Events.fire(new Blockly.Events.Change(
this.sourceBlock_, 'field', this.name, oldValue, newValue));
}
}
manageEvent();
if (noGroup) {
Blockly.Events.setGroup(false);
}
};
/**
* By default there is no difference between the human-readable text and
* the language-neutral values. Subclasses (such as dropdown) may define this.
* @param {string} newText New text.
*/
Blockly.Field.prototype.setValue = function(newText) {
if (newText === null) {
// No change if null.
return;
}
var oldText = this.getValue();
if (oldText == newText) {
return;
}
var that = this;
this.fieldHasChanged(oldText, newText, function() {
that.setText(newText);
});
};
/**
* Set the checkbox to be checked if strBool is 'TRUE', unchecks otherwise.
*/
var FieldTable = function(data, opt_extraColumns, hideHeaders) {
FieldTable.constructor.call(this, '');
// Set the initial state.
// this.setValue(json);
this.width_ = 0;
this.height_ = 0;
this.size_ = { width: this.width_, height: this.height_ };
this.data_ = data;
this.extraColumns_ = opt_extraColumns ? opt_extraColumns : {
varNames: [],
mappings: {}
};
this.showHeaders = !hideHeaders;
};
FieldTable.prototype = Object.create(Blockly.Field.prototype);
FieldTable.prototype.constructor = FieldTable;
FieldTable.NO_PATTERN = 0;
FieldTable.CLASS_PATTERN = 1;
FieldTable.PROPERTY_PATTERN = 2;
FieldTable.PATTERN_LABEL = 'pattern';
/**
* Editable fields are saved by the XML renderer, non-editable fields are not.
*/
FieldTable.prototype.EDITABLE = false;
FieldTable.prototype.setEventBindingsForBlock_ = function(block) {
if (block) {
var root = block.getSvgRoot();
Blockly.FieldVariable.prototype.dispose = function() {
var varName = this.getValue();
var block = this.sourceBlock_;
var workspace = this.workspace_;
Blockly.Field.prototype.dispose.call(this);
this.workspace_ = null;
var defaultVarNames = workspace && defaultVarNamesByWorkspace[workspace];
if (block && varName && workspace
&& defaultVarNames
&& defaultVarNames.indexOf(varName) != -1
&& workspace.getVariableUses(varName).length == 0) {
workspace.deleteVariable(varName);
}
};
}
morphShadowRec(this);
}
manageEvent();
if (noGroup) {
Blockly.Events.setGroup(false);
}
};
/**
* When a field changes, generate event and manage shadow state.
* @param {Object} oldValue The old field value
* @param {Object} newValue The new field value
* @protected
*/
Blockly.Field.prototype.fieldHasChanged = function(oldValue, newValue, manageEvent) {
var noGroup = false;
if (this.sourceBlock_) {
if (true /*this.sourceBlock_.workspace.options.shadowMorphEnabled*/ &&
Blockly.Events.recordUndo) {
if (Blockly.Events.isEnabled()) {
noGroup = true; //!Blockly.Events.getGroup();
if (noGroup) {
Blockly.Events.setGroup(true);
}
}
morphShadowRec(this.sourceBlock_);
}
if (Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.Change(
this.sourceBlock_, 'field', this.name, oldValue, newValue));
}