mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-04 19:05:37 +08:00
Fix issue with TInyMCE upload plugin (#1723)
This commit is contained in:
parent
4c1a64ce4f
commit
7d54f2ab01
1 changed files with 16 additions and 6 deletions
|
@ -293,16 +293,24 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create hidden field for images
|
||||||
|
function createImageHiddenField() {
|
||||||
|
textAreaElement.parent().find('input#tiny-mce-images').remove();
|
||||||
|
$('<input type="hidden" id="tiny-mce-images" name="tiny_mce_images" value="[]">').insertAfter(textAreaElement);
|
||||||
|
}
|
||||||
|
|
||||||
// Finding images in text
|
// Finding images in text
|
||||||
function updateActiveImages() {
|
function updateActiveImages() {
|
||||||
var images;
|
var images;
|
||||||
|
var imageContainer = $('#' + editor.id).next()[0];
|
||||||
iframe = $('#' + editor.id).prev().find('.mce-edit-area iframe').contents();
|
iframe = $('#' + editor.id).prev().find('.mce-edit-area iframe').contents();
|
||||||
images = $.map($('img', iframe), e => {
|
images = $.map($('img', iframe), e => {
|
||||||
return e.dataset.mceToken;
|
return e.dataset.mceToken;
|
||||||
});
|
});
|
||||||
if ($('#' + editor.id).next()[0]) {
|
if (imageContainer === undefined) {
|
||||||
$('#' + editor.id).next()[0].value = JSON.stringify(images);
|
createImageHiddenField();
|
||||||
}
|
}
|
||||||
|
imageContainer.value = JSON.stringify(images);
|
||||||
return JSON.stringify(images);
|
return JSON.stringify(images);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,12 +329,14 @@
|
||||||
onclick: showDialog
|
onclick: showDialog
|
||||||
});
|
});
|
||||||
|
|
||||||
ed.on('NodeChange', () => {
|
ed.on('NodeChange', function() {
|
||||||
updateActiveImages(ed);
|
// Check editor status
|
||||||
|
if (this.initialized) {
|
||||||
|
updateActiveImages(ed);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
textAreaElement.parent().find('input#tiny-mce-images').remove();
|
createImageHiddenField();
|
||||||
$('<input type="hidden" id="tiny-mce-images" name="tiny_mce_images" value="[]">').insertAfter(textAreaElement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue