94 lines
3.0 KiB
Markdown
94 lines
3.0 KiB
Markdown
# LMathPluginAPI
|
|
|
|
This is a documentation-ish for the `LMathPluginAPI` object, revealed to plugins at the init phase.
|
|
|
|
## Common
|
|
These methods and variables are available on both the backend part and the frontend part.
|
|
|
|
### api.getLogger()
|
|
Returns the `log4js` logger.
|
|
|
|
### api.getVersion()
|
|
Returns current L'Math version.
|
|
|
|
### api.getSettings()
|
|
Returns the settings object. If you need to modify settings, please see ___ (WIP).
|
|
|
|
### api.getUserSetting()
|
|
Returns the user settings object. If you need to modify settings, please see ___ (WIP).
|
|
|
|
----
|
|
|
|
### api.events
|
|
The event-specific API
|
|
#### events.on(eventName, callback)
|
|
Allows you to listen to L'Math-specific events.
|
|
#### events.fire(eventName, eventData)
|
|
Allows you to fire a custom-named event. The data will be passed as
|
|
|
|
----
|
|
|
|
### api.messages
|
|
The messaging-specific API
|
|
#### messages.on(messageName, callback)
|
|
Allows you to listen to plugin-specific IPC messages between the backend and the frontend.
|
|
Any data sent will be passed as an argument to the callback function.
|
|
**Just like with regular ipc messaging, you can't send functions or other non-json types.**
|
|
#### messages.send(messageName, messageData)
|
|
Allows you to send plugin-specific IPC messages between the backend and the frontend.
|
|
The messageData object will be converted to JSON and passed as a parsed object to any listeners on the other process.
|
|
**Just like with regular ipc messaging, you can't send functions or other non-json types.**
|
|
|
|
|
|
|
|
## Backend
|
|
|
|
### events
|
|
|
|
* `fileOpened`
|
|
* Called when a file has been succesfully opened
|
|
* Event data:
|
|
* `file` - the absolute path to the file
|
|
* `content` - a brief content description of the file
|
|
* `fileSaved`
|
|
* Called when a file has been succesfully saved
|
|
* Event data:
|
|
* `file` - the absolute path to the file
|
|
|
|
## Frontend
|
|
|
|
### events
|
|
* `worksheetLoading`
|
|
* Called when a worksheet is being loaded
|
|
* `worksheetOpened`
|
|
* Called when a worksheet has been opened (probably from a file)
|
|
* Event data:
|
|
* `content` - the brief contents of the file, **can be modified**, but please don't
|
|
* `worksheetSaved`
|
|
* Called when a worksheet has been saved
|
|
* `worksheetReset`
|
|
* Called when a new worksheet has been initialized
|
|
* `formulaRender`
|
|
* Called before a LaTeX formula is sent to the renderer
|
|
* Event data:
|
|
* `latex` - the LaTeX input, **can be modified**
|
|
* `pageSave`
|
|
* Called before saving the contents of a page
|
|
* Event data:
|
|
* `pageId` - the id of the page
|
|
* `content` - the HTML content, **can be modified**
|
|
* `data` - page metadata object, **can be modified**
|
|
* `pageLoad`
|
|
* Called before loading a page
|
|
* Event data
|
|
* `pageId` - the id of the page to be loaded
|
|
* `pageLoaded`
|
|
* Called when a page has been loaded and is about to be shown
|
|
* Event data
|
|
* `content` - the HTML content, **can be modified**
|
|
* `pageAdd`
|
|
* Called when a page is about to be created
|
|
* Event data:
|
|
* `pageName` - the name of the new page, **can be modified**
|
|
|