@@ -4,7 +4,8 @@ const categorySeparator = '<sep gap="36"/>';
4
4
5
5
const blockSeparator = '<sep gap="36"/>' ; // At default scale, about 28px
6
6
7
- const motion = function ( isStage , targetId ) {
7
+ /* eslint-disable no-unused-vars */
8
+ const motion = function ( isInitialSetup , isStage , targetId ) {
8
9
const stageSelected = ScratchBlocks . ScratchMsgs . translate (
9
10
'MOTION_STAGE_SELECTED' ,
10
11
'Stage selected: no motion blocks'
@@ -150,7 +151,7 @@ const xmlEscape = function (unsafe) {
150
151
} ) ;
151
152
} ;
152
153
153
- const looks = function ( isStage , targetId , costumeName , backdropName ) {
154
+ const looks = function ( isInitialSetup , isStage , targetId , costumeName , backdropName ) {
154
155
const hello = ScratchBlocks . ScratchMsgs . translate ( 'LOOKS_HELLO' , 'Hello!' ) ;
155
156
const hmm = ScratchBlocks . ScratchMsgs . translate ( 'LOOKS_HMM' , 'Hmm...' ) ;
156
157
return `
@@ -287,7 +288,7 @@ const looks = function (isStage, targetId, costumeName, backdropName) {
287
288
` ;
288
289
} ;
289
290
290
- const sound = function ( isStage , targetId , soundName ) {
291
+ const sound = function ( isInitialSetup , isStage , targetId , soundName ) {
291
292
return `
292
293
<category name="%{BKY_CATEGORY_SOUND}" id="sound" colour="#D65CD6" secondaryColour="#BD42BD">
293
294
<block id="${ targetId } _sound_playuntildone" type="sound_playuntildone">
@@ -342,7 +343,7 @@ const sound = function (isStage, targetId, soundName) {
342
343
` ;
343
344
} ;
344
345
345
- const events = function ( isStage ) {
346
+ const events = function ( isInitialSetup , isStage ) {
346
347
return `
347
348
<category name="%{BKY_CATEGORY_EVENTS}" id="events" colour="#FFD500" secondaryColour="#CC9900">
348
349
<block type="event_whenflagclicked"/>
@@ -381,7 +382,7 @@ const events = function (isStage) {
381
382
` ;
382
383
} ;
383
384
384
- const control = function ( isStage ) {
385
+ const control = function ( isInitialSetup , isStage ) {
385
386
return `
386
387
<category name="%{BKY_CATEGORY_CONTROL}" id="control" colour="#FFAB19" secondaryColour="#CF8B17">
387
388
<block type="control_wait">
@@ -428,7 +429,7 @@ const control = function (isStage) {
428
429
` ;
429
430
} ;
430
431
431
- const sensing = function ( isStage ) {
432
+ const sensing = function ( isInitialSetup , isStage ) {
432
433
const name = ScratchBlocks . ScratchMsgs . translate ( 'SENSING_ASK_TEXT' , 'What\'s your name?' ) ;
433
434
return `
434
435
<category name="%{BKY_CATEGORY_SENSING}" id="sensing" colour="#4CBFE6" secondaryColour="#2E8EB8">
@@ -458,13 +459,15 @@ const sensing = function (isStage) {
458
459
</block>
459
460
${ blockSeparator }
460
461
` }
461
- <block id="askandwait" type="sensing_askandwait">
462
- <value name="QUESTION">
463
- <shadow type="text">
464
- <field name="TEXT">${ name } </field>
465
- </shadow>
466
- </value>
467
- </block>
462
+ ${ isInitialSetup ? '' : `
463
+ <block id="askandwait" type="sensing_askandwait">
464
+ <value name="QUESTION">
465
+ <shadow type="text">
466
+ <field name="TEXT">${ name } </field>
467
+ </shadow>
468
+ </value>
469
+ </block>
470
+ ` }
468
471
<block id="answer" type="sensing_answer"/>
469
472
${ blockSeparator }
470
473
<block type="sensing_keypressed">
@@ -501,7 +504,7 @@ const sensing = function (isStage) {
501
504
` ;
502
505
} ;
503
506
504
- const operators = function ( ) {
507
+ const operators = function ( isInitialSetup ) {
505
508
const apple = ScratchBlocks . ScratchMsgs . translate ( 'OPERATORS_JOIN_APPLE' , 'apple' ) ;
506
509
const banana = ScratchBlocks . ScratchMsgs . translate ( 'OPERATORS_JOIN_BANANA' , 'banana' ) ;
507
510
const letter = ScratchBlocks . ScratchMsgs . translate ( 'OPERATORS_LETTEROF_APPLE' , 'a' ) ;
@@ -610,49 +613,51 @@ const operators = function () {
610
613
<block type="operator_or"/>
611
614
<block type="operator_not"/>
612
615
${ blockSeparator }
613
- <block type="operator_join">
614
- <value name="STRING1">
615
- <shadow type="text">
616
- <field name="TEXT">${ apple } </field>
617
- </shadow>
618
- </value>
619
- <value name="STRING2">
620
- <shadow type="text">
621
- <field name="TEXT">${ banana } </field>
622
- </shadow>
623
- </value>
624
- </block>
625
- <block type="operator_letter_of">
626
- <value name="LETTER">
627
- <shadow type="math_whole_number">
628
- <field name="NUM">1</field>
629
- </shadow>
630
- </value>
631
- <value name="STRING">
616
+ ${ isInitialSetup ? '' : `
617
+ <block type="operator_join">
618
+ <value name="STRING1">
619
+ <shadow type="text">
620
+ <field name="TEXT">${ apple } </field>
621
+ </shadow>
622
+ </value>
623
+ <value name="STRING2">
624
+ <shadow type="text">
625
+ <field name="TEXT">${ banana } </field>
626
+ </shadow>
627
+ </value>
628
+ </block>
629
+ <block type="operator_letter_of">
630
+ <value name="LETTER">
631
+ <shadow type="math_whole_number">
632
+ <field name="NUM">1</field>
633
+ </shadow>
634
+ </value>
635
+ <value name="STRING">
636
+ <shadow type="text">
637
+ <field name="TEXT">${ apple } </field>
638
+ </shadow>
639
+ </value>
640
+ </block>
641
+ <block type="operator_length">
642
+ <value name="STRING">
643
+ <shadow type="text">
644
+ <field name="TEXT">${ apple } </field>
645
+ </shadow>
646
+ </value>
647
+ </block>
648
+ <block type="operator_contains" id="operator_contains">
649
+ <value name="STRING1">
632
650
<shadow type="text">
633
- <field name="TEXT">${ apple } </field>
651
+ <field name="TEXT">${ apple } </field>
634
652
</shadow>
635
- </value>
636
- </block>
637
- <block type="operator_length">
638
- <value name="STRING">
653
+ </value>
654
+ <value name="STRING2">
639
655
<shadow type="text">
640
- <field name="TEXT">${ apple } </field>
656
+ <field name="TEXT">${ letter } </field>
641
657
</shadow>
642
- </value>
643
- </block>
644
- <block type="operator_contains" id="operator_contains">
645
- <value name="STRING1">
646
- <shadow type="text">
647
- <field name="TEXT">${ apple } </field>
648
- </shadow>
649
- </value>
650
- <value name="STRING2">
651
- <shadow type="text">
652
- <field name="TEXT">${ letter } </field>
653
- </shadow>
654
- </value>
655
- </block>
658
+ </value>
659
+ </block>
660
+ ` }
656
661
${ blockSeparator }
657
662
<block type="operator_mod">
658
663
<value name="NUM1">
@@ -709,12 +714,16 @@ const myBlocks = function () {
709
714
</category>
710
715
` ;
711
716
} ;
717
+ /* eslint-enable no-unused-vars */
712
718
713
719
const xmlOpen = '<xml style="display: none">' ;
714
720
const xmlClose = '</xml>' ;
715
721
716
722
/**
717
- * @param {!boolean } isStage - Whether the toolbox is for a stage-type target.
723
+ * @param {!boolean } isInitialSetup - Whether the toolbox is for initial setup. If the mode is "initial setup",
724
+ * blocks with localized default parameters (e.g. ask and wait) should not be loaded. (LLK/scratch-gui#5445)
725
+ * @param {?boolean } isStage - Whether the toolbox is for a stage-type target. This is always set to true
726
+ * when isInitialSetup is true.
718
727
* @param {?string } targetId - The current editing target
719
728
* @param {?Array.<object> } categoriesXML - optional array of `{id,xml}` for categories. This can include both core
720
729
* and other extensions: core extensions will be placed in the normal Scratch order; others will go at the bottom.
@@ -725,8 +734,9 @@ const xmlClose = '</xml>';
725
734
* @param {?string } soundName - The name of the default selected sound dropdown.
726
735
* @returns {string } - a ScratchBlocks-style XML document for the contents of the toolbox.
727
736
*/
728
- const makeToolboxXML = function ( isStage , targetId , categoriesXML = [ ] ,
737
+ const makeToolboxXML = function ( isInitialSetup , isStage = true , targetId , categoriesXML = [ ] ,
729
738
costumeName = '' , backdropName = '' , soundName = '' ) {
739
+ isStage = isInitialSetup || isStage ;
730
740
const gap = [ categorySeparator ] ;
731
741
732
742
costumeName = xmlEscape ( costumeName ) ;
@@ -743,15 +753,15 @@ const makeToolboxXML = function (isStage, targetId, categoriesXML = [],
743
753
}
744
754
// return `undefined`
745
755
} ;
746
- const motionXML = moveCategory ( 'motion' ) || motion ( isStage , targetId ) ;
747
- const looksXML = moveCategory ( 'looks' ) || looks ( isStage , targetId , costumeName , backdropName ) ;
748
- const soundXML = moveCategory ( 'sound' ) || sound ( isStage , targetId , soundName ) ;
749
- const eventsXML = moveCategory ( 'event' ) || events ( isStage , targetId ) ;
750
- const controlXML = moveCategory ( 'control' ) || control ( isStage , targetId ) ;
751
- const sensingXML = moveCategory ( 'sensing' ) || sensing ( isStage , targetId ) ;
752
- const operatorsXML = moveCategory ( 'operators' ) || operators ( isStage , targetId ) ;
753
- const variablesXML = moveCategory ( 'data' ) || variables ( isStage , targetId ) ;
754
- const myBlocksXML = moveCategory ( 'procedures' ) || myBlocks ( isStage , targetId ) ;
756
+ const motionXML = moveCategory ( 'motion' ) || motion ( isInitialSetup , isStage , targetId ) ;
757
+ const looksXML = moveCategory ( 'looks' ) || looks ( isInitialSetup , isStage , targetId , costumeName , backdropName ) ;
758
+ const soundXML = moveCategory ( 'sound' ) || sound ( isInitialSetup , isStage , targetId , soundName ) ;
759
+ const eventsXML = moveCategory ( 'event' ) || events ( isInitialSetup , isStage , targetId ) ;
760
+ const controlXML = moveCategory ( 'control' ) || control ( isInitialSetup , isStage , targetId ) ;
761
+ const sensingXML = moveCategory ( 'sensing' ) || sensing ( isInitialSetup , isStage , targetId ) ;
762
+ const operatorsXML = moveCategory ( 'operators' ) || operators ( isInitialSetup , isStage , targetId ) ;
763
+ const variablesXML = moveCategory ( 'data' ) || variables ( isInitialSetup , isStage , targetId ) ;
764
+ const myBlocksXML = moveCategory ( 'procedures' ) || myBlocks ( isInitialSetup , isStage , targetId ) ;
755
765
756
766
const everything = [
757
767
xmlOpen ,
0 commit comments