AngusHardie / SQLEditorJSPlugin

Example Javascript based plugin for SQLEditor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQLEditorJSPlugin

Example Javascript based plugin for SQLEditor

This project demonstrates how to write a simple export plugin for SQLEditor using Javascript.

This code is mostly the same as the bundled HTML Report plugin that ships with SQLEditor, except that it doesn't have a binary component and the plugin type is export rather than report.

The binary component in the plugin bundled with SQLEditor is to work around an obscure code signing issue and doesn't actually do anything.

Report instead or Export

Plugins are currently either export type or report type.

  • Export plugins offer new document dialects for the source sidebar and the Export To File panel. You add a section to the exportTypes dictionary in the Info.plist file.
  • Report plugins appear in the Save Report panel. You add a section to the reportTypes dictionary in the Info.plist file.

Structure

The pure JS plugin consists of a bundle, an Info.plist file and some javascript.

The Info.plist file specifies the main javascript file (under the scriptFile key) for the plugin. You can also evaluate other javscript files.

Building

  • Download the code and open the xcode project.
  • Build the plugin

Installing

  • SQLEditor plugins should be located in the directory:
    ~/Library/Application Support/SQLEditor/Plugins/

Using the plugin

  • Change the document dialect to the name of the plugin In this example code, the plugin is currently "SQLEditor Example Plugin"

Live Editing

Once you have installed the plugin, you can actually edit while SQLEditor is open.

You will need to hit the manual refresh button above the source view

Limtations

  • Plugins can't do diff support yet
  • No database support
  • No import support
  • No dialect specific types list yet

SQLEditor specific additions

There is a SQLEditorJS object which offers some special functions:

SQLEditorJS.evaluate(filename)

This method loads and then evaluates the specified Javascript file, it should be located in the Resources directory of the plugin

SQLEditor.contentsOfFile(filename)

This method loads and returns the contents of the specified file, it should be located in the Resources directory of the plugin

Feedback

Please send suggestions, feedback or bug reports to support@malcolmhardie.com

Suggestions on more ideomatic javascript or any other technical improvements are extremely welcome.

About

Example Javascript based plugin for SQLEditor


Languages

Language:JavaScript 100.0%