app/views/pages/_form.html.slim
= form_for (@page.new_record? ? [@wiki, @page] : @page) do |f|
= render 'errors', model: @page
fieldset.form-group
= f.label :title
= f.text_field :title, class: 'form-control', required: Rails.env.production?, autofocus: @page.title.blank?
fieldset.form-group
= f.label :parent_id
= f.select :parent_id, ([@wiki] + @wiki.descendants).map { |p| [p.tree, p.id] }, {}, class: 'form-control'
fieldset.form-group
= f.label :content
.btn-toolbar.m-b-1
.btn-group.btn-group-sm
a.btn.btn-secondary.js-insert href="#" data-text="# " H1
a.btn.btn-secondary.js-insert href="#" data-text="## " H2
a.btn.btn-secondary.js-insert href="#" data-text="### " H3
a.btn.btn-secondary.js-insert href="#" data-text="#### " H4
a.btn.btn-secondary.js-insert href="#" data-text="##### " H5
a.btn.btn-secondary.js-insert href="#" data-text="###### " H6
.btn-group.btn-group-sm
a.btn.btn-secondary.js-insert href="#" data-text="[]()" data-pos="-3"= icon('link')
a.btn.btn-secondary.js-insert href="#" data-text="![]()" data-pos="-1"= icon('image')
.btn-group.btn-group-sm
a.btn.btn-secondary.js-insert href="#" data-text="\n | \n--- | ---\n | \n | \n" data-pos="-22"= icon('table')
a.btn.btn-secondary.js-insert href="#" data-text="\n---\n"= icon('ellipsis-h')
a.btn.btn-secondary.js-insert href="#" data-text="\n```\n\n```\n" data-pos="-5"= icon('code')
a.btn.btn-secondary.js-insert href="#" data-text="\n- "= icon('list')
a.btn.btn-secondary.js-insert href="#" data-text="\n1. "= icon('list-ol')
.btn-group.btn-group-sm
a.btn.btn-secondary.js-upload href="#"= icon('paperclip')
.row
.col-sm-6
.js-content-container[
data-attachments-path="#{wiki_attachments_path(@wiki)}"
data-page-id="#{@page.try(:id).presence || @wiki.id}"]
= f.text_area :content, class: 'form-control', autofocus: @page.title.present?,
data: { preview_path: preview_wiki_path(@wiki) }
.col-sm-6
.card
.card-block
.markdown-body.text-break.js-preview
= f.submit class: 'btn btn-primary js-submit-page', data: { disable_with: t('global.please_wait') }, title: 'mod+s'