Base Functions

The TeamSQL Extension SDK comes with base functions you can use to you speed up the development of your own extension.

Each main extension class inherits from Extension class, the base functions are available via this:

this.openURL("https://google.com")

The rest of this article lists the base functions available for your use.

openURL(url: string): void

Opens a new browser window to the given URL

this.openURL("https://google.com")

showAlert(message: string): void

Shows an alert box inside TeamSQL

this.showAlert("Hello!");

openNewTab(value: string): void

Opens a new tab/query editor in TeamSQL. You can set the value populating newly-opened tab by sending a value string.

this.openNewTab("SELECT * FROM actor;");

copyToClipboard(value: string): void

Copies string values to your clipboard

this.copyToClipboard("Copied!");

getActiveEditor(): monaco.editor.IStandaloneCodeEditor

Returns the active tab's code editor as an IStandaloneCodeEditor object

let editor = this.getActiveEditor();

addActionToActiveEditor(action: monaco.editor.IActionDescriptor)

Adds a new action to TeamSQL Code Editor

this.addActionToActiveEditor(
            <monaco.editor.IActionDescriptor>{
                id: 'my-id',
                label: 'My Action',
                keybindings: [monaco.KeyMod.Alt | monaco.KeyMod.Shift | monaco.KeyCode.KEY_F],
                keybindingContext: null,
                contextMenuGroupId: '10',
                run: function (ed) {
                    // Do whatever you want to do when it's clicked
                    return null;
                },
                enablement: {
                    textFocus: true,
                }
            }
        )

results matching ""

    No results matching ""