Add functionality to expand the markdown editor
The editor will now have a default height of 300px but a button will let the user expand the editor. It will expand it to fit all content (or up to 400px if the content was not exceeding 300px). In the expanded mode the editor will keep growing as the user types more content.
This commit is contained in:

committed by
Dominic Sauer

parent
f10bcb96a6
commit
749074fec0
@ -8,7 +8,7 @@ class MarkdownFormBuilder < ActionView::Helpers::FormBuilder
|
||||
|
||||
@template.capture do
|
||||
@template.concat form_textarea
|
||||
@template.concat @template.tag.div(class: 'markdown-editor', data: {behavior: 'markdown-editor-widget', id: label_target})
|
||||
@template.concat toast_ui_editor
|
||||
end
|
||||
end
|
||||
|
||||
@ -21,6 +21,18 @@ class MarkdownFormBuilder < ActionView::Helpers::FormBuilder
|
||||
class: 'd-none'
|
||||
end
|
||||
|
||||
def toast_ui_editor
|
||||
@template.tag.div(class: 'markdown-editor__wrapper') do
|
||||
@template.concat @template.tag.div(class: 'markdown-editor', data: {behavior: 'markdown-editor-widget', id: label_target})
|
||||
@template.concat resize_btn
|
||||
end
|
||||
end
|
||||
|
||||
def resize_btn
|
||||
@template.tag.button(class: 'markdown-editor__resize-btn fa-solid', type: 'button', id: "#{label_target}-resize",
|
||||
title: I18n.t(:'markdown_editor.expand'), aria_label: I18n.t(:'markdown_editor.expand'))
|
||||
end
|
||||
|
||||
def base_id
|
||||
options[:markdown_id_suffix] || @attribute_name
|
||||
end
|
||||
|
Reference in New Issue
Block a user