mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-09 14:13:16 +08:00
Fix floating tool bar and scroll issue after leaving editor
This commit is contained in:
parent
72a1c9b9bd
commit
826ed63f17
1 changed files with 11 additions and 2 deletions
13
app/assets/javascripts/sitewide/tiny_mce.js
vendored
13
app/assets/javascripts/sitewide/tiny_mce.js
vendored
|
@ -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');
|
||||
|
||||
|
|
Loading…
Reference in a new issue