mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Strip coordinates from storage of single block stacks.
When loading, place blocks with no coordinates at 10,10 instead of 0,0.
This commit is contained in:
@@ -71,6 +71,15 @@ BlocklyStorage.restoreBlocks = function(opt_workspace) {
|
||||
BlocklyStorage.link = function(opt_workspace) {
|
||||
var workspace = opt_workspace || Blockly.getMainWorkspace();
|
||||
var xml = Blockly.Xml.workspaceToDom(workspace, true);
|
||||
// Remove x/y coordinates from XML if there's only one block stack.
|
||||
// There's no reason to store this, removing it helps with anonymity.
|
||||
if (workspace.getTopBlocks(false).length == 1 && xml.querySelector) {
|
||||
var block = xml.querySelector('block');
|
||||
if (block) {
|
||||
block.removeAttribute('x');
|
||||
block.removeAttribute('y');
|
||||
}
|
||||
}
|
||||
var data = Blockly.Xml.domToText(xml);
|
||||
BlocklyStorage.makeRequest_('/storage', 'xml', data, workspace);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user