mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Updated markdown editor to use svg drawio images
- Also tweaked page editor to not error when the current user does not have permission to change editor type.
This commit is contained in:
@@ -462,7 +462,7 @@ class MarkdownEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
insertDrawing(image, originalCursor) {
|
insertDrawing(image, originalCursor) {
|
||||||
const newText = `<div drawio-diagram="${image.id}"><img src="${image.url}"></div>`;
|
const newText = DrawIO.buildDrawingContentHtml(image);
|
||||||
this.cm.focus();
|
this.cm.focus();
|
||||||
this.cm.replaceSelection(newText);
|
this.cm.replaceSelection(newText);
|
||||||
this.cm.setCursor(originalCursor.line, originalCursor.ch + newText.length);
|
this.cm.setCursor(originalCursor.line, originalCursor.ch + newText.length);
|
||||||
@@ -488,13 +488,14 @@ class MarkdownEditor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.$http.post("/images/drawio", data).then(resp => {
|
window.$http.post("/images/drawio", data).then(resp => {
|
||||||
let newText = `<div drawio-diagram="${resp.data.id}"><img src="${resp.data.url}"></div>`;
|
const image = resp.data;
|
||||||
let newContent = this.cm.getValue().split('\n').map(line => {
|
const newText = DrawIO.buildDrawingContentHtml(image);
|
||||||
if (line.indexOf(`drawio-diagram="${drawingId}"`) !== -1) {
|
|
||||||
return newText;
|
const newContent = this.cm.getValue().split('\n').map(line => {
|
||||||
}
|
const isDrawing = line.includes(`drawio-diagram="${drawingId}"`);
|
||||||
return line;
|
return isDrawing ? newText : line;
|
||||||
}).join('\n');
|
}).join('\n');
|
||||||
|
|
||||||
this.cm.setValue(newContent);
|
this.cm.setValue(newContent);
|
||||||
this.cm.setCursor(cursorPos);
|
this.cm.setCursor(cursorPos);
|
||||||
this.cm.focus();
|
this.cm.focus();
|
||||||
|
@@ -24,7 +24,7 @@ class PageEditor {
|
|||||||
this.draftDisplayIcon = this.$refs.draftDisplayIcon;
|
this.draftDisplayIcon = this.$refs.draftDisplayIcon;
|
||||||
this.changelogInput = this.$refs.changelogInput;
|
this.changelogInput = this.$refs.changelogInput;
|
||||||
this.changelogDisplay = this.$refs.changelogDisplay;
|
this.changelogDisplay = this.$refs.changelogDisplay;
|
||||||
this.changeEditorButtons = this.$manyRefs.changeEditor;
|
this.changeEditorButtons = this.$manyRefs.changeEditor || [];
|
||||||
this.switchDialogContainer = this.$refs.switchDialog;
|
this.switchDialogContainer = this.$refs.switchDialog;
|
||||||
|
|
||||||
// Translations
|
// Translations
|
||||||
|
Reference in New Issue
Block a user