mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-28 03:33:37 +08:00
921131f999
- 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.
39 lines
1.2 KiB
JavaScript
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;
|