1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Updated drawio tinymce plugin to use embeds

- Adds support for handling drawings as embeds, based on image
  extension.
- Adds additional attribute to drawio elements within editor to prevent
  tinymce replacing embeds with a placeholder.
- Updates how contenteditable is applied to drawio blocks within editor,
  to use proper filters instead of using the SetContent event.
This commit is contained in:
Dan Brown
2022-05-23 12:24:40 +01:00
parent d926ca5f71
commit 5fd8e7e0e9
3 changed files with 56 additions and 20 deletions

View File

@@ -99,4 +99,18 @@ async function load(drawingId) {
return resp.data.content;
}
export default {show, close, upload, load};
function buildDrawingContentHtml(drawing) {
const isSvg = drawing.url.split('.').pop().toLowerCase() === 'svg';
const image = `<img src="${drawing.url}">`;
const embed = `<embed src="${drawing.url}" type="image/svg+xml">`;
return `<div drawio-diagram="${drawing.id}">${isSvg ? embed : image}</div>`
}
function buildDrawingContentNode(drawing) {
const div = document.createElement('div');
div.innerHTML = buildDrawingContentHtml(drawing);
return div.children[0];
}
export default {show, close, upload, load, buildDrawingContentHtml, buildDrawingContentNode};