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.
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.
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.
- Download the code and open the xcode project.
- Build the plugin
- SQLEditor plugins should be located in the directory:
~/Library/Application Support/SQLEditor/Plugins/
- Change the document dialect to the name of the plugin In this example code, the plugin is currently "SQLEditor Example Plugin"
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
- Plugins can't do diff support yet
- No database support
- No import support
- No dialect specific types list yet
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
Please send suggestions, feedback or bug reports to support@malcolmhardie.com
Suggestions on more ideomatic javascript or any other technical improvements are extremely welcome.