kopia lustrzana https://github.com/backface/turtlestitch
added BlockMorph >> toXMLString() api
rodzic
c1281384d8
commit
723ca360d8
|
@ -20,6 +20,7 @@
|
||||||
* blocks: new "export script" feature (including dependencies)
|
* blocks: new "export script" feature (including dependencies)
|
||||||
* blocks: tweaked "export scripts" for reporters
|
* blocks: tweaked "export scripts" for reporters
|
||||||
* German translation update (for "export script" feature)
|
* German translation update (for "export script" feature)
|
||||||
|
* blocks: added BlockMorph >> toXMLString() api
|
||||||
|
|
||||||
### 2022-03-14
|
### 2022-03-14
|
||||||
* gui, byob: refactored library serialization
|
* gui, byob: refactored library serialization
|
||||||
|
|
|
@ -3966,12 +3966,33 @@ BlockMorph.prototype.exportResultPic = function () {
|
||||||
|
|
||||||
BlockMorph.prototype.exportScript = function () {
|
BlockMorph.prototype.exportScript = function () {
|
||||||
// assumes this is the script's top block
|
// 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),
|
var ide = this.parentThatIsA(IDE_Morph),
|
||||||
blockEditor = this.parentThatIsA(BlockEditorMorph),
|
blockEditor = this.parentThatIsA(BlockEditorMorph),
|
||||||
rcvr = this.scriptTarget(),
|
rcvr = this.scriptTarget(),
|
||||||
dependencies = [],
|
dependencies = [],
|
||||||
isReporter = this instanceof ReporterBlockMorph,
|
isReporter = this instanceof ReporterBlockMorph;
|
||||||
str;
|
|
||||||
|
|
||||||
if (!ide && blockEditor) {
|
if (!ide && blockEditor) {
|
||||||
ide = blockEditor.target.parentThatIsA(IDE_Morph);
|
ide = blockEditor.target.parentThatIsA(IDE_Morph);
|
||||||
|
@ -3996,7 +4017,7 @@ BlockMorph.prototype.exportScript = function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
str = '<script app="' +
|
return '<script app="' +
|
||||||
ide.serializer.app +
|
ide.serializer.app +
|
||||||
'" version="' +
|
'" version="' +
|
||||||
ide.serializer.version +
|
ide.serializer.version +
|
||||||
|
@ -4006,12 +4027,6 @@ BlockMorph.prototype.exportScript = function () {
|
||||||
ide.serializer.serialize(this) +
|
ide.serializer.serialize(this) +
|
||||||
(isReporter ? '</script>' : '') +
|
(isReporter ? '</script>' : '') +
|
||||||
'</script>';
|
'</script>';
|
||||||
|
|
||||||
ide.saveXMLAs(
|
|
||||||
str,
|
|
||||||
this.selector + ' script',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// BlockMorph syntax analysis
|
// BlockMorph syntax analysis
|
||||||
|
|
Ładowanie…
Reference in New Issue