added BlockMorph >> toXMLString() api

snap8
Jens Mönig 2022-03-15 19:07:52 +01:00
rodzic c1281384d8
commit 723ca360d8
2 zmienionych plików z 25 dodań i 9 usunięć

Wyświetl plik

@ -20,6 +20,7 @@
* blocks: new "export script" feature (including dependencies)
* blocks: tweaked "export scripts" for reporters
* German translation update (for "export script" feature)
* blocks: added BlockMorph >> toXMLString() api
### 2022-03-14
* gui, byob: refactored library serialization

Wyświetl plik

@ -3966,12 +3966,33 @@ BlockMorph.prototype.exportResultPic = function () {
BlockMorph.prototype.exportScript = function () {
// assumes this is the script's top block
var ide = this.parentThatIsA(IDE_Morph),
blockEditor = this.parentThatIsA(BlockEditorMorph),
xml;
if (!ide && blockEditor) {
ide = blockEditor.target.parentThatIsA(IDE_Morph);
}
if (!ide) {
return;
}
xml = this.toXMLString();
if (xml) {
ide.saveXMLAs(
xml,
this.selector + ' script',
false
);
}
};
BlockMorph.prototype.toXMLString = function () {
var ide = this.parentThatIsA(IDE_Morph),
blockEditor = this.parentThatIsA(BlockEditorMorph),
rcvr = this.scriptTarget(),
dependencies = [],
isReporter = this instanceof ReporterBlockMorph,
str;
isReporter = this instanceof ReporterBlockMorph;
if (!ide && blockEditor) {
ide = blockEditor.target.parentThatIsA(IDE_Morph);
@ -3996,7 +4017,7 @@ BlockMorph.prototype.exportScript = function () {
}
});
str = '<script app="' +
return '<script app="' +
ide.serializer.app +
'" version="' +
ide.serializer.version +
@ -4006,12 +4027,6 @@ BlockMorph.prototype.exportScript = function () {
ide.serializer.serialize(this) +
(isReporter ? '</script>' : '') +
'</script>';
ide.saveXMLAs(
str,
this.selector + ' script',
false
);
};
// BlockMorph syntax analysis