Last active
May 13, 2020 19:56
-
-
Save dullbananas/e6046c5e20159ec6895da97efe6185a6 to your computer and use it in GitHub Desktop.
EditSC extension API concept
This file contains 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
declare const editsc; // Tells TypeScript that this variable is defined elsewhere | |
editsc.init({ | |
useVersion: "1.0", // The version of the extension API to use | |
name: "Basics", | |
}); | |
// Defines an action allowing the user to select a | |
// block and replace it with a different block | |
editsc.action({ | |
context: editsc.context.singleBlock, | |
name: "Set block", | |
options: [ | |
editsc.option.block("newBlock"), | |
], | |
ui: [ | |
editsc.ui.input("newBlock", {label: "New block"}), // The new block to replace the old one with | |
editsc.ui.button("Set block", function(ctx, opt) { | |
ctx.block.replace(opt.newBlock); | |
}), | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment