BookStack/resources/js/components/wysiwyg-editor.js
Dan Brown 921131f999
Modularised our tinymce config and plugins
- Split everything into specific plugin/concern files to make things
  more managable. Means original component file is now simple and much
  of the core config is focused in one place.
2022-02-05 23:15:58 +00:00

39 lines
1.2 KiB
JavaScript

import {build as buildEditorConfig} from "../wysiwyg/config";
class WysiwygEditor {
setup() {
this.elem = this.$el;
this.pageId = this.$opts.pageId;
this.textDirection = this.$opts.textDirection;
this.isDarkMode = document.documentElement.classList.contains('dark-mode');
this.tinyMceConfig = buildEditorConfig({
containerElement: this.elem,
darkMode: this.isDarkMode,
textDirection: this.textDirection,
drawioUrl: this.getDrawIoUrl(),
pageId: Number(this.pageId),
translations: {
imageUploadErrorText: this.$opts.imageUploadErrorText,
serverUploadLimitText: this.$opts.serverUploadLimitText,
}
});
window.$events.emitPublic(this.elem, 'editor-tinymce::pre-init', {config: this.tinyMceConfig});
window.tinymce.init(this.tinyMceConfig);
}
getDrawIoUrl() {
const drawioUrlElem = document.querySelector('[drawio-url]');
if (drawioUrlElem) {
return drawioUrlElem.getAttribute('drawio-url');
}
return '';
}
}
export default WysiwygEditor;