--- references: - client/document_editor.ts - client/document_editor_js.ts --- Document editors allow you to not only view but also edit files other than markdown. By itself they are just [[Plugs|plugs]] which hook into Silverbullet and provide an editor based on the extension of the file. Silverbullet includes an image viewer by itself to view most image files (`jpg`, `png`, ...). If you are missing an editor and want to build your own look at [[#Development]]. # Usage To get started, you first need to install a plug that provides a document editor (for examples see [[#Available editors]]). Once installed and loaded, you can open the document navigator using `Cmd-o` (Mac) or `Ctrl-o` (Windows, Linux), which works similarly to the page navigator. The only difference is that files which you can open will have their extension highlighted in blue, files for which no document editor is loaded are gray. # Available editors Currently only two major document editors exist (As well as the built-in image viewer). Both are installable through the [[Configuration Manager#Libraries|Library Manager]]. - [PDF viewer](https://github.com/MrMugame/silverbullet-pdf/) - [Excalidraw](https://github.com/LogeshG5/silverbullet-excalidraw) # Development First the editor is defined inside the plug manifest. The `editor` field is used to specify the file extensions your editor can handle. ```yaml name: txteditor functions: TXTEditor: path: ./editor.ts:editor editor: ["txt"] ``` The function provided should look like this. The html tag will be directly inserted into an iframe as the `srcdoc`. This means you can also use the `
` or `` tags. ```typescript export async function editor(): Promise<{ html: string }> { return { html: "