Merge pull request #1731 from aignatov-bio/ai-sci-3418-fix-window-scroll-after-exit-from-tinymce

Fix floating tool bar and scroll issue after leaving editor [SCI-3418]
This commit is contained in:
Miha Mencin 2019-05-07 16:35:49 +02:00 committed by GitHub
commit b31645adbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -137,6 +137,7 @@ var TinyMCE = (function() {
setTimeout(() => {
$(editor.editorContainer).addClass('show');
$('.tinymce-placeholder').remove();
moveToolbar(editor, editorToolbar, editorToolbaroffset);
}, 400);
// Init saved status label
if (editor.getContent() !== '') {
@ -144,12 +145,18 @@ var TinyMCE = (function() {
}
// Init Floating toolbar
moveToolbar(editor, editorToolbar, editorToolbaroffset);
$(window).on('scroll', function() {
moveToolbar(editor, editorToolbar, editorToolbaroffset);
});
// Update scroll position after exit
function updateScrollPosition() {
if (editorForm.offset().top < $(window).scrollTop()) {
$(window).scrollTop(editorForm.offset().top - 150);
}
}
// Init Save button
editorForm
.find('.tinymce-save-button')
@ -161,6 +168,7 @@ var TinyMCE = (function() {
editor.setProgressState(1);
editor.save();
editorForm.submit();
updateScrollPosition();
});
// After save action
@ -190,6 +198,7 @@ var TinyMCE = (function() {
editorForm.find('.tinymce-status-badge').addClass('hidden');
editorForm.find('.tinymce-view').removeClass('hidden');
editor.remove();
updateScrollPosition();
})
.removeClass('hidden');