Skip to content

Commit 3917e50

Browse files
committed
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.
1 parent dd71658 commit 3917e50

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lang/en/entities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
'pages_md_insert_drawing' => 'Insert Drawing',
240240
'pages_md_show_preview' => 'Show preview',
241241
'pages_md_sync_scroll' => 'Sync preview scroll',
242-
'pages_drawing_unsaved' => 'Unsaved Drawing',
242+
'pages_drawing_unsaved' => 'Unsaved Drawing Found',
243243
'pages_drawing_unsaved_confirm' => 'Unsaved drawing data was found from a previous failed drawing save attempt. Would you like to restore and continue editing this unsaved drawing?',
244244
'pages_not_in_chapter' => 'Page is not in a chapter',
245245
'pages_move' => 'Move Page',

resources/js/wysiwyg/plugin-drawio.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ function showDrawingManager(mceEditor, selectedNode = null) {
3434
}
3535

3636
async function updateContent(pngData) {
37-
const id = `image-${Math.random().toString(16).slice(2)}`;
3837
const loadingImage = window.baseUrl('/loading.gif');
3938

4039
const handleUploadError = error => {
@@ -65,17 +64,19 @@ async function updateContent(pngData) {
6564

6665
await wait(5);
6766

68-
pageEditor.insertContent(`<div drawio-diagram contenteditable="false"><img src="${loadingImage}" id="${id}"></div>`);
67+
const id = `drawing-${Math.random().toString(16).slice(2)}`;
68+
const wrapId = `drawing-wrap-${Math.random().toString(16).slice(2)}`;
69+
pageEditor.insertContent(`<div drawio-diagram contenteditable="false" id="${wrapId}"><img src="${loadingImage}" id="${id}"></div>`);
6970
DrawIO.close();
7071

7172
try {
7273
const img = await DrawIO.upload(pngData, options.pageId);
7374
pageEditor.undoManager.transact(() => {
7475
pageEditor.dom.setAttrib(id, 'src', img.url);
75-
pageEditor.dom.get(id).parentNode.setAttribute('drawio-diagram', img.id);
76+
pageEditor.dom.setAttrib(wrapId, 'drawio-diagram', img.id);
7677
});
7778
} catch (err) {
78-
pageEditor.dom.remove(id);
79+
pageEditor.dom.remove(wrapId);
7980
handleUploadError(err);
8081
throw new Error(`Failed to save image with error: ${err}`);
8182
}

0 commit comments

Comments
 (0)