scratch-blocks 2.1.1 → 2.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"procedures.d.ts","sourceRoot":"","sources":["../../../../src/blocks/procedures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH;;GAEG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAIvC;;GAEG;AACH,KAAK,aAAa,GAAG,MAAM,CACzB,MAAM,EACN;IACE,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAA;CACxB,GAAG,IAAI,CACT,CAAA;AAED;;GAEG;AACH,aAAK,YAAY;IACf,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,OAAO,MAAM;CACd;AA2gCD,UAAU,cAAe,SAAQ,OAAO,CAAC,QAAQ;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,oBAAoB,EAAE,MAAM,aAAa,CAAA;IACzC,sBAAsB,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,CAAA;IAC9D,gBAAgB,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,CAAA;IACxD,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,iBAAiB,EAAE,CACjB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,aAAa,EAC5B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,OAAO,CAAC,KAAK,KACjB,IAAI,CAAA;IACT,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC3C;AAED,MAAM,WAAW,yBAA0B,SAAQ,cAAc;I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E,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAClF,cAAc,OAAO,CAAA;AAErB,UAAU,oBAAqB,SAAQ,OAAO,CAAC,cAAc;IAC3D;;;OAGG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAA;CAClC;AASD,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,wBAkDvE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scratch-blocks",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Scratch Blocks is a library for building creative computing interfaces.",
5
5
  "author": "Massachusetts Institute of Technology",
6
6
  "license": "Apache-2.0",
@@ -24,7 +24,8 @@
24
24
  "prepare": "husky || true",
25
25
  "start": "webpack serve --open --mode development",
26
26
  "test": "echo \"Error: no test specified\" && exit 1",
27
- "test:lint": "eslint && prettier --check ."
27
+ "test:lint": "eslint && prettier --check .",
28
+ "watch": "webpack --mode development --watch"
28
29
  },
29
30
  "dependencies": {
30
31
  "@blockly/continuous-toolbox": "^7.0.8",
@@ -32,10 +33,10 @@
32
33
  "blockly": "^12.4.1"
33
34
  },
