+ return new SimpleWysiwygEditorInterface(context);
+}
+
+export function createBasicEditorInstance(container: HTMLElement, htmlContent: string, options: Record<string, any> = {}): SimpleWysiwygEditorInterface {
+ const editor = createEditor({
+ namespace: 'BookStackBasicEditor',
+ nodes: getNodesForBasicEditor(),
+ onError: console.error,
+ theme: theme,
+ });
+ const context: EditorUiContext = buildEditorUI(container, editor, options);
+ editor.setRootElement(context.editorDOM);
+
+ const editorTeardown = mergeRegister(
+ registerRichText(editor),
+ registerHistory(editor, createEmptyHistoryState(), 300),
+ registerShortcuts(context),
+ registerAutoLinks(editor),
+ );
+
+ // Register toolbars, modals & decorators
+ context.manager.setToolbar(getBasicEditorToolbar(context));
+ context.manager.registerContextToolbar('link', contextToolbars.link);
+ context.manager.registerModal('link', modals.link);
+ context.manager.onTeardown(editorTeardown);
+
+ setEditorContentFromHtml(editor, htmlContent);
+
+ return new SimpleWysiwygEditorInterface(context);