MCPcopy
hub / github.com/RaspberryPiFoundation/blockly / stringToFieldJson

Method stringToFieldJson

packages/blockly/core/block.ts:2204–2213  ·  view source on GitHub ↗

* Turns a string into the JSON definition of a label field. If the string * becomes an empty string when trimmed, this returns null. * * @param str String to turn into the JSON definition of a label field. * @returns The JSON definition or null.

(str: string)

Source from the content-addressed store, hash-verified

2202 * @returns The JSON definition or null.
2203 */
2204 private stringToFieldJson(str: string): {text: string; type: string} | null {
2205 str = str.trim();
2206 if (str) {
2207 return {
2208 'type': 'field_label',
2209 'text': str,
2210 };
2211 }
2212 return null;
2213 }
2214
2215 /**
2216 * Move a named input to a different location on this block.

Callers 2

interpolateArgumentsMethod · 0.95
fieldFromJsonMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected