Add optional data property to blocks and XML.

This commit is contained in:
Neil Fraser
2015-02-24 17:07:47 -08:00
parent 1e88c35a0a
commit aed4d8f5d4
2 changed files with 16 additions and 4 deletions

View File

@@ -95,6 +95,13 @@ Blockly.Xml.blockToDom_ = function(block) {
element.appendChild(commentElement);
}
if (block.data) {
// Optional text data that round-trips beween blocks and XML.
// Has no effect. May be used by 3rd parties for meta information.
var dataElement = goog.dom.createDom('data', null, block.data);
element.appendChild(dataElement);
}
var hasValues = false;
for (var i = 0, input; input = block.inputList[i]; i++) {
var container;
@@ -357,6 +364,11 @@ Blockly.Xml.domToBlockHeadless_ =
block.comment.setBubbleSize(bubbleW, bubbleH);
}
break;
case 'data':
// Optional text data that round-trips beween blocks and XML.
// Has no effect. May be used by 3rd parties for meta information.
block.data = xmlChild.textContent;
break;
case 'title':
// Titles were renamed to field in December 2013.
// Fall through.