34
35
  "devDependencies": {
35
- "@commitlint/cli": "20.4.3",
36
- "@commitlint/config-conventional": "20.4.3",
36
+ "@commitlint/cli": "20.5.0",
37
+ "@commitlint/config-conventional": "20.5.0",
37
38
  "eslint": "9.39.4",
38
- "eslint-config-scratch": "14.0.6",
39
+ "eslint-config-scratch": "14.0.11",
39
40
  "husky": "9.1.7",
40
41
  "prettier": "3.8.1",
41
42
  "scratch-semantic-release-config": "4.0.1",
@@ -570,10 +570,7 @@ function populateArgumentOnDeclaration_(
570
570
  oldBlock = saveInfo?.block ?? null
571
571
  }
572
572
 
573
- // TODO: This always returns false, because it checks for argument reporter
574
- // blocks instead of argument editor blocks. Create a new version for argument
575
- // editors.
576
- const oldTypeMatches = checkOldTypeMatches_(oldBlock, type)
573
+ const oldTypeMatches = checkOldEditorTypeMatches_(oldBlock, type)
577
574
  const displayName = this.displayNames_[index]
578
575
 
579
576
  // Decide which block to attach.
@@ -591,13 +588,13 @@ function populateArgumentOnDeclaration_(
591
588
  }
592
589
 
593
590
  /**
594
- * Check whether the type of the old block corresponds to the given argument
595
- * type.
591
+ * Check whether the type of the old argument reporter block corresponds to the
592
+ * given argument type.
596
593
  * @param oldBlock The old block to check.
597
- * @param type The argument type. One of 'n', 'n', or 's'.
594
+ * @param type The argument type. One of 'n', 'b', or 's'.
598
595
  * @returns True if the type matches, false otherwise.
599
596
  */
600
- function checkOldTypeMatches_(oldBlock: Blockly.BlockSvg | null, type: string): boolean {
597
+ function checkOldTypeMatches_(oldBlock: Blockly.BlockSvg | null, type: ArgumentType): boolean {
601
598
  if (!oldBlock) {
602
599
  return false
603
600
  }
@@ -613,6 +610,29 @@ function checkOldTypeMatches_(oldBlock: Blockly.BlockSvg | null, type: string):
613
610
  return false
614
611
  }
615
612
 
613
+ /**
614
+ * Check whether the type of the old argument editor block corresponds to the
615
+ * given argument type.
616
+ * @param oldBlock The old block to check.
617
+ * @param type The argument type. One of 'n', 'b', or 's'.
618
+ * @returns True if the type matches, false otherwise.
619
+ */
620
+ function checkOldEditorTypeMatches_(oldBlock: Blockly.BlockSvg | null, type: ArgumentType): boolean {
621
+ if (!oldBlock) {
622
+ return false
623
+ }
624
+ if (
625
+ (type === ArgumentType.NUMBER || type === ArgumentType.STRING) &&
626
+ oldBlock.type === 'argument_editor_string_number'
627
+ ) {
628
+ return true
629
+ }
630
+ if (type === ArgumentType.BOOLEAN && oldBlock.type === 'argument_editor_boolean') {
631
+ return true
632
+ }
633
+ return false
634
+ }
635
+
616
636
  /**
617
637
  * Create an argument editor.
618
638
  * An argument editor is a shadow block with a single text field, which is used
@@ -856,6 +876,26 @@ function updateArgumentReporterNames_(
856
876
  }
857
877
  }
858
878
 
879
+ /**
880
+ * Override showContextMenu on an argument reporter block so that right-clicks
881
+ * while the block is seated inside a procedures_prototype delegate up to the
882
+ * prototype (which in turn delegates to the parent procedures_definition).
883
+ * When the reporter has been dragged out and lives elsewhere, it keeps its
884
+ * normal context menu.
885
+ * @param block The argument reporter block to configure.
886
+ */
887
+ function delegateContextMenuToPrototypeParent(block: Blockly.BlockSvg) {
888
+ const origShowContextMenu = block.showContextMenu.bind(block)
889
+ block.showContextMenu = function (this: Blockly.BlockSvg, e: Event) {
890
+ const parent = this.getParent()
891
+ if (parent?.type === 'procedures_prototype') {
892
+ parent.showContextMenu(e)
893
+ } else {
894
+ origShowContextMenu(e)
895
+ }
896
+ }
897
+ }
898
+
859
899
  Blockly.Blocks.procedures_definition = {
860
900
  /**
861
901
  * Block for defining a procedure with no return value.
@@ -923,6 +963,18 @@ Blockly.Blocks.procedures_prototype = {
923
963
  this.setDeletable(false)
924
964
  this.setDragStrategy(new DelegateToParentDraggable(this))
925
965
 
966
+ // Delegate right-clicks to the parent define block so that "Add Comment",
967
+ // "Edit", etc. act on the definition rather than the prototype itself.
968
+ const protoOrigShowContextMenu = this.showContextMenu.bind(this)
969
+ this.showContextMenu = function (this: Blockly.BlockSvg, e: Event) {
970
+ const parent = this.getParent()
971
+ if (parent) {
972
+ parent.showContextMenu(e)
973
+ } else {
974
+ protoOrigShowContextMenu(e)
975
+ }
976
+ }
977
+
926
978
  /* Data known about the procedure. */
927
979
  this.procCode_ = ''
928
980
  this.displayNames_ = []
@@ -1018,6 +1070,7 @@ Blockly.Blocks.argument_reporter_boolean = {
1018
1070
  extensions: ['colours_more', 'output_boolean'],
1019
1071
  })
1020
1072
  this.setDragStrategy(new DuplicateOnDragDraggable(this))
1073
+ delegateContextMenuToPrototypeParent(this)
1021
1074
  },
1022
1075
  }
1023
1076
 
@@ -1035,6 +1088,7 @@ Blockly.Blocks.argument_reporter_string_number = {
1035
1088
  extensions: ['colours_more', 'output_number', 'output_string'],
1036
1089
  })
1037
1090
  this.setDragStrategy(new DuplicateOnDragDraggable(this))
1091
+ delegateContextMenuToPrototypeParent(this)
1038
1092
  },
1039
1093
  }
1040
1094
 
