marksmith 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9b7bca51b1e950acb74830923706300439557e2600e1ea147f3db026c3116e2
4
- data.tar.gz: d442e841439c4873b688c1df818aada6d80087578b8564469395881652cd3e15
3
+ metadata.gz: 1758cda8f3d3f25677b3a47e0f611d1dbe31f379115d1e61d15f668cf98cf299
4
+ data.tar.gz: 484c5072c16076cb57af3196ea976d58020dadadad18eb9141b32374856debab
5
5
  SHA512:
6
- metadata.gz: 43f2b59bfc02d83bc4d02ea6249c4f6d0a27ba5438be942669e6ab129cdaf40c86c6ffbdae62514d32f19d2751f4e674fc7cc887ffd224d298ddc1d51c8ef9eb
7
- data.tar.gz: 14681e16b67254a763d33175c46b0aa28064153b7f338fc72d94dff9a338c4c722e202d6fc36c3bf86e0cb0d36beb4fd2b6ad2492ea88f5c3cc7956096876bc9
6
+ metadata.gz: c923c6fa717c4efb8ae5cc92d72e7bebe073e650efd19aa3bb7d45997dec041657f725aeeeb57b76a0542572582aeef520daef5e46341fc5052000e523c302ae
7
+ data.tar.gz: cfcb4587e7900bf98511d415a71ec3dc224090788244db216556f596eae8b93cdcf5086924551c778b0a1bd4335ca59398ea2df8c588bbbc58e2712da18e83b7
data/README.md CHANGED
@@ -227,11 +227,22 @@ application.register('list-continuation', ListContinuationController)
227
227
 
228
228
  ## Dark mode
229
229
 
230
- Marksmith comes with dark mode built in using the `.dark` class on the `html` element strategy.
230
+ Marksmith comes with dark mode built in using the `.dark` class on a wrapper element strategy.
231
231
 
232
- ```html
232
+ ```erb
233
+ <!-- Wrapper element -->
234
+ <div class="dark">
235
+ <%= marksmith_tag :body %>
236
+ </div>
237
+
238
+ <!-- or -->
239
+ <%= form_with model: post, class: "dark" do |form| %>
240
+ <%= form.marksmith :body %>
241
+ <% end %>
242
+
243
+ <!-- or -->
233
244
  <html class="dark">
234
- ...
245
+ <%= marksmith_tag :body %>
235
246
  </html>
