Markdown API
Per-option reference for the Markdown field provided by marksmith. For tasks and examples, see the Markdown guide.
Pass options to a field declaration in your resource's fields method, for example in app/avo/resources/post.rb:
field :body, as: :markdown, file_uploads: falseThe contracts below describe marksmith 0.6.0. The field is hidden on Index by default. For shared options, see Field options.
Attachments
-> file_uploads
Controls the editor's file-upload UI. The field forwards this value to Marksmith's enable_file_uploads setting.
field :body, as: :markdown, file_uploads: false| Value | Behavior |
|---|---|
nil | Enables uploads when an upload URL is available. |
true | Enables uploads when an upload URL is available. |
false | Disables uploads. |
- Type:
Booleanornil - Default:
nil
Upload URL required
Uploads remain disabled without an upload URL, even with file_uploads: true. When Active Storage is defined, Marksmith's helper supplies the app's rails_direct_uploads_url.
-> media_library
Controls the "Attach from gallery" option in the editor. The gallery is available only when the global Media Library configuration is enabled and this option is truthy.
field :body, as: :markdown, media_library: false- Type:
Boolean - Default:
true - Values:
trueorfalse; an explicitnilfalls back totrue.
Preview requests
-> extra_preview_params
Additional parameters sent with preview requests. Avo starts with resource_class (the resource class name) and field_id (the field identifier), then merges this Hash after those entries. Custom matching keys override those identifiers.
field :body, as: :markdown, extra_preview_params: { foo: :bar }- Type:
Hash - Default:
{} - Values: A Hash of additional preview parameters;
nilorfalsefalls back to{}.
Hash required
The edit component expands this value with Ruby's double-splat operator. A value that cannot be converted to a Hash raises TypeError when the edit component renders; there is no earlier field-level type validation.
Show presentation
-> always_show
Controls whether the Show view displays the full rendered Markdown instead of a collapsed preview. This option is defined by Marksmith's Markdown field, not by BaseField.
field :body, as: :markdown, always_show: true- Type:
Boolean - Default:
false - Values:
truedisplays the full content;falseorniluses the collapsed preview. Other truthy values also disable collapsing; no Boolean type validation is performed. - Availability:
marksmith0.6.0or newer. Older versions display the full content without consulting this option.