export block definitions from inside the block editor

snap8
Jens Mönig 2022-04-20 14:40:48 +02:00
rodzic 16692e4e25
commit 268e78e4fa
4 zmienionych plików z 32 dodań i 13 usunięć

Wyświetl plik

@ -8,6 +8,7 @@
* new "Menus" library
* export script (including dependencies) via its context menu
* export / import sprite-local custom block definitions from the palette
* export block definitions from inside the block editor
* added "combinations" primitive to the palette
* new POSITION primitive reporter in the MOTION category
* new MOUSE POSITION primitive reporter in the SENSING category
@ -43,6 +44,7 @@
### 2022-04-20
* threads: terminate all threads waiting to display a question on ASKing a falsy value
* threads: clear "answer" on ASK nothing/falsy
* byob, blocks: export block definition from inside the block editor
### 2022-04-19
* threads: ASK nothing or a falsy value terminates the thread currently displaying a question

Wyświetl plik

@ -16,14 +16,14 @@
<script src="src/morphic.js?version=2022-01-28"></script>
<script src="src/symbols.js?version=2021-03-03"></script>
<script src="src/widgets.js?version=2021-17-09"></script>
<script src="src/blocks.js?version=2022-04-08"></script>
<script src="src/blocks.js?version=2022-04-20"></script>
<script src="src/threads.js?version=2022-04-20"></script>
<script src="src/objects.js?version=2022-04-04"></script>
<script src="src/scenes.js?version=2022-03-03"></script>
<script src="src/gui.js?version=2022-04-06"></script>
<script src="src/paint.js?version=2021-07-05"></script>
<script src="src/lists.js?version=2022-02-07"></script>
<script src="src/byob.js?version=2022-03-23"></script>
<script src="src/byob.js?version=2022-04-20"></script>
<script src="src/tables.js?version=2022-01-28"></script>
<script src="src/sketch.js?version=2021-11-03"></script>
<script src="src/video.js?version=2019-06-27"></script>

Wyświetl plik

@ -161,7 +161,7 @@ CostumeIconMorph, SoundIconMorph, SVG_Costume*/
// Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2022-April-08';
modules.blocks = '2022-April-20';
var SyntaxElementMorph;
var BlockMorph;
@ -3348,11 +3348,19 @@ BlockMorph.prototype.userMenu = function () {
'save a picture of both\nthis script and its result'
);
}
menu.addItem(
'export script',
() => top.exportScript(),
'download this script\nas an XML file'
);
if (top instanceof PrototypeHatBlockMorph) {
menu.addItem(
"export...",
() => top.exportBlockDefinition(),
'including dependencies'
);
} else {
menu.addItem(
'export script',
() => top.exportScript(),
'download this script\nas an XML file'
);
}
if (proc) {
if (vNames.length) {
menu.addLine();

Wyświetl plik

@ -111,7 +111,7 @@ ArgLabelMorph*/
// Global stuff ////////////////////////////////////////////////////////
modules.byob = '2022-March-23';
modules.byob = '2022-April-20';
// Declarations
@ -1218,6 +1218,11 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
'uncheck to\nhide in palette',
'check to\nshow in palette'
);
menu.addItem(
"export...",
() => hat.exportBlockDefinition(),
'including dependencies'
);
} else {
menu = this.constructor.uber.userMenu.call(this);
dlg = this.parentThatIsA(DialogBoxMorph);
@ -1312,10 +1317,11 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
};
CustomCommandBlockMorph.prototype.exportBlockDefinition = function () {
var ide = this.parentThatIsA(IDE_Morph),
rcvr = this.scriptTarget(),
def = this.isGlobal ? this.definition
: rcvr.getMethod(this.blockSpec);
var rcvr = this.scriptTarget(),
ide = rcvr.parentThatIsA(IDE_Morph),
def = this.isGlobal || this instanceof PrototypeHatBlockMorph ?
this.definition
: rcvr.getMethod(this.blockSpec);
new BlockExportDialogMorph(
ide.serializer,
[def].concat(def.collectDependencies([], [], rcvr)),
@ -2790,6 +2796,9 @@ PrototypeHatBlockMorph.prototype.userMenu = function () {
return this.parts()[0].userMenu();
};
PrototypeHatBlockMorph.prototype.exportBlockDefinition =
CustomCommandBlockMorph.prototype.exportBlockDefinition;
// PrototypeHatBlockMorph zebra coloring
PrototypeHatBlockMorph.prototype.fixBlockColor = function (