-
Notifications
You must be signed in to change notification settings - Fork 0
Applications [Set Content]
Julian Curtis-Zilius edited this page May 17, 2018
·
6 revisions
Each application has its own content area in the CanvasTools Control Panel. Applications can set text inside that can be updated on the fly as well as adding custom buttons to perform actions. Using the Set Content
method must be used AFTER you have registered your application and stored your tokenID
.
-
tokenID
:String
Submit the ID of the token you received when you first used the register API on your application. -
content
:String
HTML you want to display in the application content area. You can use this to provide details on the status of your application, the user's information, etc. -
buttons
:Array
An array ofbutton
s your application will contain. -
button
:Object
An object that goes inside thebuttons
array. -
button.name
:String
The name of the button that will be displayed to the user. -
button.link
:String
The URL the button will navigate to when clicked.
// The ID of the CanvasTools Chrome Extension (Don't change this)
var editorExtensionId = "gmdmngbeceipkojacdoljnllcnfpdgce";
// The ID of the CanvasTools Chrome Extension (Don't change this)
var application = {
setContent: {
tokenID: response.tokenID,
content: '<h4>Welcome to the CanvasTools Application Demo Content Area!</h4>',
buttons: [
{
name: 'Open Demo',
link: 'https://canvastools-demo.glitch.me/'
},
{
name: 'Open Google',
link: 'https://google.com'
}
]
}
}
chrome.runtime.sendMessage(editorExtensionId, {application: application}, function(response) {
if (response === false) {
alert('Could not set application content!')
} else {
console.log(response)
}
});
Executing the above code would result in a message popup that looks like this: