-
Notifications
You must be signed in to change notification settings - Fork 3.8k
JSON Block Definition interface #9402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
heliacer
wants to merge
16
commits into
RaspberryPiFoundation:main
Choose a base branch
from
heliacer:jsonblockdefs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
052226a
fix: update CSS selector for comment text styling in zelos ConstantPr…
heliacer fe6d967
Merge branch 'google:develop' into develop
heliacer c718910
Merge branch 'google:develop' into develop
heliacer a08da65
add interface, add neccessary output: null to missing json defs, not …
heliacer b24b3aa
Merge branch 'google:develop' into jsonblockdefs
heliacer 568baaa
fix: revert accidental comment selector change not meant for this PR
heliacer d26a001
use existing config
heliacer efac0ee
Merge branch 'RaspberryPiFoundation:main' into jsonblockdefs-feat
heliacer f0868e8
remove enforced output: null, make name optional for input dummies
heliacer 8c62221
fix: re-add output (again) since some were necessary after all
heliacer 25ba1b2
fix: prettier problems
heliacer f62c62e
fix: proposed changes
heliacer 93e0b4c
fix: revert to bracket access
heliacer 92de714
feat: add input_end_row field to JsonBlockDefinition interface
heliacer 750c858
revert: make JsonBlockDefinition optional for now to avoid breaking c…
heliacer 4b38237
fix: final touches (I hope)
heliacer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import {FieldCheckboxFromJsonConfig} from '../field_checkbox.js'; | ||
| import {FieldDropdownFromJsonConfig} from '../field_dropdown'; | ||
| import {FieldImageFromJsonConfig} from '../field_image'; | ||
| import {FieldNumberFromJsonConfig} from '../field_number'; | ||
| import {FieldTextInputFromJsonConfig} from '../field_textinput'; | ||
| import {FieldVariableFromJsonConfig} from '../field_variable'; | ||
heliacer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Defines the JSON structure for a block definition in Blockly. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const blockDef: JsonBlockDefinition = { | ||
| * type: 'custom_block', | ||
| * message0: 'move %1 steps', | ||
| * args0: [ | ||
| * { | ||
| * 'type': 'field_number', | ||
| * 'name': 'INPUT', | ||
| * }, | ||
| * ], | ||
| * previousStatement: null, | ||
| * nextStatement: null, | ||
| * }; | ||
| * ``` | ||
| */ | ||
| export interface JsonBlockDefinition { | ||
| type: string; | ||
| style?: string | null; | ||
| colour?: string | number; | ||
| output?: string | string[] | null; | ||
| previousStatement?: string | string[] | null; | ||
| nextStatement?: string | string[] | null; | ||
| outputShape?: number; | ||
| inputsInline?: boolean; | ||
| tooltip?: string; | ||
| helpUrl?: string; | ||
| extensions?: string[]; | ||
| mutator?: string; | ||
| enableContextMenu?: boolean; | ||
| suppressPrefixSuffix?: boolean; | ||
|
|
||
| [key: `message${number}`]: string | undefined; | ||
| [key: `args${number}`]: BlockArg[] | undefined; | ||
| [key: `implicitAlign${number}`]: string | undefined; | ||
| } | ||
|
|
||
| /** Block Arg */ | ||
| export type BlockArg = | ||
| | InputValueArg | ||
| | InputStatementArg | ||
| | InputDummyArg | ||
| | InputEndRowArg | ||
| | FieldInputArg | ||
| | FieldNumberArg | ||
| | FieldDropdownArg | ||
| | FieldCheckboxArg | ||
| | FieldImageArg | ||
| | FieldVariableArg; | ||
|
|
||
| /** Input Args */ | ||
| interface InputValueArg { | ||
| type: 'input_value'; | ||
| name?: string; | ||
| check?: string | string[]; | ||
| align?: FieldsAlign; | ||
| } | ||
| interface InputStatementArg { | ||
| type: 'input_statement'; | ||
| name?: string; | ||
| check?: string | string[]; | ||
| } | ||
| interface InputDummyArg { | ||
| type: 'input_dummy'; | ||
| name?: string; | ||
| } | ||
heliacer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| interface InputEndRowArg { | ||
| type: 'input_end_row'; | ||
| name?: string; | ||
| } | ||
|
|
||
| /** Field Args */ | ||
| interface FieldInputArg extends FieldTextInputFromJsonConfig { | ||
| type: 'field_input'; | ||
| name?: string; | ||
| } | ||
|
|
||
| interface FieldNumberArg extends FieldNumberFromJsonConfig { | ||
| type: 'field_number'; | ||
| name?: string; | ||
| } | ||
|
|
||
| interface FieldDropdownArg extends FieldDropdownFromJsonConfig { | ||
| type: 'field_dropdown'; | ||
| name?: string; | ||
| } | ||
|
|
||
| interface FieldCheckboxArg extends FieldCheckboxFromJsonConfig { | ||
| type: 'field_checkbox'; | ||
| name?: string; | ||
| } | ||
|
|
||
| interface FieldImageArg extends FieldImageFromJsonConfig { | ||
| type: 'field_image'; | ||
| name?: string; | ||
| } | ||
|
|
||
| interface FieldVariableArg extends FieldVariableFromJsonConfig { | ||
| type: 'field_variable'; | ||
| name?: string; | ||
| } | ||
|
|
||
| export type FieldsAlign = 'LEFT' | 'RIGHT' | 'CENTRE'; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.