%
data_attributes = local_assigns[:data] || {}
disabled = local_assigns[:disabled] || false
placeholder = local_assigns[:placeholder] || nil
autofocus = local_assigns[:autofocus] || false
style = local_assigns[:style] || nil
classes = local_assigns[:class] || nil
rows = local_assigns[:rows] || 15
field_name = form&.field_name(name) || name
value = if defined?(form)
form.object.send(name)
else
local_assigns[:value] || nil
end
extra_preview_params = local_assigns[:extra_preview_params] || {}
%>
<%= content_tag :div,
class: "ms:block ms:flex-col ms:w-full ms:border ms:border-neutral-300 ms:rounded ms:@container ms:focus-within:border-neutral-400",
data: {
controller: "marksmith list-continuation",
action: "
beforeinput->list-continuation#handleBeforeInput
input->list-continuation#handleInput
",
marksmith_preview_url_value: marksmith.markdown_previews_path,
marksmith_active_tab_class: "bg-white",
marksmith_attach_url_value: main_app.rails_direct_uploads_url,
marksmith_extra_preview_params_value: extra_preview_params.as_json,
} do %>
<% toggle_button_classes = class_names(marksmith_button_classes, "ms:bg-neutral-200 ms:border-0 ms:bg-none ms:text-sm ms:hover:bg-neutral-300 ms:uppercase ms:text-xs ms:font-semibold ms:text-neutral-800") %>
<%= content_tag :div, class: "ms:flex ms:flex-col ms:size-full", data: { marksmith_target: "fieldContainer" } do %>
<%= text_area_tag field_name, value,
id: name,
class: class_names("ms:flex ms:flex-1 ms:rounded ms:border-none ms:p-2 ms:resize-y ms:focus:outline-none ms:font-mono ms:focus:ring-0 ms:leading-normal", classes),
rows: rows,
data: {
action: "drop->marksmith#dropUpload paste->marksmith#pasteUpload",
marksmith_target: "fieldElement",
**data_attributes
},
disabled:,
placeholder:,
autofocus:,
style:
%>
<%= link_to "https://docs.github.com/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax", target: "_blank", class: class_names("ms:flex ms:items-center ms:gap-x-2 ms:text-neutral-800 ms:no-underline", toolbar_button_classes) do %>
<%= image_tag asset_path("marksmith/svgs/markdown.svg"), class: "ms:inline ms:size-4" %> <%= t("marksmith.markdown_is_supported").humanize %>
<% end %>
<%= button_tag data: { action: "click->marksmith#buttonUpload" }, class: class_names("ms:bg-none ms:border-none ms:bg-transparent ms:text-neutral-600 ms:items-center ms:flex", toolbar_button_classes) do %>
<%= image_tag asset_path("marksmith/svgs/paperclip.svg"), class: "ms:inline ms:size-4" %> <%= t("marksmith.attach_files").humanize %>
<% end %>
<% end %>
<%= content_tag :div,
class: "ms:hidden ms:markdown-preview ms:size-full ms:flex-1 ms:flex ms:size-full",
id: "markdown-preview-#{name}",
data: {
marksmith_target: "previewElement",
} do %>
<% end %>
<% end %>