Install and use ToastUi markdown editor

Replace all usages of pagedown-bootstrap editor with the new editor.
Add styles to ensure the editor preview matches the final output.
This commit is contained in:
Julia Casamitjana
2024-04-11 10:34:37 +02:00
committed by Dominic Sauer
parent 96f5f1f8d7
commit 9c71c6667a
10 changed files with 362 additions and 37 deletions

View File

@ -3,6 +3,8 @@
Otherwise, code might not be highlighted correctly (race condition)
meta name='turbolinks-visit-control' content='reload'
- append_javascript_pack_tag('sortable')
- append_javascript_pack_tag('toast-ui')
- append_stylesheet_pack_tag('toast-ui')
- execution_environments = ExecutionEnvironment.where.not(file_type_id: nil).select(:file_type_id, :id)
- file_types = FileType.where.not(file_extension: nil).select(:file_extension, :id)
@ -18,7 +20,7 @@
.help-block.form-text == t('.hints.internal_title')
.mb-3
= f.label(:description, class: 'form-label')
= f.pagedown :description, input_html: {preview: true, rows: 10}
= f.pagedown :description
.mb-3
= f.label(:execution_environment_id, class: 'form-label')
= f.collection_select(:execution_environment_id, @execution_environments, :id, :name, {include_blank: t('exercises.form.none')}, class: 'form-control')

View File

@ -1,3 +1,10 @@
- content_for :head do
// Force a full page reload, see https://github.com/turbolinks/turbolinks/issues/326.
Otherwise, code might not be highlighted correctly (race condition)
meta name='turbolinks-visit-control' content='reload'
- append_javascript_pack_tag('toast-ui')
- append_stylesheet_pack_tag('toast-ui')
= form_for(@proxy_exercise, multipart: true, builder: PagedownFormBuilder) do |f|
= render('shared/form_errors', object: @proxy_exercise)
.mb-3
@ -5,7 +12,7 @@
= f.text_field(:title, class: 'form-control', required: true)
.mb-3
= f.label(:description, class: 'form-label')
= f.pagedown :description, input_html: {preview: true, rows: 10}
= f.pagedown :description
.mb-3
= f.label(:algorithm, class: 'form-label')
= f.collection_select(:algorithm, ProxyExercise.algorithms.map {|algorithm, _id| [t("activerecord.attributes.proxy_exercise.algorithm_type.#{algorithm}"), algorithm] }, :second, :first, {}, class: 'form-control form-control-sm')

View File

@ -1,3 +1,10 @@
- content_for :head do
// Force a full page reload, see https://github.com/turbolinks/turbolinks/issues/326.
Otherwise, code might not be highlighted correctly (race condition)
meta name='turbolinks-visit-control' content='reload'
- append_javascript_pack_tag('toast-ui')
- append_stylesheet_pack_tag('toast-ui')
= form_for(@tip, builder: PagedownFormBuilder) do |f|
= render('shared/form_errors', object: @tip)
.mb-3
@ -5,7 +12,7 @@
= f.text_field(:title, class: 'form-control', required: false)
.mb-3
= f.label(:description, class: 'form-label')
= f.pagedown :description, input_html: {preview: true, rows: 5}
= f.pagedown :description
.mb-3
= f.label(:file_type_id, t('activerecord.attributes.file.file_type_id'), class: 'form-label')
= f.collection_select(:file_type_id, @file_types, :id, :name, {include_blank: true}, class: 'form-control')