Update api.md

This commit is contained in:
Roni Lehto 2021-04-07 19:36:38 +00:00
parent 3775394805
commit 4fbaa63794

View File

@ -5,9 +5,6 @@ This is a documentation-ish for the `LMathPluginAPI` object, revealed to plugins
## Common ## Common
These methods and variables are available on both the backend part and the frontend part. These methods and variables are available on both the backend part and the frontend part.
### api.getLogger()
Returns the `log4js` logger.
### api.getVersion() ### api.getVersion()
Returns current L'Math version. Returns current L'Math version.
@ -43,6 +40,19 @@ The messageData object will be converted to JSON and passed as a parsed object t
## Backend ## Backend
### api.getSessionId() (`String`)
Returns the current session identifier
### api.getLogger() (lo4js logger)
Returns the `log4js` logger.
### api.getWindow() (`BrowserWindow`)
Returns the main Electron window of the app
### api.getDataFolder() (`String`)
Returns the absolute path to L'Math's data folder
### api.getTempFolder() (`String`)
Returns the absolute path to the session-specific temp folder
### api.getPluginsFolder() (`String`)
Returns the absolute path to L'Math's plugin folder
### events ### events
* `fileOpened` * `fileOpened`
@ -54,6 +64,25 @@ The messageData object will be converted to JSON and passed as a parsed object t
* Called when a file has been succesfully saved * Called when a file has been succesfully saved
* Event data: * Event data:
* `file` - the absolute path to the file * `file` - the absolute path to the file
* `pageImport`
* Called when a page is about to be loaded from file (and possibly safe-checked)
* Event data:
* `pageId` - the id of the page
* `content` - the HTML contents, **can be modified**
* `pageLoaded`
* Called when a page has been loaded (from file or from cache) and is about to be sent to the frontend
* Event data
* `pageId` - the id of the page
* `content` - the HTML contents, **can be modified**
* `pageSave`
* Called before saving a page to its temporary file
* Event data
* `pageId` - the id of the page
* `content` - the HTML contents, **can be modified**
* `pageSaved`
* Called when a page has been succesfully saved to its temporary file
* Event data
* `pageId` - the id of the page
## Frontend ## Frontend