working pagedown!!!!

This commit is contained in:
yqbk
2016-07-13 16:45:54 +02:00
parent bff02a3005
commit 52fd18c80e
5 changed files with 13 additions and 29 deletions

View File

@ -160,6 +160,7 @@ $(function() {
// new MarkdownEditor('#exercise_instructions');
new MarkdownEditor('#exercise_description');
// todo: add an ace editor for each file
new PagedownEditor('#exercise_description');
enableInlineFileCreation();
inferFileAttributes();

View File

@ -1,22 +0,0 @@
(function() {
var ACE_FILES_PATH = '/assets/ace/';
converter = Markdown.getSanitizingConverter()
editor = new Markdown.Editor converter
editor.run();
editor.refreshPreview()
window.MarkdownEditor = function(selector) {
ace.config.set('modePath', ACE_FILES_PATH);
var editor = ace.edit($(selector).next()[0]);
editor.on('change', function() {
$(selector).val(editor.getValue());
});
editor.setShowPrintMargin(false);
var session = editor.getSession();
session.setMode('markdown');
session.setUseWrapMode(true);
session.setValue($(selector).val());
};
})();

View File

@ -0,0 +1,11 @@
(function() {
var ACE_FILES_PATH = '/assets/ace/';
window.PagedownEditor = function(selector) {
var converter = Markdown.getSanitizingConverter();
var editor = new Markdown.Editor( converter );
editor.run();
};
})();

View File

@ -9,12 +9,7 @@
.form-group
= f.label(:description)
= f.hidden_field(:description)
/.form-control.markdown
.wmd-panel
#wmd-button-bar
textarea#wmd-input
#wmd-preview
= f.pagedown_editor :description, {skip_preview: false, panel_class: 'wmd-panel', button_bar_id: 'wmd-button-bar', button_bar_class: '', editor_id: 'wmd-input', editor_class: 'wmd-input', preview_id: 'wmd-preview', preview_class: '', }
.form-control.markdown
/.form-group
= f.label(:description)
= f.hidden_field(:description)

View File

@ -22,7 +22,6 @@ module CodeOcean
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'Berlin'
config.assets.precompile += %w( markdown-buttons.png )
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]