mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-08 01:50:57 +00:00
Service provider and other cleanup
- Removed old 'exposeTranslations' system to instead use new component option system. - Extracted validation rules into their own service provider. - Cleaned up some formatting/comments in the repos.
This commit is contained in:
parent
5e01c30882
commit
66917520cb
10 changed files with 45 additions and 47 deletions
resources/js/components
|
@ -13,6 +13,7 @@ class MarkdownEditor {
|
|||
|
||||
this.pageId = this.$opts.pageId;
|
||||
this.textDirection = this.$opts.textDirection;
|
||||
this.imageUploadErrorText = this.$opts.imageUploadErrorText;
|
||||
|
||||
this.markdown = new MarkdownIt({html: true});
|
||||
this.markdown.use(mdTasksLists, {label: true});
|
||||
|
@ -373,7 +374,7 @@ class MarkdownEditor {
|
|||
const newContent = `[](${resp.data.url})`;
|
||||
replaceContent(placeHolderText, newContent);
|
||||
}).catch(err => {
|
||||
window.$events.emit('error', trans('errors.image_upload_error'));
|
||||
window.$events.emit('error', context.imageUploadErrorText);
|
||||
replaceContent(placeHolderText, selectedText);
|
||||
console.log(err);
|
||||
});
|
||||
|
@ -492,7 +493,7 @@ class MarkdownEditor {
|
|||
this.cm.focus();
|
||||
DrawIO.close();
|
||||
}).catch(err => {
|
||||
window.$events.emit('error', trans('errors.image_upload_error'));
|
||||
window.$events.emit('error', this.imageUploadErrorText);
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,7 +38,7 @@ function editorPaste(event, editor, wysiwygComponent) {
|
|||
editor.dom.replace(newEl, id);
|
||||
}).catch(err => {
|
||||
editor.dom.remove(id);
|
||||
window.$events.emit('error', trans('errors.image_upload_error'));
|
||||
window.$events.emit('error', wysiwygComponent.imageUploadErrorText);
|
||||
console.log(err);
|
||||
});
|
||||
}, 10);
|
||||
|
@ -236,7 +236,7 @@ function codePlugin() {
|
|||
});
|
||||
}
|
||||
|
||||
function drawIoPlugin(drawioUrl, isDarkMode, pageId) {
|
||||
function drawIoPlugin(drawioUrl, isDarkMode, pageId, wysiwygComponent) {
|
||||
|
||||
let pageEditor = null;
|
||||
let currentNode = null;
|
||||
|
@ -280,7 +280,7 @@ function drawIoPlugin(drawioUrl, isDarkMode, pageId) {
|
|||
pageEditor.dom.setAttrib(imgElem, 'src', img.url);
|
||||
pageEditor.dom.setAttrib(currentNode, 'drawio-diagram', img.id);
|
||||
} catch (err) {
|
||||
window.$events.emit('error', trans('errors.image_upload_error'));
|
||||
window.$events.emit('error', wysiwygComponent.imageUploadErrorText);
|
||||
console.log(err);
|
||||
}
|
||||
return;
|
||||
|
@ -295,7 +295,7 @@ function drawIoPlugin(drawioUrl, isDarkMode, pageId) {
|
|||
pageEditor.dom.get(id).parentNode.setAttribute('drawio-diagram', img.id);
|
||||
} catch (err) {
|
||||
pageEditor.dom.remove(id);
|
||||
window.$events.emit('error', trans('errors.image_upload_error'));
|
||||
window.$events.emit('error', wysiwygComponent.imageUploadErrorText);
|
||||
console.log(err);
|
||||
}
|
||||
}, 5);
|
||||
|
@ -414,12 +414,12 @@ function listenForBookStackEditorEvents(editor) {
|
|||
|
||||
class WysiwygEditor {
|
||||
|
||||
|
||||
setup() {
|
||||
this.elem = this.$el;
|
||||
|
||||
this.pageId = this.$opts.pageId;
|
||||
this.textDirection = this.$opts.textDirection;
|
||||
this.imageUploadErrorText = this.$opts.imageUploadErrorText;
|
||||
this.isDarkMode = document.documentElement.classList.contains('dark-mode');
|
||||
|
||||
this.plugins = "image table textcolor paste link autolink fullscreen code customhr autosave lists codeeditor media";
|
||||
|
@ -437,7 +437,7 @@ class WysiwygEditor {
|
|||
const drawioUrlElem = document.querySelector('[drawio-url]');
|
||||
if (drawioUrlElem) {
|
||||
const url = drawioUrlElem.getAttribute('drawio-url');
|
||||
drawIoPlugin(url, this.isDarkMode, this.pageId);
|
||||
drawIoPlugin(url, this.isDarkMode, this.pageId, this);
|
||||
this.plugins += ' drawio';
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue