mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
Fix tiny mce visuals, saving and cursor position
This commit is contained in:
parent
3bb268459f
commit
8e6413b031
2 changed files with 21 additions and 5 deletions
18
app/assets/javascripts/sitewide/tiny_mce.js
vendored
18
app/assets/javascripts/sitewide/tiny_mce.js
vendored
|
@ -57,6 +57,7 @@ var TinyMCE = (function() {
|
|||
menubar: 'file edit view insert format',
|
||||
toolbar: 'undo redo restoredraft | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link | forecolor backcolor | customimageuploader | codesample',
|
||||
plugins: 'autosave autoresize customimageuploader link advlist codesample autolink lists charmap hr anchor searchreplace wordcount visualblocks visualchars insertdatetime nonbreaking save directionality paste textcolor colorpicker textpattern',
|
||||
autoresize_bottom_margin: 20,
|
||||
codesample_languages: [
|
||||
{ text: 'R', value: 'r' },
|
||||
{ text: 'MATLAB', value: 'matlab' },
|
||||
|
@ -139,6 +140,7 @@ var TinyMCE = (function() {
|
|||
$('.tinymce-placeholder').remove();
|
||||
moveToolbar(editor, editorToolbar, editorToolbaroffset);
|
||||
}, 400);
|
||||
|
||||
// Init saved status label
|
||||
if (editor.getContent() !== '') {
|
||||
editorForm.find('.tinymce-status-badge').removeClass('hidden');
|
||||
|
@ -149,7 +151,6 @@ var TinyMCE = (function() {
|
|||
moveToolbar(editor, editorToolbar, editorToolbaroffset);
|
||||
});
|
||||
|
||||
|
||||
// Update scroll position after exit
|
||||
function updateScrollPosition() {
|
||||
if (editorForm.offset().top < $(window).scrollTop()) {
|
||||
|
@ -157,6 +158,16 @@ var TinyMCE = (function() {
|
|||
}
|
||||
}
|
||||
|
||||
// Saving at clicking anywhere outside of the editor
|
||||
editor.on('blur', function(event) {
|
||||
event.preventDefault();
|
||||
editorForm.clearFormErrors();
|
||||
editor.setProgressState(1);
|
||||
editor.save();
|
||||
editorForm.submit();
|
||||
updateScrollPosition();
|
||||
});
|
||||
|
||||
// Init Save button
|
||||
editorForm
|
||||
.find('.tinymce-save-button')
|
||||
|
@ -202,6 +213,11 @@ var TinyMCE = (function() {
|
|||
})
|
||||
.removeClass('hidden');
|
||||
|
||||
// Set cursor to the end of the content
|
||||
editor.focus();
|
||||
editor.selection.select(editor.getBody(), true);
|
||||
editor.selection.collapse(false);
|
||||
|
||||
SmartAnnotation.init($(editor.contentDocument.activeElement));
|
||||
initHighlightjsIframe($(this.iframeElement).contents());
|
||||
},
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
.tinymce-view {
|
||||
border: solid 1px;
|
||||
border-color: $color-white;
|
||||
box-shadow: 1px 0 2px $color-alto;
|
||||
min-height: 200px;
|
||||
border-radius: 3px;
|
||||
min-height: 100px;
|
||||
padding: 3px;
|
||||
|
||||
&:hover {
|
||||
border-color: $color-alto;
|
||||
border-color: $color-gainsboro;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue