summaryrefslogtreecommitdiff
path: root/byob.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-04-03 12:03:34 +0200
committerjmoenig <jens@moenig.org>2013-04-03 12:03:34 +0200
commit18821f7bc1807b6ae199e2c207a865439ee6167f (patch)
treeea996b1b5e634bca04f756bdc9f93fadb51d5e3f /byob.js
parent4804d8cfc82ecaad3e0906090994f6e804243b01 (diff)
downloadsnap-byow-18821f7bc1807b6ae199e2c207a865439ee6167f.tar.gz
snap-byow-18821f7bc1807b6ae199e2c207a865439ee6167f.zip
PrototypeHatBlocks accept anchored comments
You can now "stick" comments to the prototype hat block in the block editor
Diffstat (limited to 'byob.js')
-rw-r--r--byob.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/byob.js b/byob.js
index 99e882c..1a4f1e8 100644
--- a/byob.js
+++ b/byob.js
@@ -105,7 +105,7 @@ CommentMorph, localize, CSlotMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.byob = '2013-April-02';
+modules.byob = '2013-April-03';
// Declarations
@@ -137,6 +137,7 @@ function CustomBlockDefinition(spec, receiver) {
this.type = 'command';
this.spec = spec || '';
this.declarations = {}; // {'inputName' : [type, default]}
+ this.comment = null;
// don't serialize (not needed for functionality):
this.receiver = receiver || null; // for serialization only (pointer)
@@ -1400,7 +1401,7 @@ function BlockEditorMorph(definition, target) {
}
BlockEditorMorph.prototype.init = function (definition, target) {
- var scripts, proto, scriptsFrame, block, myself = this;
+ var scripts, proto, scriptsFrame, block, comment, myself = this;
// additional properties:
this.definition = definition;
@@ -1428,6 +1429,12 @@ BlockEditorMorph.prototype.init = function (definition, target) {
proto = new PrototypeHatBlockMorph(this.definition);
proto.setPosition(scripts.position().add(10));
+ if (definition.comment !== null) {
+ comment = definition.comment.fullCopy();
+ proto.comment = comment;
+ comment.block = proto;
+ }
+
if (definition.body !== null) {
proto.nextBlock(definition.body.expression.fullCopy());
}
@@ -1577,6 +1584,10 @@ BlockEditorMorph.prototype.updateDefinition = function () {
if (head) {
this.definition.category = head.blockCategory;
this.definition.type = head.type;
+ if (head.comment) {
+ this.definition.comment = head.comment.fullCopy();
+ this.definition.comment.block = true; // serialize in short form
+ }
}
this.definition.body = this.context(head);