-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathexample.ts
More file actions
33 lines (27 loc) · 1.04 KB
/
example.ts
File metadata and controls
33 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ArgumentType, BlockType, BlockUtilityWithID, Environment, extension, scratch } from "$common";
import formatMessage from './format-message'; // This should actually be an npm package and thus be 'format-message'
const details = {
name: "Some Blocks",
description: "A demonstration of some blocks",
iconURL: "example.png",
insetIconURL: "thumbnail.svg"
}
export default class SomeBlocks extends extension(details) {
init(env: Environment) { }
@(scratch.reporter`letter ${
{
type: "string",
defaultValue: 'text',
options: [{ text: 'Item One', value: 'itemId1' },'itemId2']
}
} of ${{ type: "number", defaultValue: 1 }}`)
myReporter(text: string, letterNum: number, util: BlockUtilityWithID) {
const message = formatMessage({
id: 'myReporter.result',
default: 'Letter {letterNum} of {text} is {result}.',
description: 'The text template for the "myReporter" block result'
});
const result = text.charAt(letterNum);
return message.format({ text, letterNum, result });
}
}