There are a range of available events emitted as part of a public & [supported](#support) API for accessing or extending JavaScript libraries and components used in the system.
These are emitted via standard DOM events so can be consumed using standard DOM APIs like so:
Breaking changes of the event API, event names, or event properties, are possible but will be documented in update notes.
The detail provided within the events, and the libraries made accessible, are not considered supported nor stable, and changes to these won't be clearly documented changelogs.
If the event is generic in use but specific to a library, the `<context>` will start with `library-` followed by the library name. Otherwise `<context>` may reflect the UI context/component.
-`editorViewConfig` - An [EditorViewConfig](https://codemirror.net/docs/ref/#view.EditorViewConfig) object that will eventually be passed when creating the CodeMirror EditorView instance.
config.doc = config.doc || "Start this page with a nice story";
});
```
### `editor-markdown::setup`
This event is called when the markdown editor loads, post configuration but before the editor is ready to use.
#### Event Data
-`markdownIt` - A references to the [MarkdownIt](https://markdown-it.github.io/markdown-it/#MarkdownIt) instance used to render markdown to HTML (Just for the preview).
See [this diagrams.net page](https://www.diagrams.net/doc/faq/configure-diagram-editor) for details on the available options for the configure event.
If using a custom diagrams.net instance, via the `DRAWIO` option, you will need to ensure your DRAWIO option URL has the `configure=1` query parameter.
#### Event Data
-`config` - The configuration object that will be passed to diagrams.net.
- This will likely be empty by default, but modify this object in-place as needed with your desired options.
##### Example
```javascript
// Set only the "general" and "android" libraries to show by default
This event is called before the TinyMCE editor, used as the BookStack WYSIWYG page editor, is initialised.
#### Event Data
-`config` - Object containing the configuration that's going to be passed to [tinymce.init](https://www.tiny.cloud/docs/api/tinymce/root_tinymce/#init).
This event is called during the `setup` lifecycle stage of the TinyMCE editor used as the BookStack WYSIWYG editor. This is after configuration, but before the editor is fully loaded and ready to use.
This event is called whenever a CodeMirror instance is loaded, as a method to configure the theme used by CodeMirror. This applies to all CodeMirror instances including in-page code blocks, editors using in BookStack settings, and the Page markdown editor.
#### Event Data
-`darkModeActive` - A boolean to indicate if the current view/page is being loaded with dark mode active.
-`registerViewTheme(builder)` - A method that can be called to register a new view (CodeMirror UI) theme.
-`builder` - A function that will return an object that will be passed into the CodeMirror [EditorView.theme()](https://codemirror.net/docs/ref/#view.EditorView^theme) function as a StyleSpec.
-`registerHighlightStyle(builder)` - A method that can be called to register a new HighlightStyle (code highlighting) theme.
-`builder` - A function, that receives a reference to [Tag.tags](https://lezer.codemirror.net/docs/ref/#highlight.tags) and returns an array of [TagStyle](https://codemirror.net/docs/ref/#language.TagStyle) objects.
##### Example
The below shows registering a custom "Solarized dark" editor and syntax theme: