mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-10 06:37:32 +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(() => {
|
setTimeout(() => {
|
||||||
$(editor.editorContainer).addClass('show');
|
$(editor.editorContainer).addClass('show');
|
||||||
$('.tinymce-placeholder').remove();
|
$('.tinymce-placeholder').remove();
|
||||||
|
moveToolbar(editor, editorToolbar, editorToolbaroffset);
|
||||||
}, 400);
|
}, 400);
|
||||||
// Init saved status label
|
// Init saved status label
|
||||||
if (editor.getContent() !== '') {
|
if (editor.getContent() !== '') {
|
||||||
|
@ -144,12 +145,18 @@ var TinyMCE = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init Floating toolbar
|
// Init Floating toolbar
|
||||||
|
|
||||||
moveToolbar(editor, editorToolbar, editorToolbaroffset);
|
|
||||||
$(window).on('scroll', function() {
|
$(window).on('scroll', function() {
|
||||||
moveToolbar(editor, editorToolbar, editorToolbaroffset);
|
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
|
// Init Save button
|
||||||
editorForm
|
editorForm
|
||||||
.find('.tinymce-save-button')
|
.find('.tinymce-save-button')
|
||||||
|
@ -161,6 +168,7 @@ var TinyMCE = (function() {
|
||||||
editor.setProgressState(1);
|
editor.setProgressState(1);
|
||||||
editor.save();
|
editor.save();
|
||||||
editorForm.submit();
|
editorForm.submit();
|
||||||
|
updateScrollPosition();
|
||||||
});
|
});
|
||||||
|
|
||||||
// After save action
|
// After save action
|
||||||
|
@ -190,6 +198,7 @@ var TinyMCE = (function() {
|
||||||
editorForm.find('.tinymce-status-badge').addClass('hidden');
|
editorForm.find('.tinymce-status-badge').addClass('hidden');
|
||||||
editorForm.find('.tinymce-view').removeClass('hidden');
|
editorForm.find('.tinymce-view').removeClass('hidden');
|
||||||
editor.remove();
|
editor.remove();
|
||||||
|
updateScrollPosition();
|
||||||
})
|
})
|
||||||
.removeClass('hidden');
|
.removeClass('hidden');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue