mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Drawio: Tweaked fail backup handling during testing
- Tweaked wording of popup title. - Updated WYSIWYG create handling to properly remove drawing container on failure. Tested across FF and chrome, in both editors for create & editing.
This commit is contained in:
@ -34,7 +34,6 @@ function showDrawingManager(mceEditor, selectedNode = null) {
|
||||
}
|
||||
|
||||
async function updateContent(pngData) {
|
||||
const id = `image-${Math.random().toString(16).slice(2)}`;
|
||||
const loadingImage = window.baseUrl('/loading.gif');
|
||||
|
||||
const handleUploadError = error => {
|
||||
@ -65,17 +64,19 @@ async function updateContent(pngData) {
|
||||
|
||||
await wait(5);
|
||||
|
||||
pageEditor.insertContent(`<div drawio-diagram contenteditable="false"><img src="${loadingImage}" id="${id}"></div>`);
|
||||
const id = `drawing-${Math.random().toString(16).slice(2)}`;
|
||||
const wrapId = `drawing-wrap-${Math.random().toString(16).slice(2)}`;
|
||||
pageEditor.insertContent(`<div drawio-diagram contenteditable="false" id="${wrapId}"><img src="${loadingImage}" id="${id}"></div>`);
|
||||
DrawIO.close();
|
||||
|
||||
try {
|
||||
const img = await DrawIO.upload(pngData, options.pageId);
|
||||
pageEditor.undoManager.transact(() => {
|
||||
pageEditor.dom.setAttrib(id, 'src', img.url);
|
||||
pageEditor.dom.get(id).parentNode.setAttribute('drawio-diagram', img.id);
|
||||
pageEditor.dom.setAttrib(wrapId, 'drawio-diagram', img.id);
|
||||
});
|
||||
} catch (err) {
|
||||
pageEditor.dom.remove(id);
|
||||
pageEditor.dom.remove(wrapId);
|
||||
handleUploadError(err);
|
||||
throw new Error(`Failed to save image with error: ${err}`);
|
||||
}
|
||||
|
Reference in New Issue
Block a user