Skip to content

Instantly share code, notes, and snippets.

@dullbananas
Last active May 13, 2020 19:56
Show Gist options
  • Save dullbananas/e6046c5e20159ec6895da97efe6185a6 to your computer and use it in GitHub Desktop.
Save dullbananas/e6046c5e20159ec6895da97efe6185a6 to your computer and use it in GitHub Desktop.
EditSC extension API concept
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