块状结构变化的事件是什么?
What's the event of blockly structure change?
我有一个包含 blockly 的网络应用程序,我希望能够将用户在 blockly 上创建的结构保存在后端数据库上。
我只想知道如何获取当前工作区结构,以便我可以 post 将其保存到服务器。
然后在用户登录时重新加载。
谢谢。
来自Importing and exporting blocks:
If your application needs to save and store the user's blocks and restore them at a later visit, use this call for export to XML:
var xml = Blockly.Xml.workspaceToDom(workspace);
var xml_text = Blockly.Xml.domToText(xml);
This will produce a minimal (but ugly) string containing the XML for the user's blocks. If one wishes to obtain a more readable (but larger) string, use Blockly.Xml.domToPrettyText instead.
Restoring from an XML string to blocks is just as simple:
var xml = Blockly.Xml.textToDom(xml_text);
Blockly.Xml.domToWorkspace(xml, workspace);
我有一个包含 blockly 的网络应用程序,我希望能够将用户在 blockly 上创建的结构保存在后端数据库上。 我只想知道如何获取当前工作区结构,以便我可以 post 将其保存到服务器。 然后在用户登录时重新加载。
谢谢。
来自Importing and exporting blocks:
If your application needs to save and store the user's blocks and restore them at a later visit, use this call for export to XML:
var xml = Blockly.Xml.workspaceToDom(workspace); var xml_text = Blockly.Xml.domToText(xml);
This will produce a minimal (but ugly) string containing the XML for the user's blocks. If one wishes to obtain a more readable (but larger) string, use Blockly.Xml.domToPrettyText instead.
Restoring from an XML string to blocks is just as simple:
var xml = Blockly.Xml.textToDom(xml_text); Blockly.Xml.domToWorkspace(xml, workspace);