236
247
  ```
237
248
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Marksmith 0.4.0
2
+ Marksmith 0.4.2
3
3
  */
4
4
  var ListContinuationController = (function () {
5
5
  'use strict';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Marksmith 0.4.0
2
+ Marksmith 0.4.2
3
3
  */
4
4
  var ListContinuationController = (function (stimulus) {
5
5
  'use strict';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Marksmith 0.4.0
2
+ Marksmith 0.4.2
3
3
  */
4
4
  var MarksmithController = (function () {
5
5
  'use strict';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Marksmith 0.4.0
2
+ Marksmith 0.4.2
3
3
  */
4
4
  var MarksmithController = (function (stimulus) {
5
5
  'use strict';
@@ -1,13 +1,13 @@
1
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
2
  <%= @form.marksmith @field.id,
3
3
  gallery: {
4
- enabled: true,
4
+ enabled: @field.gallery_enabled?,
5
5
  open_path: avo.attach_media_path,
6
6
  turbo_frame: ::Avo::MODAL_FRAME_ID,
7
7
  params: {
8
8
  resource_name: @resource.singular_route_key,
9
9
  controller_name: "marksmith",
10
- controller_selector: "[data-unique-selector='#{unique_id}']",
10
+ controller_selector: "[data-unique-selector=#{unique_id}]",
11
11
  record_id: @resource&.record&.to_param,
12
12
  }
13
13
  },
@@ -16,7 +16,9 @@
16
16
  },
17
17
  extra_preview_params: {
18
18
  resource_class: @resource.class.name,
19
- field_id: field.id,
20
- }
19
+ field_id: @field.id,
20
+ **@field.extra_preview_params
21
+ },
22
+ enable_file_uploads: @field.file_uploads
21
23
  %>
22
24
  <% end %>
@@ -101,4 +101,12 @@ class Marksmith::Editor
101
101
  def value
102
102
  form&.object&.send(name) || @value || nil
103
103
  end
104
+
105
+ def textarea_id
106
+ "#{id}-textarea"
107
+ end
108
+
109
+ def preview_pane_id
110
+ "#{id}-preview-pane"
111
+ end
104
112
  end
@@ -1,4 +1,4 @@
1
- <%= tag.markdown_toolbar for: name,
1
+ <%= tag.markdown_toolbar for: textarea_id,
2
2
  class: class_names("ms:flex ms:flex-wrap ms:px-2 ms:py-1", "ms:pointer-events-none": disabled),
3
3
  data: { marksmith_target: "toolbar" } do
4
4
  %>
@@ -15,9 +15,9 @@
15
15
  marksmith_extra_preview_params_value: editor.extra_preview_params.as_json,
16
16
  **editor.controller_data_attributes,
17
17
  } do %>
18
- <%= render partial: "marksmith/shared/toolbar", locals: { name: editor.name, disabled: editor.disabled } %>
18
+ <%= render partial: "marksmith/shared/toolbar", locals: { textarea_id: editor.textarea_id, disabled: editor.disabled} %>
19
19
  <div class="ms:border-t ms:w-full ms:border-neutral-500 ms:flex ms:flex-1">
20
20
  <%= render partial: "marksmith/shared/editor_pane", locals: { editor: } %>
21
- <%= render partial: "marksmith/shared/preview_pane", locals: { name: editor.name } %>
21
+ <%= render partial: "marksmith/shared/preview_pane", locals: { editor: } %>
22
22
  </div>
23
23
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <%= content_tag :div, class: "ms:flex ms:flex-1 ms:flex-col ms:size-full", data: { marksmith_target: "fieldContainer" } do %>
2
2
  <%= text_area_tag editor.field_name, editor.value,
3
- id: editor.name,
3
+ id: editor.textarea_id,
4
4
  class: class_names(
5
5
  "ms:flex ms:flex-1 ms:border-none ms:resize-none ms:focus:outline-none ms:font-mono ms:focus:ring-0 ms:leading-normal ms:p-2 ms:text-sm ms:field-sizing-content ms:min-h-60",
6
6
  "ms:dark:bg-neutral-800 ms:dark:text-neutral-200",
@@ -1,6 +1,6 @@
1
1
  <%= content_tag :div,
2
2
  class: "ms:hidden ms:markdown-preview ms:size-full ms:flex-1 ms:flex ms:size-full ms:p-2 ms:overflow-auto ms:bg-white ms:dark:bg-neutral-800 ms:rounded-b-md",
3
- id: "markdown-preview-#{name}",
3
+ id: editor.preview_pane_id,
4
4
  data: {
5
5
  marksmith_target: "previewPane",
6
6
  } do %>
@@ -4,5 +4,5 @@
4
4
  ) do %>
5
5
  <%= render partial: "marksmith/shared/tabs" %>
6
6
 
7
- <%= render partial: "marksmith/shared/action_bar", locals: { name:, disabled: } %>
7
+ <%= render partial: "marksmith/shared/action_bar", locals: { textarea_id:, disabled: } %>
8
8
  <% end %>
@@ -1,7 +1,14 @@
1
1
  module Marksmith
2
2
  module Fields
3
3
  class MarkdownField < Avo::Fields::BaseField
4
+ attr_reader :extra_preview_params,
5
+ :file_uploads
6
+
4
7
  def initialize(id, **args, &block)
8
+ @media_library = args[:media_library].nil? ? true : args[:media_library]
9
+ @extra_preview_params = args[:extra_preview_params] || {}
10
+ @file_uploads = args[:file_uploads]
11
+
5
12
  super(id, **args, &block)
6
13
 
7
14
  hide_on :index
@@ -10,6 +17,10 @@ module Marksmith
10
17
  def view_component_namespace
11
18
  "Marksmith::MarkdownField"
12
19
  end
20
+
21
+ def gallery_enabled?
22
+ Avo::MediaLibrary.configuration.enabled && @media_library
23
+ end
13
24
  end
14
25
  end
15
26
  end
@@ -1,3 +1,3 @@
1
1
  module Marksmith
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marksmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-03 00:00:00.000000000 Z
11
+ date: 2025-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport