The Editor plugin API allows biblios to load new editor types. Each editor type is associated with a specific record syntax. When a record is opened, the record syntax is checked and the appropriate editor is called upon to load the record and generate an editor for it. When biblios saves a record, it asks the editor plugin for the current XML of the record.
Each Editor plugin should support the following API as a javascript object:
Constructor
function(editorid)
The constructor should accept a string parameter called 'editorid'. This is the id of the div in which the editor will be placed. The editor plugin should use this editorid to retrieve data from the editor and to manipulate data in the editor.
XML related methods
These methods relate to loading xml from biblios into the editor and returning xml from the editor to biblios.
loadXml(xmldoc, callback)
This method is called by biblios when opening a record. The method is passed an xml DOM document and a callback function. The editor plugin should use this xml DOM document to generate an editor for the document. After generating the editor, it should call the callback.
XMLString()
This method is called by biblios when saving a record. It should return the current XML representation of the editor's document as a string.
XML()
This method should return the same XML document as XMLString, but as a DOM document.
update()
This method is called by biblios to force the editor plugin to do whatever it needs to do to refresh the xml document it returns from XMLString() and XML().
Processing and editing methods
These methods relate to processing records and creating toolbars for the editor tabs.
postProcess()
This method is called by biblios after loadXml(). It allows the plugin a chance to do any further processing of the record, such as adding particular styles to fields or adding enhanced behaviors.
processForLocation(location)
This method is called by biblios to ask the editor plugin to do any additional processing required for the 'location' passed in as a parameter.
getToolsMenu()
This method is called by biblios to populate the Commands editor menu with menu items.
getToolbar(editorid)
This method is called by biblios to create the editor toolbar (of which the Commands menu is one part).
Metadata retrieval methods
These methods allow biblios to query the editor plugin for particular pieces of the record it is responsible for editing, such as title, author, etc.
getFormat()
This method should return the format of the record.
getTitle()
getAuthor()
getDate()
getPublisher()
getControlNumber()
These methods return the obvious pieces of the record for display in the biblios Save folders.
Record previews
Each editor plugin is called upon by biblios to return an xsl DOM document suitable for creating a preview for records using its syntax. This is setup by a call like this in the editor plugin:
biblios.app.registerPreviewXsl('marc21', marcxsl);
Editor plugin configuration
Editor plugins are configured in the main biblios configuration file, biblios.xml.
Each editor type gets a section like the following under the
<editors>
section:
<editor> <name>MARC21Editor</name> <syntax>marc21</syntax> <enabled>1</enabled> </editor>
The
<plugin> <name>MARC21Editor</name> <type>editor</type> <file>plugins/marc21editor/marc21editor.js</file> <initcall>new MarcEditor(editorid)</initcall> <enabled>1</enabled> <allowDelete>0</allowDelete> <allowModify>0</allowModify> <xslpath>/plugins/marc21editor/</xslpath> </plugin>
The most important elements of the preceding plugin editor configuration stanza are <name>, <file> and <initcall>.
<file> is used by biblios to load the plugin's javascript file via $.getScript().
<initcall> is used by biblios' openRecord() function to create a new object of that plugin type by eval'ing the text of the <initcall>.