mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-05 14:41:53 +08:00
Merge pull request #2082 from aignatov-bio/ai-sci-3907-fix-dirty-event-after-update-marvinjs-image
Fix dirty event after update marvinjs image [SCI-3907]
This commit is contained in:
commit
ba50b19986
3 changed files with 12 additions and 4 deletions
|
@ -186,6 +186,7 @@ var MarvinJsEditorApi = (function() {
|
|||
type: 'PUT',
|
||||
success: function(json) {
|
||||
if (config.objectType === 'TinyMceAsset') {
|
||||
TinyMCE.makeItDirty(config.editor);
|
||||
config.image[0].src = json.url;
|
||||
config.image[0].dataset.mceSrc = json.url;
|
||||
} else {
|
||||
|
|
14
app/assets/javascripts/sitewide/tiny_mce.js
vendored
14
app/assets/javascripts/sitewide/tiny_mce.js
vendored
|
@ -31,6 +31,12 @@ var TinyMCE = (function() {
|
|||
+ '</style>');
|
||||
}
|
||||
|
||||
function makeItDirty(editor) {
|
||||
var editorForm = $(editor.getContainer()).closest('form');
|
||||
editorForm.find('.tinymce-status-badge').addClass('hidden');
|
||||
$(editor.getContainer()).find('.tinymce-save-button').removeClass('hidden');
|
||||
}
|
||||
|
||||
// returns a public API for TinyMCE editor
|
||||
return Object.freeze({
|
||||
init: function(selector, onSaveCallback) {
|
||||
|
@ -246,10 +252,7 @@ var TinyMCE = (function() {
|
|||
});
|
||||
|
||||
editor.on('Dirty', function() {
|
||||
var editorForm = $(editor.getContainer()).closest('form');
|
||||
editorForm.find('.tinymce-status-badge').addClass('hidden');
|
||||
$(editor.getContainer())
|
||||
.find('.tinymce-save-button').removeClass('hidden');
|
||||
makeItDirty(editor);
|
||||
});
|
||||
|
||||
editor.on('remove', function() {
|
||||
|
@ -286,6 +289,9 @@ var TinyMCE = (function() {
|
|||
$('#' + editor.id).next()[0].value = JSON.stringify(images);
|
||||
return JSON.stringify(images);
|
||||
},
|
||||
makeItDirty: function(editor) {
|
||||
makeItDirty(editor);
|
||||
},
|
||||
highlight: initHighlightjs
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -17,6 +17,7 @@ tinymce.PluginManager.add('custom_image_toolbar', function(editor) {
|
|||
MarvinJsEditor.open({
|
||||
mode: 'edit-tinymce',
|
||||
marvinUrl: '/tiny_mce_assets/' + image[0].dataset.mceToken + '/marvinjs',
|
||||
editor: editor,
|
||||
image: image
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue