Add backend for tips and enable markdown support
This commit is contained in:
@@ -315,6 +315,9 @@ var CodeOceanEditor = {
|
||||
}).fail(_.noop)
|
||||
.always(function () {
|
||||
ace.edit(editor).session.setMode(newMode);
|
||||
if (newMode === 'ace/mode/python') {
|
||||
ace.edit(editor).setTheme('ace/theme/tomorrow')
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
@@ -30,7 +30,11 @@ $(document).on('turbolinks:load', function () {
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.setTheme(THEME);
|
||||
|
||||
// For creating / editing an exercise
|
||||
var textarea = $('textarea[id="exercise_files_attributes_' + index + '_content"]');
|
||||
if ($('.edit_tip, .new_tip').isPresent()) {
|
||||
textarea = $('textarea[id="tip_example"]')
|
||||
}
|
||||
var content = textarea.val();
|
||||
|
||||
if (content != undefined) {
|
||||
@@ -383,11 +387,11 @@ $(document).on('turbolinks:load', function () {
|
||||
observeExportButtons();
|
||||
}
|
||||
toggleCodeHeight();
|
||||
if (window.hljs) {
|
||||
highlightCode();
|
||||
}
|
||||
}
|
||||
|
||||
if (window.hljs) {
|
||||
highlightCode();
|
||||
}
|
||||
|
||||
if ($('#editor-edit').isPresent()) {
|
||||
configureEditors();
|
||||
|
@@ -31,12 +31,16 @@ $(document).on('turbolinks:load', function() {
|
||||
});
|
||||
|
||||
// enable chosen hook when editing an exercise to update ace code highlighting
|
||||
if ($.isController('exercises') && $('.edit_exercise, .new_exercise').isPresent()) {
|
||||
if ($.isController('exercises') && $('.edit_exercise, .new_exercise').isPresent() ||
|
||||
$.isController('tips') && $('.edit_tip, .new_tip').isPresent() ) {
|
||||
chosen_inputs.filter(function(){
|
||||
return $(this).attr('id').includes('file_type_id');
|
||||
}).on('change chosen:ready', function(event, parameter) {
|
||||
// Set ACE editor mode (for code highlighting) on change of file type and after initialization
|
||||
editorInstance = $(event.target).closest('.card-body').find('.editor')[0];
|
||||
if (editorInstance === undefined) {
|
||||
editorInstance = $(event.target).closest('.container').find('.editor')[0];
|
||||
}
|
||||
selectedFileType = event.target.value;
|
||||
CodeOceanEditor.updateEditorModeToFileTypeID(editorInstance, selectedFileType);
|
||||
})
|
||||
|
Reference in New Issue
Block a user