new text editor: tinyMCE
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
</div>
|
||||
<div id="notes_box" class="col-9 h-100">
|
||||
<div id="notes_feedback"></div>
|
||||
<div id="notes"></div>
|
||||
<form id="notes" method="post"><textarea id="tiny"></textarea></form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="template-items">
|
||||
@@ -31,27 +31,40 @@ oCATC.pageInit = function(asHash, bFirstPage) {
|
||||
//Setup layout
|
||||
self.setPageTitle(self.consts.courses[self.tmp('id_course')].description);
|
||||
|
||||
//Setup Quill
|
||||
oEditor = new Editor('#notes');
|
||||
oEditor.onKeyStroke = (e) => {
|
||||
if(e.which == 83 && e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
save(true);
|
||||
//Setup TinyMCE
|
||||
tinymce.init({
|
||||
selector: '#tiny',
|
||||
height: '100%',
|
||||
menubar: false,
|
||||
plugins: [
|
||||
'advlist autolink lists link image charmap print preview anchor',
|
||||
'searchreplace visualblocks code fullscreen',
|
||||
'insertdatetime media table paste autosave save hr'
|
||||
],
|
||||
toolbar:
|
||||
'save undo redo | '+
|
||||
'formatselect | '+
|
||||
'bold italic underline strikethrough forecolor | '+
|
||||
'alignleft aligncenter alignright alignjustify | '+
|
||||
'bullist numlist outdent indent hr | '+
|
||||
'link table image | '+
|
||||
'removeformat',
|
||||
save_onsavecallback: function(oEditor) { save(true); },
|
||||
autosave_interval: "10s",
|
||||
setup: function(ed) {
|
||||
ed.on('init', function(e) {
|
||||
Tools.ajax(
|
||||
'get_note',
|
||||
(asData) => {
|
||||
tinymce.activeEditor.setContent(asData.notes);
|
||||
noteFeedback('notice', 'Last update at '+asData.led_time+' on '+asData.led_date);
|
||||
},
|
||||
{id: self.tmp('id_course')},
|
||||
() => {console.log('Note not found for course ID = '+self.tmp('id_course'))}
|
||||
);
|
||||
});
|
||||
}
|
||||
else save();
|
||||
};
|
||||
//oQuill.keyboard.addBinding({key: 'S', ctrlKey: true}, function(){saveNotes(true);});
|
||||
|
||||
//Load notes
|
||||
Tools.ajax(
|
||||
'get_note',
|
||||
(asData) => {
|
||||
oEditor.setContent(asData.notes);
|
||||
noteFeedback('notice', 'Last update at '+asData.led_time+' on '+asData.led_date);
|
||||
},
|
||||
{id: self.tmp('id_course')},
|
||||
() => {console.log('Note not found for course ID = '+self.tmp('id_course'))}
|
||||
);
|
||||
});
|
||||
|
||||
//Setup File Upload
|
||||
$('#fileupload')
|
||||
@@ -85,7 +98,7 @@ oCATC.pageInit = function(asHash, bFirstPage) {
|
||||
loadDocs();
|
||||
|
||||
//Scrollbar
|
||||
$('#doc_list_box, #notes').mCustomScrollbar({
|
||||
$('#doc_list_box').mCustomScrollbar({
|
||||
axis: 'y',
|
||||
scrollInertia: 0,
|
||||
autoExpandScrollbar: true,
|
||||
@@ -93,6 +106,10 @@ oCATC.pageInit = function(asHash, bFirstPage) {
|
||||
});
|
||||
};
|
||||
|
||||
oCATC.onSamePageMove = function(asHash) {
|
||||
return true;
|
||||
};
|
||||
|
||||
oCATC.onQuitPage = function(sExitMode) {
|
||||
return save(true, (sExitMode==self.consts.exitmodes.closing));
|
||||
};
|
||||
@@ -148,14 +165,14 @@ function save(bForce, bOnUnload) {
|
||||
if(bOnUnload) bForce = true;
|
||||
|
||||
if(typeof oSaveTimer != 'undefined') clearTimeout(oSaveTimer);
|
||||
var bSave = (oEditor.keystrokes % 20 == 0 || bForce);
|
||||
var bSave = (/*oEditor.keystrokes % 20 == 0 || */bForce); //FIXME: redo auto save
|
||||
|
||||
if(bSave) {
|
||||
if(self.tmp('saving') && !bOnUnload) {
|
||||
oSaveTimer = setTimeout(function(){save(true);}, 500);
|
||||
}
|
||||
else {
|
||||
var sContent = oEditor.getContent();
|
||||
var sContent = tinymce.activeEditor.getContent();
|
||||
if(self.tmp('id_course') != 0) {
|
||||
self.tmp('saving', true);
|
||||
noteFeedback('info', 'Saving...');
|
||||
|
||||
Reference in New Issue
Block a user