Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variable xml generation, console warnings #251

Merged
merged 1 commit into from Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions blockly_compressed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion core/field.js
Expand Up @@ -819,9 +819,10 @@ Blockly.Field.prototype.getSize = function() {
if (this.isDirty_) {
this.render_();
this.isDirty_ = false;
} else if (this.visible_ && this.size_.width == 0) {
} else if (this.visible_ && this.size_.width == 0 && !this.sourceBlock_.isInsertionMarker_) {
// If the field is not visible the width will be 0 as well, one of the
// problems with the old system.
// pxt-blockly: field size will also be zero for insertion marker fields
console.warn('Deprecated use of setting size_.width to 0 to rerender a' +
' field. Set field.isDirty_ to true instead.');
this.render_();
Expand Down
9 changes: 9 additions & 0 deletions core/field_image.js
Expand Up @@ -59,6 +59,7 @@ Blockly.FieldImage = function(src, width, height,
if (typeof opt_onClick == 'function') {
this.clickHandler_ = opt_onClick;
this.EDITABLE = true;
this.SERIALIZABLE = true;
}
};
goog.inherits(Blockly.FieldImage, Blockly.Field);
Expand Down Expand Up @@ -90,6 +91,14 @@ Blockly.FieldImage.fromJson = function(options) {
*/
Blockly.FieldImage.prototype.EDITABLE = false;

/**
* * Serializable fields are saved by the XML renderer, non-serializable fields
* are not. Editable fields should also be serializable.
* @type {boolean}
* @const
*/
Blockly.FieldImage.prototype.SERIALIZABLE = false;

/**
* Used to tell if the field needs to be rendered the next time the block is
* rendered. Image fields are statically sized, and only need to be
Expand Down
3 changes: 2 additions & 1 deletion core/utils.js
Expand Up @@ -273,7 +273,8 @@ Blockly.utils.checkMessageReferences = function(message) {
for (var i = 0; i < m.length; i++) {
var msgKey = m[i].toUpperCase();
if (msgTable[msgKey.slice(6, -1)] == undefined) {
console.log('WARNING: No message string for ' + m[i] + ' in ' + message);
// pxt-blockly: ignore, we use custom localization
// console.log('WARNING: No message string for ' + m[i] + ' in ' + message);
validSoFar = false; // Continue to report other errors.
}
}
Expand Down
3 changes: 2 additions & 1 deletion core/xml.js
Expand Up @@ -48,7 +48,8 @@ goog.require('Blockly.utils.xml');
Blockly.Xml.workspaceToDom = function(workspace, opt_noId) {
var xml = Blockly.utils.xml.createElement('xml');
var variablesElement = Blockly.Xml.variablesToDom(
Blockly.Variables.allUsedVarModels(workspace));
// pxt-blockly: always output all variables
workspace.getAllVariables(workspace));
if (variablesElement.hasChildNodes()) {
xml.appendChild(variablesElement);
}
Expand Down
8 changes: 8 additions & 0 deletions typings/blockly.d.ts
Expand Up @@ -8576,6 +8576,14 @@ declare module Blockly {
*/
EDITABLE: boolean;

/**
* * Serializable fields are saved by the XML renderer, non-serializable fields
* are not. Editable fields should also be serializable.
* @type {boolean}
* @const
*/
SERIALIZABLE: boolean;

/**
* Used to tell if the field needs to be rendered the next time the block is
* rendered. Image fields are statically sized, and only need to be
Expand Down