Add hideFromPalette flag for hiding legacy blocks

This commit is contained in:
Paul Kaplan 2017-11-01 11:07:26 -04:00
parent 082e051cce
commit 18398d010b
3 changed files with 11 additions and 5 deletions
src

View file

@ -328,7 +328,8 @@ class Scratch3PenBlocks {
type: ArgumentType.NUMBER,
defaultValue: 1
}
}
},
hideFromPalette: true
},
{
opcode: 'changePenShadeBy',
@ -339,7 +340,8 @@ class Scratch3PenBlocks {
type: ArgumentType.NUMBER,
defaultValue: 1
}
}
},
hideFromPalette: true
},
{
opcode: 'setPenHueToNumber',
@ -350,7 +352,8 @@ class Scratch3PenBlocks {
type: ArgumentType.NUMBER,
defaultValue: 1
}
}
},
hideFromPalette: true
},
{
opcode: 'changePenHueBy',
@ -361,7 +364,8 @@ class Scratch3PenBlocks {
type: ArgumentType.NUMBER,
defaultValue: 1
}
}
},
hideFromPalette: true
}
],
menus: {

View file

@ -630,8 +630,9 @@ class Runtime extends EventEmitter {
const xmlParts = [];
for (const categoryInfo of this._blockInfo) {
const {name, color1, color2} = categoryInfo;
const paletteBlocks = categoryInfo.blocks.filter(block => !block.info.hideFromPalette);
xmlParts.push(`<category name="${name}" colour="${color1}" secondaryColour="${color2}">`);
xmlParts.push.apply(xmlParts, categoryInfo.blocks.map(blockInfo => blockInfo.xml));
xmlParts.push.apply(xmlParts, paletteBlocks.map(block => block.xml));
xmlParts.push('</category>');
}
return xmlParts.join('\n');

View file

@ -30,6 +30,7 @@ const builtinExtensions = {
* @property {object.<string,ArgumentInfo>|undefined} arguments - information about this block's arguments, if any
* @property {string|Function|undefined} func - the method for this block on the extension service (default: opcode)
* @property {Array.<string>|undefined} filter - the list of targets for which this block should appear (default: all)
* @property {Boolean|undefined} hideFromPalette - true if should not be appear in the palette. (default false)
*/
/**