Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Ask wether to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
alienzhangyw committed Jul 24, 2020
1 parent 609b16f commit 021e2b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion BlockPi/src/msg/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ var MSG = {
typeError: "You are not loading a XML file!",
hashError: "Sorry, '%1' doesn't correspond with any saved program.",
xmlError: "Could not load your saved file. Perhaps it was created with a different version of Blockly?",
badXml: "Error parsing XML:\n%1\n\nSelect 'OK' to abandon your changes or 'Cancel' to further edit the XML."
badXml: "Error parsing XML:\n%1\n\nSelect 'OK' to abandon your changes or 'Cancel' to further edit the XML.",
merge: "Shall we merge the existing blocks with the file you are loading?"
};
3 changes: 2 additions & 1 deletion BlockPi/src/msg/zh-hans.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ var MSG = {
hashError: "对不起,没有任何已保存的程序对应'%1' 。",
typeError: "您载入的不是XML文件!",
xmlError: "无法载入您保存的文件。您是否使用其他版本的Blockly创建该文件的?",
badXml: "XML解析错误:\n%1\n\n选择“确定”以取消您对XML的修改,或选择“取消”以继续编辑XML。"
badXml: "XML解析错误:\n%1\n\n选择“确定”以取消您对XML的修改,或选择“取消”以继续编辑XML。",
merge: "是否将要载入的程序与现有积木块合并?"
};
5 changes: 3 additions & 2 deletions BlockPi/src/msg/zh-hant.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ var MSG = {
textVariable: "文字",
deviceVariable: "設備",
httpRequestError: "命令出現錯誤。",
linkAlert: "透過此連結分享您的積木組:\n\n%1",
linkAlert: "透過此連結分享您的積木組:\n\n%1",
typeError: "您載入的不是XML檔案!",
hashError: "對不起,「%1」並未對應任何已保存的程式。",
xmlError: "未能載入您保存的檔案。或許它是由其他版本的Blockly創建?",
badXml: "解析 XML 時出現錯誤:\n%1\n\n選擇'確定'以放棄您的更改,或選擇'取消'以進一步編輯 XML。"
badXml: "解析 XML 時出現錯誤:\n%1\n\n選擇'確定'以放棄您的更改,或選擇'取消'以進一步編輯 XML。",
merge: "是否將要載入的檔案與現有積木合併?"
};
7 changes: 4 additions & 3 deletions BlockPi/src/script/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ BlocklyStorage.loadXml_ = function(xml, workspace) {
BlocklyStorage.alert(BlocklyStorage.XML_ERROR + '\nXML: ' + xml);
return;
}
// Clear the workspace to avoid merge.
workspace.clear();
Blockly.Xml.domToWorkspace(xml, workspace);
// Ask whether to merge or override.
Blockly.confirm(MSG['merge'], (merge) => {
merge ? Blockly.Xml.appendDomToWorkspace(xml, workspace) : Blockly.Xml.clearWorkspaceAndLoadFromXml(xml, workspace);
})
};

/**
Expand Down

0 comments on commit 021e2b8

Please sign in to comment.