scratch-blocks 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commitlint.config.js +2 -2
- package/dist/main.mjs +1 -2
- package/dist/types/msg/scratch_msgs.d.ts.map +1 -1
- package/dist/types/src/block_reporting.d.ts.map +1 -1
- package/dist/types/src/blocks/colour.d.ts +0 -19
- package/dist/types/src/blocks/colour.d.ts.map +1 -1
- package/dist/types/src/blocks/control.d.ts +0 -19
- package/dist/types/src/blocks/control.d.ts.map +1 -1
- package/dist/types/src/blocks/data.d.ts +0 -19
- package/dist/types/src/blocks/data.d.ts.map +1 -1
- package/dist/types/src/blocks/event.d.ts +0 -19
- package/dist/types/src/blocks/event.d.ts.map +1 -1
- package/dist/types/src/blocks/looks.d.ts +0 -19
- package/dist/types/src/blocks/looks.d.ts.map +1 -1
- package/dist/types/src/blocks/math.d.ts +0 -19
- package/dist/types/src/blocks/math.d.ts.map +1 -1
- package/dist/types/src/blocks/matrix.d.ts +0 -19
- package/dist/types/src/blocks/matrix.d.ts.map +1 -1
- package/dist/types/src/blocks/motion.d.ts +0 -19
- package/dist/types/src/blocks/motion.d.ts.map +1 -1
- package/dist/types/src/blocks/note.d.ts +0 -19
- package/dist/types/src/blocks/note.d.ts.map +1 -1
- package/dist/types/src/blocks/operators.d.ts +0 -19
- package/dist/types/src/blocks/operators.d.ts.map +1 -1
- package/dist/types/src/blocks/procedures.d.ts +6 -9
- package/dist/types/src/blocks/procedures.d.ts.map +1 -1
- package/dist/types/src/blocks/sensing.d.ts +0 -19
- package/dist/types/src/blocks/sensing.d.ts.map +1 -1
- package/dist/types/src/blocks/sound.d.ts +0 -19
- package/dist/types/src/blocks/sound.d.ts.map +1 -1
- package/dist/types/src/blocks/text.d.ts +0 -19
- package/dist/types/src/blocks/text.d.ts.map +1 -1
- package/dist/types/src/blocks/vertical_extensions.d.ts +0 -19
- package/dist/types/src/blocks/vertical_extensions.d.ts.map +1 -1
- package/dist/types/src/checkable_continuous_flyout.d.ts +2 -7
- package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
- package/dist/types/src/checkbox_bubble.d.ts +13 -12
- package/dist/types/src/checkbox_bubble.d.ts.map +1 -1
- package/dist/types/src/colours.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +0 -7
- package/dist/types/src/constants.d.ts.map +1 -1
- package/dist/types/src/context_menu_items.d.ts +0 -5
- package/dist/types/src/context_menu_items.d.ts.map +1 -1
- package/dist/types/src/data_category.d.ts +2 -4
- package/dist/types/src/data_category.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_base.d.ts +2 -3
- package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_change.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_change.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_collapse.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_collapse.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_create.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_create.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_delete.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_delete.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_move.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_move.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_resize.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_resize.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_end.d.ts +1 -2
- package/dist/types/src/events/events_block_drag_end.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_outside.d.ts +1 -2
- package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
- package/dist/types/src/events/events_scratch_variable_create.d.ts +0 -5
- package/dist/types/src/events/events_scratch_variable_create.d.ts.map +1 -1
- package/dist/types/src/fields/field_colour_slider.d.ts +3 -27
- package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
- package/dist/types/src/fields/field_matrix.d.ts +0 -19
- package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
- package/dist/types/src/fields/field_note.d.ts +8 -23
- package/dist/types/src/fields/field_note.d.ts.map +1 -1
- package/dist/types/src/fields/field_textinput_removable.d.ts +2 -4
- package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
- package/dist/types/src/fields/field_variable_getter.d.ts +0 -19
- package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
- package/dist/types/src/fields/field_vertical_separator.d.ts +0 -19
- package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_angle.d.ts +0 -19
- package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_dropdown.d.ts +0 -5
- package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_number.d.ts +0 -19
- package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_variable.d.ts +4 -7
- package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
- package/dist/types/src/flyout_checkbox_icon.d.ts +2 -3
- package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
- package/dist/types/src/glows.d.ts +1 -3
- package/dist/types/src/glows.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +50 -51
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/procedures.d.ts +6 -8
- package/dist/types/src/procedures.d.ts.map +1 -1
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts +3 -5
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/renderer/bowler_hat.d.ts +2 -3
- package/dist/types/src/renderer/bowler_hat.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/cat_face.d.ts +6 -5
- package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/constants.d.ts +2 -2
- package/dist/types/src/renderer/cat/constants.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/drawer.d.ts +3 -4
- package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/path_object.d.ts +2 -3
- package/dist/types/src/renderer/cat/path_object.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/render_info.d.ts +3 -4
- package/dist/types/src/renderer/cat/render_info.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/renderer.d.ts +6 -7
- package/dist/types/src/renderer/cat/renderer.d.ts.map +1 -1
- package/dist/types/src/renderer/constants.d.ts +4 -4
- package/dist/types/src/renderer/constants.d.ts.map +1 -1
- package/dist/types/src/renderer/drawer.d.ts +5 -4
- package/dist/types/src/renderer/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/path_object.d.ts +1 -3
- package/dist/types/src/renderer/path_object.d.ts.map +1 -1
- package/dist/types/src/renderer/render_info.d.ts +3 -4
- package/dist/types/src/renderer/render_info.d.ts.map +1 -1
- package/dist/types/src/renderer/renderer.d.ts +8 -15
- package/dist/types/src/renderer/renderer.d.ts.map +1 -1
- package/dist/types/src/scratch_block_paster.d.ts +0 -5
- package/dist/types/src/scratch_block_paster.d.ts.map +1 -1
- package/dist/types/src/scratch_blocks_utils.d.ts +0 -20
- package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_bubble.d.ts +1 -4
- package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_icon.d.ts +2 -3
- package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
- package/dist/types/src/scratch_connection_checker.d.ts +0 -5
- package/dist/types/src/scratch_connection_checker.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_category.d.ts +5 -5
- package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_toolbox.d.ts +3 -6
- package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
- package/dist/types/src/scratch_dragger.d.ts +1 -10
- package/dist/types/src/scratch_dragger.d.ts.map +1 -1
- package/dist/types/src/scratch_insertion_marker_previewer.d.ts +0 -5
- package/dist/types/src/scratch_insertion_marker_previewer.d.ts.map +1 -1
- package/dist/types/src/scratch_variable_map.d.ts +0 -5
- package/dist/types/src/scratch_variable_map.d.ts.map +1 -1
- package/dist/types/src/scratch_variable_model.d.ts +1 -2
- package/dist/types/src/scratch_variable_model.d.ts.map +1 -1
- package/dist/types/src/scratch_zoom_controls.d.ts +4 -6
- package/dist/types/src/scratch_zoom_controls.d.ts.map +1 -1
- package/dist/types/src/shadows.d.ts +2 -2
- package/dist/types/src/shadows.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label.d.ts +4 -6
- package/dist/types/src/status_indicator_label.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts +1 -6
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/variables.d.ts +4 -8
- package/dist/types/src/variables.d.ts.map +1 -1
- package/dist/types/src/xml.d.ts +2 -3
- package/dist/types/src/xml.d.ts.map +1 -1
- package/dist/types/tests/jsunit/block_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/connection_db_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/connection_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/event_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/extensions_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_number_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_variable_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/gesture_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/input_test.d.ts +1 -0
- package/dist/types/tests/jsunit/input_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/json_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/names_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/procedure_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/svg_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/test_utilities.d.ts.map +1 -1
- package/dist/types/tests/jsunit/utils_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/variable_map_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/variable_model_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/widget_div_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/xml_test.d.ts.map +1 -1
- package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +1 -1
- package/eslint.config.mjs +69 -0
- package/i18n/create_scratch_msgs.js +44 -45
- package/i18n/js_to_json.js +40 -32
- package/i18n/json_to_js.js +37 -37
- package/i18n/sync_tx_translations.js +64 -65
- package/i18n/test_scratch_msgs.js +66 -63
- package/msg/js/en.js +289 -287
- package/msg/json/en.json +284 -284
- package/msg/messages.js +289 -287
- package/msg/scratch_msgs.js +22959 -22970
- package/package.json +6 -3
- package/prettier.config.mjs +3 -0
- package/release.config.js +7 -7
- package/renovate.json5 +7 -9
- package/src/block_reporting.ts +15 -18
- package/src/blocks/colour.ts +12 -15
- package/src/blocks/control.ts +167 -177
- package/src/blocks/data.ts +225 -292
- package/src/blocks/event.ts +121 -123
- package/src/blocks/looks.ts +165 -167
- package/src/blocks/math.ts +44 -46
- package/src/blocks/matrix.ts +11 -13
- package/src/blocks/motion.ts +151 -153
- package/src/blocks/note.ts +11 -13
- package/src/blocks/operators.ts +158 -160
- package/src/blocks/procedures.ts +415 -523
- package/src/blocks/sensing.ts +163 -165
- package/src/blocks/sound.ts +58 -60
- package/src/blocks/text.ts +10 -12
- package/src/blocks/vertical_extensions.ts +86 -102
- package/src/checkable_continuous_flyout.ts +25 -42
- package/src/checkbox_bubble.ts +83 -100
- package/src/colours.ts +35 -37
- package/src/constants.ts +22 -29
- package/src/context_menu_items.ts +56 -81
- package/src/css.ts +3 -4
- package/src/data_category.ts +137 -251
- package/src/events/events_block_comment_base.ts +21 -31
- package/src/events/events_block_comment_change.ts +21 -42
- package/src/events/events_block_comment_collapse.ts +22 -43
- package/src/events/events_block_comment_create.ts +29 -46
- package/src/events/events_block_comment_delete.ts +10 -19
- package/src/events/events_block_comment_move.ts +27 -52
- package/src/events/events_block_comment_resize.ts +28 -55
- package/src/events/events_block_drag_end.ts +16 -26
- package/src/events/events_block_drag_outside.ts +12 -22
- package/src/events/events_scratch_variable_create.ts +33 -56
- package/src/fields/field_colour_slider.ts +173 -228
- package/src/fields/field_matrix.ts +200 -269
- package/src/fields/field_note.ts +272 -377
- package/src/fields/field_textinput_removable.ts +25 -40
- package/src/fields/field_variable_getter.ts +26 -31
- package/src/fields/field_vertical_separator.ts +19 -24
- package/src/fields/scratch_field_angle.ts +150 -186
- package/src/fields/scratch_field_dropdown.ts +15 -19
- package/src/fields/scratch_field_number.ts +123 -180
- package/src/fields/scratch_field_variable.ts +54 -75
- package/src/flyout_checkbox_icon.ts +18 -28
- package/src/glows.ts +51 -58
- package/src/index.ts +119 -133
- package/src/procedures.ts +146 -213
- package/src/recyclable_block_flyout_inflater.ts +14 -25
- package/src/renderer/bowler_hat.ts +6 -8
- package/src/renderer/cat/cat_face.ts +98 -99
- package/src/renderer/cat/constants.ts +67 -87
- package/src/renderer/cat/drawer.ts +21 -27
- package/src/renderer/cat/path_object.ts +3 -5
- package/src/renderer/cat/render_info.ts +5 -8
- package/src/renderer/cat/renderer.ts +11 -15
- package/src/renderer/constants.ts +34 -49
- package/src/renderer/drawer.ts +35 -51
- package/src/renderer/path_object.ts +4 -10
- package/src/renderer/render_info.ts +36 -56
- package/src/renderer/renderer.ts +16 -29
- package/src/scratch_block_paster.ts +12 -20
- package/src/scratch_blocks_utils.ts +4 -7
- package/src/scratch_comment_bubble.ts +70 -101
- package/src/scratch_comment_icon.ts +74 -123
- package/src/scratch_connection_checker.ts +7 -17
- package/src/scratch_continuous_category.ts +24 -28
- package/src/scratch_continuous_toolbox.ts +20 -27
- package/src/scratch_dragger.ts +42 -81
- package/src/scratch_insertion_marker_previewer.ts +6 -11
- package/src/scratch_variable_map.ts +5 -12
- package/src/scratch_variable_model.ts +4 -11
- package/src/scratch_zoom_controls.ts +101 -156
- package/src/shadows.ts +32 -37
- package/src/status_indicator_label.ts +54 -67
- package/src/status_indicator_label_flyout_inflater.ts +11 -21
- package/src/variables.ts +89 -138
- package/src/xml.ts +21 -35
- package/tsconfig.json +2 -6
- package/types/continuous-toolbox.d.ts +1 -1
- package/dist/main.mjs.LICENSE.txt +0 -163
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license
|
|
3
2
|
* Visual Blocks Editor
|
|
4
3
|
*
|
|
5
4
|
* Copyright 2016 Massachusetts Institute of Technology
|
|
@@ -17,19 +16,18 @@
|
|
|
17
16
|
* See the License for the specific language governing permissions and
|
|
18
17
|
* limitations under the License.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
|
-
* @
|
|
20
|
+
* @file Text input field with floating "remove" button.
|
|
23
21
|
* @author pkaplan@media.mit.edu (Paul Kaplan)
|
|
24
22
|
*/
|
|
25
|
-
import * as Blockly from
|
|
26
|
-
import type { ProcedureDeclarationBlock } from
|
|
23
|
+
import * as Blockly from 'blockly/core'
|
|
24
|
+
import type { ProcedureDeclarationBlock } from '../blocks/procedures'
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* Class for an editable text field displaying a deletion icon when selected.
|
|
30
28
|
*/
|
|
31
29
|
export class FieldTextInputRemovable extends Blockly.FieldTextInput {
|
|
32
|
-
private removeButtonMouseWrapper_?: Blockly.browserEvents.Data
|
|
30
|
+
private removeButtonMouseWrapper_?: Blockly.browserEvents.Data
|
|
33
31
|
|
|
34
32
|
/**
|
|
35
33
|
* Show the inline free-text editor on top of the text with the remove button.
|
|
@@ -38,24 +36,21 @@ export class FieldTextInputRemovable extends Blockly.FieldTextInput {
|
|
|
38
36
|
// Wait for our parent block to render so we can examine its metrics to
|
|
39
37
|
// calculate rounded corners on the editor as needed.
|
|
40
38
|
Blockly.renderManagement.finishQueuedRenders().then(() => {
|
|
41
|
-
super.showEditor_()
|
|
39
|
+
super.showEditor_()
|
|
42
40
|
|
|
43
|
-
const div = Blockly.WidgetDiv.getDiv()
|
|
44
|
-
div.className +=
|
|
45
|
-
const removeButton = document.createElement(
|
|
46
|
-
removeButton.className =
|
|
47
|
-
removeButton.setAttribute(
|
|
48
|
-
"src",
|
|
49
|
-
this.sourceBlock_!.workspace.options.pathToMedia + "icons/remove.svg"
|
|
50
|
-
);
|
|
41
|
+
const div = Blockly.WidgetDiv.getDiv()!
|
|
42
|
+
div.className += ' removableTextInput'
|
|
43
|
+
const removeButton = document.createElement('img')
|
|
44
|
+
removeButton.className = 'blocklyTextRemoveIcon'
|
|
45
|
+
removeButton.setAttribute('src', this.sourceBlock_!.workspace.options.pathToMedia + 'icons/remove.svg')
|
|
51
46
|
this.removeButtonMouseWrapper_ = Blockly.browserEvents.bind(
|
|
52
47
|
removeButton,
|
|
53
|
-
|
|
48
|
+
'mousedown',
|
|
54
49
|
this,
|
|
55
|
-
this.removeCallback_
|
|
56
|
-
)
|
|
57
|
-
div.appendChild(removeButton)
|
|
58
|
-
})
|
|
50
|
+
this.removeCallback_,
|
|
51
|
+
)
|
|
52
|
+
div.appendChild(removeButton)
|
|
53
|
+
})
|
|
59
54
|
}
|
|
60
55
|
|
|
61
56
|
/**
|
|
@@ -63,33 +58,26 @@ export class FieldTextInputRemovable extends Blockly.FieldTextInput {
|
|
|
63
58
|
* on sourceBlock and calls it if possible.
|
|
64
59
|
*/
|
|
65
60
|
private removeCallback_() {
|
|
66
|
-
if (this.sourceBlock_ &&
|
|
67
|
-
(this.sourceBlock_ as ProcedureDeclarationBlock).removeFieldCallback(
|
|
68
|
-
this
|
|
69
|
-
);
|
|
61
|
+
if (this.sourceBlock_ && 'removeFieldCallback' in this.sourceBlock_) {
|
|
62
|
+
;(this.sourceBlock_ as ProcedureDeclarationBlock).removeFieldCallback(this)
|
|
70
63
|
} else {
|
|
71
|
-
console.warn(
|
|
64
|
+
console.warn('Expected a source block with removeFieldCallback')
|
|
72
65
|
}
|
|
73
66
|
}
|
|
74
67
|
|
|
75
68
|
/**
|
|
76
69
|
* Helper function to construct a FieldTextInputRemovable from a JSON arg object,
|
|
77
70
|
* dereferencing any string table references.
|
|
78
|
-
*
|
|
79
71
|
* @param options A JSON object with options (text, class, and spellcheck).
|
|
80
72
|
* @returns The new text input.
|
|
81
73
|
*/
|
|
82
|
-
fromJson(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
options
|
|
87
|
-
);
|
|
88
|
-
const field = new FieldTextInputRemovable(text, null, options);
|
|
89
|
-
if (typeof options["spellcheck"] == "boolean") {
|
|
90
|
-
field.setSpellcheck(options["spellcheck"]);
|
|
74
|
+
fromJson(options: Blockly.FieldTextInputFromJsonConfig): FieldTextInputRemovable {
|
|
75
|
+
const text = Blockly.utils.parsing.replaceMessageReferences(options.text)
|
|
76
|
+
const field = new FieldTextInputRemovable(text, null, options)
|
|
77
|
+
if (typeof options.spellcheck == 'boolean') {
|
|
78
|
+
field.setSpellcheck(options.spellcheck)
|
|
91
79
|
}
|
|
92
|
-
return field
|
|
80
|
+
return field
|
|
93
81
|
}
|
|
94
82
|
}
|
|
95
83
|
|
|
@@ -97,8 +85,5 @@ export class FieldTextInputRemovable extends Blockly.FieldTextInput {
|
|
|
97
85
|
* Register the field and any dependencies.
|
|
98
86
|
*/
|
|
99
87
|
export function registerFieldTextInputRemovable() {
|
|
100
|
-
Blockly.fieldRegistry.register(
|
|
101
|
-
"field_input_removable",
|
|
102
|
-
FieldTextInputRemovable
|
|
103
|
-
);
|
|
88
|
+
Blockly.fieldRegistry.register('field_input_removable', FieldTextInputRemovable)
|
|
104
89
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license
|
|
3
2
|
* Visual Blocks Editor
|
|
4
3
|
*
|
|
5
4
|
* Copyright 2017 Google Inc.
|
|
@@ -17,104 +16,100 @@
|
|
|
17
16
|
* See the License for the specific language governing permissions and
|
|
18
17
|
* limitations under the License.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
|
-
* @
|
|
20
|
+
* @file Variable getter field. Appears as a label but has a variable
|
|
23
21
|
* picker in the right-click menu.
|
|
24
22
|
* @author fenichel@google.com (Rachel Fenichel)
|
|
25
23
|
*/
|
|
26
|
-
import * as Blockly from
|
|
24
|
+
import * as Blockly from 'blockly/core'
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* Class for a variable getter field.
|
|
30
28
|
*/
|
|
31
29
|
class FieldVariableGetter extends Blockly.FieldLabel {
|
|
32
|
-
private variable: Blockly.IVariableModel<Blockly.IVariableState> | null =
|
|
33
|
-
null;
|
|
30
|
+
private variable: Blockly.IVariableModel<Blockly.IVariableState> | null = null
|
|
34
31
|
|
|
35
32
|
/**
|
|
36
33
|
* Creates a new FieldVariableGetter.
|
|
37
|
-
*
|
|
38
34
|
* @param allowedVariableType The type of variables this field can display.
|
|
39
35
|
*/
|
|
40
|
-
constructor(private allowedVariableType =
|
|
41
|
-
super(Blockly.Field.SKIP_SETUP)
|
|
42
|
-
this.SERIALIZABLE = true
|
|
36
|
+
constructor(private allowedVariableType = '') {
|
|
37
|
+
super(Blockly.Field.SKIP_SETUP)
|
|
38
|
+
this.SERIALIZABLE = true
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
/**
|
|
46
42
|
* Returns the ID of this field's variable.
|
|
47
|
-
*
|
|
48
43
|
* @returns The ID of this field's variable.
|
|
49
44
|
*/
|
|
50
45
|
getValue(): string {
|
|
51
|
-
return this.variable?.getId() ??
|
|
46
|
+
return this.variable?.getId() ?? ''
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
/**
|
|
55
50
|
* Returns the name of this field's variable.
|
|
56
|
-
*
|
|
57
51
|
* @returns The name of this field's variable.
|
|
58
52
|
*/
|
|
59
53
|
getText(): string {
|
|
60
|
-
return this.variable?.getName() ??
|
|
54
|
+
return this.variable?.getName() ?? ''
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
/**
|
|
64
58
|
* Get the variable model for the variable associated with this field.
|
|
65
59
|
* Not guaranteed to be in the variable map on the workspace (e.g. if accessed
|
|
66
60
|
* after the variable has been deleted).
|
|
67
|
-
*
|
|
68
61
|
* @returns the selected variable, or null if none was selected.
|
|
69
62
|
*/
|
|
70
63
|
getVariable(): Blockly.IVariableModel<Blockly.IVariableState> | null {
|
|
71
|
-
return this.variable
|
|
64
|
+
return this.variable
|
|
72
65
|
}
|
|
73
66
|
|
|
74
67
|
/**
|
|
75
68
|
* Updates this field's variable to one with the given ID.
|
|
76
|
-
*
|
|
77
69
|
* @param newVariableId ID of a variable this field should represent.
|
|
78
70
|
*/
|
|
79
71
|
doValueUpdate_(newVariableId: string) {
|
|
80
|
-
super.doValueUpdate_(newVariableId)
|
|
81
|
-
const workspace = this.getSourceBlock()!.workspace
|
|
82
|
-
this.variable = Blockly.Variables.getVariable(workspace, newVariableId)
|
|
72
|
+
super.doValueUpdate_(newVariableId)
|
|
73
|
+
const workspace = this.getSourceBlock()!.workspace
|
|
74
|
+
this.variable = Blockly.Variables.getVariable(workspace, newVariableId)
|
|
83
75
|
}
|
|
84
76
|
|
|
85
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Informs Blockly that this field depends on a variable.
|
|
79
|
+
* @returns Always true.
|
|
80
|
+
*/
|
|
86
81
|
referencesVariables() {
|
|
87
|
-
return true
|
|
82
|
+
return true
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
/** Rerenders this field when the underlying variable's name changes. */
|
|
91
86
|
refreshVariableName() {
|
|
92
|
-
this.forceRerender()
|
|
87
|
+
this.forceRerender()
|
|
93
88
|
}
|
|
94
89
|
|
|
95
90
|
static fromJson(options: FieldVariableGetterConfig) {
|
|
96
|
-
return new FieldVariableGetter(options
|
|
91
|
+
return new FieldVariableGetter(options.allowedVariableType)
|
|
97
92
|
}
|
|
98
93
|
|
|
99
94
|
fromXml(element: Element) {
|
|
100
|
-
this.setValue(element.getAttribute(
|
|
95
|
+
this.setValue(element.getAttribute('id')!)
|
|
101
96
|
}
|
|
102
97
|
|
|
103
98
|
toXml(element: Element): Element {
|
|
104
|
-
element.setAttribute(
|
|
105
|
-
element.setAttribute(
|
|
106
|
-
element.textContent = this.variable!.getName()
|
|
107
|
-
return element
|
|
99
|
+
element.setAttribute('id', this.variable!.getId())
|
|
100
|
+
element.setAttribute('variabletype', this.variable!.getType())
|
|
101
|
+
element.textContent = this.variable!.getName()
|
|
102
|
+
return element
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
interface FieldVariableGetterConfig extends Blockly.FieldLabelConfig {
|
|
112
|
-
allowedVariableType?: string
|
|
107
|
+
allowedVariableType?: string
|
|
113
108
|
}
|
|
114
109
|
|
|
115
110
|
/**
|
|
116
111
|
* Register the field and any dependencies.
|
|
117
112
|
*/
|
|
118
113
|
export function registerFieldVariableGetter() {
|
|
119
|
-
Blockly.fieldRegistry.register(
|
|
114
|
+
Blockly.fieldRegistry.register('field_variable_getter', FieldVariableGetter)
|
|
120
115
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license
|
|
3
2
|
* Visual Blocks Editor
|
|
4
3
|
*
|
|
5
4
|
* Copyright 2017 Massachusetts Institute of Technology
|
|
@@ -17,25 +16,24 @@
|
|
|
17
16
|
* See the License for the specific language governing permissions and
|
|
18
17
|
* limitations under the License.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
|
-
* @
|
|
20
|
+
* @file Vertical separator field. Draws a vertical line.
|
|
23
21
|
* @author ericr@media.mit.edu (Eric Rosenbaum)
|
|
24
22
|
*/
|
|
25
|
-
import * as Blockly from
|
|
23
|
+
import * as Blockly from 'blockly/core'
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
26
|
* Class for a vertical separator line.
|
|
29
27
|
*/
|
|
30
28
|
class FieldVerticalSeparator extends Blockly.Field {
|
|
31
|
-
private lineElement?: SVGLineElement
|
|
29
|
+
private lineElement?: SVGLineElement
|
|
32
30
|
|
|
33
31
|
constructor() {
|
|
34
|
-
super(Blockly.Field.SKIP_SETUP)
|
|
32
|
+
super(Blockly.Field.SKIP_SETUP)
|
|
35
33
|
/**
|
|
36
34
|
* Editable fields are saved by the XML renderer, non-editable fields are not.
|
|
37
35
|
*/
|
|
38
|
-
this.EDITABLE = false
|
|
36
|
+
this.EDITABLE = false
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
/**
|
|
@@ -43,29 +41,28 @@ class FieldVerticalSeparator extends Blockly.Field {
|
|
|
43
41
|
* @returns The new field instance.
|
|
44
42
|
*/
|
|
45
43
|
static fromJson = function () {
|
|
46
|
-
return new FieldVerticalSeparator()
|
|
47
|
-
}
|
|
44
|
+
return new FieldVerticalSeparator()
|
|
45
|
+
}
|
|
48
46
|
|
|
49
47
|
/**
|
|
50
48
|
* Install this field on a block.
|
|
51
49
|
*/
|
|
52
50
|
initView() {
|
|
53
|
-
const height =
|
|
54
|
-
|
|
55
|
-
this.size_ = new Blockly.utils.Size(1, height);
|
|
51
|
+
const height = 10 * (this.getConstants() as Blockly.zelos.ConstantProvider).GRID_UNIT
|
|
52
|
+
this.size_ = new Blockly.utils.Size(1, height)
|
|
56
53
|
|
|
57
54
|
this.lineElement = Blockly.utils.dom.createSvgElement(
|
|
58
|
-
|
|
55
|
+
'line',
|
|
59
56
|
{
|
|
60
57
|
stroke: (this.sourceBlock_ as Blockly.BlockSvg).getColourSecondary(),
|
|
61
|
-
|
|
58
|
+
'stroke-linecap': 'round',
|
|
62
59
|
x1: 0,
|
|
63
60
|
y1: 0,
|
|
64
61
|
x2: 0,
|
|
65
62
|
y2: height,
|
|
66
63
|
},
|
|
67
|
-
this.fieldGroup_
|
|
68
|
-
)
|
|
64
|
+
this.fieldGroup_,
|
|
65
|
+
)
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
/**
|
|
@@ -76,25 +73,26 @@ class FieldVerticalSeparator extends Blockly.Field {
|
|
|
76
73
|
* @package
|
|
77
74
|
*/
|
|
78
75
|
setLineHeight(newHeight: number) {
|
|
79
|
-
this.lineElement!.setAttribute(
|
|
76
|
+
this.lineElement!.setAttribute('y2', `${newHeight}`)
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
/**
|
|
83
80
|
* Get the value of this field. A no-op in this case.
|
|
81
|
+
* @returns Always null.
|
|
84
82
|
*/
|
|
85
83
|
getValue(): string | null {
|
|
86
|
-
return null
|
|
84
|
+
return null
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
getText() {
|
|
90
|
-
return
|
|
88
|
+
return ''
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
/**
|
|
94
92
|
* Set the value of this field. A no-op in this case.
|
|
95
93
|
*/
|
|
96
94
|
setValue() {
|
|
97
|
-
return
|
|
95
|
+
return
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
/**
|
|
@@ -116,8 +114,5 @@ class FieldVerticalSeparator extends Blockly.Field {
|
|
|
116
114
|
* Register the field and any dependencies.
|
|
117
115
|
*/
|
|
118
116
|
export function registerFieldVerticalSeparator() {
|
|
119
|
-
Blockly.fieldRegistry.register(
|
|
120
|
-
"field_vertical_separator",
|
|
121
|
-
FieldVerticalSeparator
|
|
122
|
-
);
|
|
117
|
+
Blockly.fieldRegistry.register('field_vertical_separator', FieldVerticalSeparator)
|
|
123
118
|
}
|