@@ -182,7 +182,7 @@ const PROCEDURE_DEF_CONTEXTMENU = function (this: Blockly.Block) {
182
182
 
183
183
  // Find and remove the duplicate option
184
184
  for (let i = 0, option; (option = menuOptions[i]); i++) {
185
- if (option.text == Blockly.Msg.DUPLICATE) {
185
+ if (option.text == Blockly.Msg.DUPLICATE_BLOCK) {
186
186
  menuOptions.splice(i, 1)
187
187
  break
188
188
  }
package/src/css.ts CHANGED
@@ -17,6 +17,7 @@
17
17
  * limitations under the License.
18
18
  */
19
19
  import * as Blockly from 'blockly/core'
20
+ import { Colours } from './colours'
20
21
 
21
22
  const styles = `
22
23
  .blocklySvg {
@@ -287,9 +288,12 @@ const styles = `
287
288
  cursor: -moz-grabbing;
288
289
  }
289
290
 
290
- /* All the blocks being dragged get the blocklyDragging class, so match only the root one */
291
+ /* All the blocks being dragged get the blocklyDragging class, so match only the root one.
292
+ Using a CSS drop-shadow rather than an SVG filter reference avoids a Safari bug where
293
+ url("#blocklyDragShadowFilter") fails to resolve across SVG document boundaries when
294
+ the block is on the drag surface (a separate <svg> from the main workspace). */
291
295
  :not(.blocklyDragging) > .blocklyDragging {
292
- filter: url(#blocklyDragShadowFilter);
296
+ filter: drop-shadow(0px 0px 6px rgba(0, 0, 0, ${Colours.dragShadowOpacity}));
293
297
  }
294
298
 
295
299
  /* Changes cursor on mouse down. Not effective in Firefox because of
@@ -1208,6 +1212,15 @@ const styles = `
1208
1212
  .blocklyInsertionMarker > g:not(:last-child) {
1209
1213
  visibility: hidden;
1210
1214
  }
1215
+
1216
+ /* Safari does not expand SVG elements to fill their absolutely-positioned
1217
+ container using top/left/right/bottom alone — it uses the SVG intrinsic
1218
+ size (300x150) instead. Explicit width/height ensures the drag surface SVG
1219
+ fills the injection div so dragged blocks are not clipped. */
1220
+ .blocklyBlockDragSurface, .blocklyAnimationLayer {
1221
+ width: 100%;
1222
+ height: 100%;
1223
+ }
1211
1224
  `
1212
1225
 
1213
1226
  Blockly.Css.register(styles)
package/src/index.ts CHANGED
@@ -56,7 +56,6 @@ import './scratch_insertion_marker_previewer'
56
56
  import './scratch_variable_map'
57
57
  import './scratch_variable_model'
58
58
  import { ScratchZoomControls } from './scratch_zoom_controls'
59
- import { buildShadowFilter } from './shadows'
60
59
  import { registerStatusIndicatorLabelFlyoutInflater } from './status_indicator_label_flyout_inflater'
61
60
  import * as ScratchVariables from './variables'
62
61
 
@@ -120,7 +119,6 @@ export function inject(container: Element, options: ScratchBlocksOptions) {
120
119
  const workspace = Blockly.inject(container, options)
121
120
 
122
121
  buildGlowFilter(workspace)
123
- buildShadowFilter(workspace)
124
122
 
125
123
  // Replace Blockly's sprite-sheet zoom controls with SVG-file-based ones so
126
124
  // each button is a separate file and the correct set is picked up via
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright 2024 Google LLC
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import * as Blockly from 'blockly/core';
6
- /**
7
- * Creates an SVG filter to apply drop shadows to blocks being dragged and
8
- * inserts it into the DOM.
9
- * @param workspace The workspace whose SVG will receive the filter definition.
10
- */
11
- export declare function buildShadowFilter(workspace: Blockly.WorkspaceSvg): void;
12
- //# sourceMappingURL=shadows.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shadows.d.ts","sourceRoot":"","sources":["../../../src/shadows.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAGvC;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,YAAY,QA+ChE"}
package/src/shadows.ts DELETED
@@ -1,60 +0,0 @@
1
- /**
2
- * Copyright 2024 Google LLC
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import * as Blockly from 'blockly/core'
6
- import { Colours } from './colours'
7
-
8
- /**
9
- * Creates an SVG filter to apply drop shadows to blocks being dragged and
10
- * inserts it into the DOM.
11
- * @param workspace The workspace whose SVG will receive the filter definition.
12
- */
13
- export function buildShadowFilter(workspace: Blockly.WorkspaceSvg) {
14
- const svg = workspace.getParentSvg()
15
- const defs = Blockly.utils.dom.createSvgElement(Blockly.utils.Svg.DEFS, {}, svg)
16
- // Adjust these width/height, x/y properties to stop the shadow from clipping
17
- const dragShadowFilter = Blockly.utils.dom.createSvgElement(
18
- 'filter',
19
- {
20
- id: 'blocklyDragShadowFilter',
21
- height: '140%',
22
- width: '140%',
23
- y: '-20%',
24
- x: '-20%',
25
- },
26
- defs,
27
- )
28
- Blockly.utils.dom.createSvgElement(
29
- 'feGaussianBlur',
30
- {
31
- in: 'SourceAlpha',
32
- stdDeviation: '6',
33
- },
34
- dragShadowFilter,
35
- )
36
- const componentTransfer = Blockly.utils.dom.createSvgElement(
37
- 'feComponentTransfer',
38
- { result: 'offsetBlur' },
39
- dragShadowFilter,
40
- )
41
- // Shadow opacity is specified in the adjustable colour library,
42
- // since the darkness of the shadow largely depends on the workspace colour.
43
- Blockly.utils.dom.createSvgElement(
44
- 'feFuncA',
45
- {
46
- type: 'linear',
47
- slope: Colours.dragShadowOpacity,
48
- },
49
- componentTransfer,
50
- )
51
- Blockly.utils.dom.createSvgElement(
52
- 'feComposite',
53
- {
54
- in: 'SourceGraphic',
55
- in2: 'offsetBlur',
56
- operator: 'over',
57
- },
58
- dragShadowFilter,
59
- )
60
- }