scratch-blocks 2.0.7 → 2.1.0

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":"context_menu_items.d.ts","sourceRoot":"","sources":["../../../src/context_menu_items.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,mBAAmB,SAwBlC;AAgBD;;GAEG;AACH,wBAAgB,iBAAiB,SA2ChC;AAsCD;;;GAGG;AACH,wBAAgB,sBAAsB,SAiBrC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,SAsBnC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,SAuBlC"}
1
+ {"version":3,"file":"context_menu_items.d.ts","sourceRoot":"","sources":["../../../src/context_menu_items.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,mBAAmB,SAwBlC;AAgBD;;GAEG;AACH,wBAAgB,iBAAiB,SA2ChC;AAsCD;;;GAGG;AACH,wBAAgB,sBAAsB,SAiBrC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,SAuBnC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,SAwBlC"}
@@ -62,4 +62,17 @@ interface ScratchBlocksOptions extends Blockly.BlocklyOptions {
62
62
  scratchTheme?: ScratchBlocksTheme;
63
63
  }
64
64
  export declare function inject(container: Element, options: ScratchBlocksOptions): Blockly.WorkspaceSvg;
65
+ /**
66
+ * Returns true when a specific content node (block, comment, etc.) within the
67
+ * Blockly workspace has keyboard focus, as opposed to the workspace background
68
+ * itself or nothing at all.
69
+ *
70
+ * Host applications can use this to decide whether to handle a keyboard event
71
+ * themselves or defer to Blockly. When this returns false and the workspace SVG
72
+ * has DOM focus, key presses should be treated as if the workspace background
73
+ * is focused and the host UI hierarchy should handle them normally (e.g. for
74
+ * Scratch's key-sensing).
75
+ * @returns True if a content node has focus, false otherwise.
76
+ */
77
+ export declare function isContentNodeFocused(): boolean;
65
78
  //# sourceMappingURL=index.d.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,EAAE,CAAA;AAC7B,OAAO,EAAE,yBAAyB,EAAE,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAA;AACvC,OAAO,EAAE,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,wBAmDvE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAG9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scratch-blocks",
3
- "version": "2.0.7",
3
+ "version": "2.1.0",
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",
@@ -35,7 +35,7 @@
35
35
  "@commitlint/cli": "20.4.3",
36
36
  "@commitlint/config-conventional": "20.4.3",
37
37
  "eslint": "9.39.4",
38
- "eslint-config-scratch": "14.0.3",
38
+ "eslint-config-scratch": "14.0.6",
39
39
  "husky": "9.1.7",
40
40
  "prettier": "3.8.1",
41
41
  "scratch-semantic-release-config": "4.0.1",
@@ -163,6 +163,7 @@ export function registerCopyShortcut() {
163
163
  Blockly.ShortcutRegistry.registry.register(
164
164
  {
165
165
  ...original,
166
+ allowCollision: true, // we're intentionally overriding the default handler
166
167
  callback(workspace, e, shortcut, scope) {
167
168
  const focused = scope.focusedNode
168
169
  if (focused instanceof Blockly.BlockSvg && !focused.isInFlyout) {
@@ -178,7 +179,7 @@ export function registerCopyShortcut() {
178
179
  return original.callback?.(workspace, e, shortcut, scope) ?? false
179
180
  },
180
181
  },
181
- true,
182
+ true, // allowOverrides: we're intentionally overriding the default handler
182
183
  )
183
184
  }
184
185
 
@@ -191,6 +192,7 @@ export function registerCutShortcut() {
191
192
  Blockly.ShortcutRegistry.registry.register(
192
193
  {
193
194
  ...original,
195
+ allowCollision: true, // we're intentionally overriding the default handler
194
196
  callback(workspace, e, shortcut, scope) {
195
197
  const focused = scope.focusedNode
196
198
  if (focused instanceof Blockly.BlockSvg && !focused.isInFlyout) {
@@ -207,6 +209,6 @@ export function registerCutShortcut() {
207
209
  return original.callback?.(workspace, e, shortcut, scope) ?? false
208
210
  },
209
211
  },
210
- true,
212
+ true, // allowOverrides: we're intentionally overriding the default handler
211
213
  )
212
214
  }
package/src/index.ts CHANGED
@@ -144,6 +144,23 @@ export function inject(container: Element, options: ScratchBlocksOptions) {
144
144
  return workspace
145
145
  }
146
146
 
147
+ /**
148
+ * Returns true when a specific content node (block, comment, etc.) within the
149
+ * Blockly workspace has keyboard focus, as opposed to the workspace background
150
+ * itself or nothing at all.
151
+ *
152
+ * Host applications can use this to decide whether to handle a keyboard event
153
+ * themselves or defer to Blockly. When this returns false and the workspace SVG
154
+ * has DOM focus, key presses should be treated as if the workspace background
155
+ * is focused and the host UI hierarchy should handle them normally (e.g. for
156
+ * Scratch's key-sensing).
157
+ * @returns True if a content node has focus, false otherwise.
158
+ */
159
+ export function isContentNodeFocused(): boolean {
160
+ const node = Blockly.getFocusManager().getFocusedNode()
161
+ return node !== null && !(node instanceof Blockly.WorkspaceSvg)
162
+ }
163
+
147
164
  registerContinuousToolbox()
148
165
  Blockly.Scrollbar.scrollbarThickness = Blockly.Touch.TOUCH_ENABLED ? 14 : 11
149
166
  Blockly.FlyoutButton.TEXT_MARGIN_X = 40