<%= simple_form_for [current_project, @node, @note],
  html: {
    data: {
      behavior: 'local-auto-save',
      auto_save_key: @auto_save_key
    }
  } do |f| %>

  <%= f.hidden_field :category, value: Category.default.id %>

  <%= f.label :text, 'Note source input', class: 'visually-hidden' %>
  <%=
    f.input :text,
      label: false,
      input_html: {
        class: 'textile',
        data: {
          allow_dropdown: @note.new_record?,
          behavior: 'auto-save rich-toolbar drop-zone',
          paths: editor_paths,
          'rich-toolbar': 'defaults field image',
          'rich-toolbar-uploader': '[data-behavior~=jquery-upload]',
        },
        rows: 20
      }
  %>

  <% if @note.persisted? %>
    <%= hidden_field :note, :original_updated_at, value: @note.updated_at.to_i %>
  <% end %>

  <div class="form-actions sticky">
    <%= f.button :submit, class: 'btn btn-primary' %> or
    <%=
      link_to 'Cancel',
      @note.new_record? ? project_node_path(@node.project, @node) : project_node_note_path(@node.project, @node, @note),
      class: 'cancel-link',
      data: {
        behavior: 'clear-local-auto-save'
      }
    %>
  </div>
<% end %>
