<% 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] || {} # Used by Avo and other adapters to enable the gallery link. gallery_enabled = local_assigns.dig(:gallery, :enabled) || false gallery_open_path = local_assigns.dig(:gallery, :open_path) || nil gallery_params = local_assigns.dig(:gallery, :params) || {} if gallery_open_path.present? gallery_full_path = gallery_open_path + "?" + gallery_params.map { |k,v| "#{k}=#{v}" }.join('&') else gallery_full_path = nil end gallery_turbo_frame = local_assigns.dig(:gallery, :turbo_frame) || nil %> <%= 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 ", unique_selector: ".#{@input_id}", # used to pinpoint the exact element in which to insert the attachment 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, **local_assigns.fetch(:controller_data_attributes, {}) } 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") %>
" data-marksmith-target="toolbar"> <%= marksmith_toolbar_button "bold" %> <%= marksmith_toolbar_button "header" %> <%= marksmith_toolbar_button "italic" %> <%= marksmith_toolbar_button "quote" %> <%= marksmith_toolbar_button "code" %> <%= marksmith_toolbar_button "link" %> <%= marksmith_toolbar_button "image" %> <%= marksmith_toolbar_button "unordered-list" %> <%= marksmith_toolbar_button "ordered-list" %> <%= marksmith_toolbar_button "task-list" %>
<% toolbar_button_classes = "ms:cursor-pointer ms:hover:bg-neutral-100 ms:px-1 ms:py-px ms:rounded ms:text-sm" %>
<%= 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:text-neutral-800 ms:no-underline", toolbar_button_classes) do %> <%= image_tag asset_path("marksmith/svgs/markdown.svg"), class: "ms:inline ms:size-4 ms:mr-1" %> <%= 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 ms:mr-1" %> <%= t("marksmith.upload_files").humanize %> <% end %> <% if gallery_enabled %> <%= link_to gallery_full_path, data: { turbo_frame: gallery_turbo_frame }, class: class_names("ms:flex ms:items-center ms:text-neutral-800 ms:no-underline", toolbar_button_classes) do %> <%= image_tag asset_path("marksmith/svgs/gallery.svg"), class: "ms:inline ms:size-4 ms:mr-1" %> <%= t("marksmith.attach_from_gallery").humanize %> <% end %> <% 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 %>