Blockly. Xml
Methods
appendDomToWorkspace
appendDomToWorkspace(xml, workspace) returns Array of string
Decode an XML DOM and create blocks on the workspace. Position the new blocks immediately below prior blocks, aligned by their starting edge.
Parameter |
|
---|---|
xml |
Element The XML DOM. Value must not be null. |
workspace |
The workspace to add to. Value must not be null. |
- Returns
-
Array of string
An array containing new block IDs.
blockToDom
blockToDom(block, opt_noId) returns (Element or DocumentFragment)
Encode a block subtree as XML.
Parameter |
|
---|---|
block |
The root block to encode. Value must not be null. |
opt_noId |
Optional boolean True if the encoder should skip the block ID. |
- Returns
-
(non-null Element or non-null DocumentFragment)
Tree of XML elements or an empty document fragment if the block was an insertion marker.
blockToDomWithXY
blockToDomWithXY(block, opt_noId) returns (Element or DocumentFragment)
Encode a block subtree as XML with XY coordinates.
Parameter |
|
---|---|
block |
The root block to encode. Value must not be null. |
opt_noId |
Optional boolean True if the encoder should skip the block ID. |
- Returns
-
(non-null Element or non-null DocumentFragment)
Tree of XML elements or an empty document fragment if the block was an insertion marker.
clearWorkspaceAndLoadFromXml
clearWorkspaceAndLoadFromXml(xml, workspace) returns Array of string
Clear the given workspace then decode an XML DOM and create blocks on the workspace.
Parameter |
|
---|---|
xml |
Element XML DOM. Value must not be null. |
workspace |
The workspace. Value must not be null. |
- Returns
-
Array of string
An array containing new block ids.
deleteNext
deleteNext(xmlBlock)
Remove any 'next' block (statements in a stack).
Parameter |
|
---|---|
xmlBlock |
(non-null Element or non-null DocumentFragment) XML block element or an empty DocumentFragment if the block was an insertion marker. |
domToBlock
domToBlock(xmlBlock, workspace) returns Blockly.Block
Decode an XML block tag and create a block (and possibly sub blocks) on the workspace.
Parameter |
|
---|---|
xmlBlock |
Element XML block element. Value must not be null. |
workspace |
The workspace. Value must not be null. |
- Returns
-
non-null Blockly.Block
The root block created.
domToPrettyText
domToPrettyText(dom) returns string
Converts a DOM structure into properly indented text.
Parameter |
|
---|---|
dom |
Node A tree of XML elements. Value must not be null. |
- Returns
-
string
Text representation.
domToText
domToText(dom) returns string
Converts a DOM structure into plain text. Currently the text format is fairly ugly: all one line with no whitespace, unless the DOM itself has whitespace built-in.
Parameter |
|
---|---|
dom |
Node A tree of XML nodes. Value must not be null. |
- Returns
-
string
Text representation.
domToVariables
domToVariables(xmlVariables, workspace)
Decode an XML list of variables and add the variables to the workspace.
Parameter |
|
---|---|
xmlVariables |
Element List of XML variable elements. Value must not be null. |
workspace |
The workspace to which the variable should be added. Value must not be null. |
domToWorkspace
domToWorkspace(xml, workspace) returns Array of string
Decode an XML DOM and create blocks on the workspace.
Parameter |
|
---|---|
xml |
Element XML DOM. Value must not be null. |
workspace |
The workspace. Value must not be null. |
- Returns
-
non-null Array of string
An array containing new block IDs.
textToDom
textToDom(text) returns Element
Converts an XML string into a DOM structure.
Parameter |
|
---|---|
text |
string An XML string. |
- Throws
-
if the text doesn't parse.
- Returns
-
non-null Element
A DOM object representing the singular child of the document element.
variablesToDom
variablesToDom(variableList) returns Element
Encode a list of variables as XML.
Parameter |
|
---|---|
variableList |
Array of non-null Blockly.VariableModel List of all variable models. Value must not be null. |
- Returns
-
non-null Element
Tree of XML elements.
workspaceToDom
workspaceToDom(workspace, opt_noId) returns Element
Encode a block tree as XML.
Parameter |
|
---|---|
workspace |
The workspace containing blocks. Value must not be null. |
opt_noId |
Optional boolean True if the encoder should skip the block IDs. |
- Returns
-
non-null Element
XML DOM element.