mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-13 06:29:31 -04:00
Merge remote-tracking branch 'Google/master' into google-master-april-1
# Conflicts: # blockly_compressed_horizontal.js # blockly_uncompressed_vertical.js # blocks_compressed.js # core/block.js # core/block_svg.js # core/blockly.js # core/connection.js # core/field_textinput.js # core/workspace_svg.js # generators/lua/lists.js # generators/lua/text.js # msg/js/he.js # msg/js/id.js # msg/js/sr.js # msg/js/zh-hant.js # msg/json/en.json
This commit is contained in:
commit
a65109f423
134 changed files with 1952 additions and 1235 deletions
core
|
@ -153,9 +153,16 @@ Blockly.Workspace.prototype.getAllBlocks = function() {
|
|||
* Dispose of all blocks in workspace.
|
||||
*/
|
||||
Blockly.Workspace.prototype.clear = function() {
|
||||
var existingGroup = Blockly.Events.getGroup();
|
||||
if (!existingGroup) {
|
||||
Blockly.Events.setGroup(true);
|
||||
}
|
||||
while (this.topBlocks_.length) {
|
||||
this.topBlocks_[0].dispose();
|
||||
}
|
||||
if (!existingGroup) {
|
||||
Blockly.Events.setGroup(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -232,12 +239,21 @@ Blockly.Workspace.prototype.undo = function(redo) {
|
|||
events = Blockly.Events.filter(events, redo);
|
||||
Blockly.Events.recordUndo = false;
|
||||
for (var i = 0, event; event = events[i]; i++) {
|
||||
console.log(event);
|
||||
event.run(redo);
|
||||
}
|
||||
Blockly.Events.recordUndo = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the undo/redo stacks.
|
||||
*/
|
||||
Blockly.Workspace.prototype.clearUndo = function() {
|
||||
this.undoStack_.length = 0;
|
||||
this.redoStack_.length = 0;
|
||||
// Stop any events already in the firing queue from being undoable.
|
||||
Blockly.Events.clearPendingUndo();
|
||||
};
|
||||
|
||||
/**
|
||||
* When something in this workspace changes, call a function.
|
||||
* @param {!Function} func Function to call.
|
||||
|
@ -328,6 +344,8 @@ Blockly.Workspace.getById = function(id) {
|
|||
|
||||
// Export symbols that would otherwise be renamed by Closure compiler.
|
||||
Blockly.Workspace.prototype['clear'] = Blockly.Workspace.prototype.clear;
|
||||
Blockly.Workspace.prototype['clearUndo'] =
|
||||
Blockly.Workspace.prototype.clearUndo;
|
||||
Blockly.Workspace.prototype['addChangeListener'] =
|
||||
Blockly.Workspace.prototype.addChangeListener;
|
||||
Blockly.Workspace.prototype['removeChangeListener'] =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue