ponkotsu-md-editor 0.2.1 → 0.2.3

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: 62a1a937b8cf271a226386c2661c8decedc24ae6b2189e92ba2358f8a9428228
4
- data.tar.gz: 72feda410a62df3df6f05ba7fae531eb7c44f8f1fc77d73284d85a1b69258efa
3
+ metadata.gz: d007b75a9e2bfeabb03abec88127f8aeda9985e9a74a3fbcff8c342feff476f1
4
+ data.tar.gz: e9b2b7ab14c48f2fda20f22ff1c691ec99f73d05cd14df2c4e59b3631aa5f603
5
5
  SHA512:
6
- metadata.gz: 57667cc623bba7c40bb54d83dedc7eb8b7a85af87a6b4314f67a43ced501b7d068ef770b0d43b055d8ed5c9cb039c764b16800d5e28c45e19c44d2f6f495590f
7
- data.tar.gz: e998286e7ddfead67721ed9d287ec148b770e7a1c9f0ec9b360fe02ceec263dca7e146b2608d959aef970d6b4c140f07e2622476c1006d38fbdf3107963eb06d
6
+ metadata.gz: f546344f1057a655b542c08cbe80eaaf7e61dd7259aa56b5ecd36c8fe10b043af8229100cf23ffbf0dc34e4407997400f27edc8df3633883b6f9c7f06758e20e
7
+ data.tar.gz: 9ded99ef961fbc338226e0edded2985397204c3df576a636181ef84128318b6cc4b88e83148b0714dcc71e1034a984bcd7341bae2bc58878f527207777283320
@@ -15,6 +15,19 @@
15
15
  function onReady(callback) {
16
16
  if (document.readyState === 'loading') {
17
17
  document.addEventListener('DOMContentLoaded', callback);
18
+
19
+ const textarea = document.getElementById('editor_content');
20
+ const hiddenField = document.getElementById('content_hidden_field');
21
+
22
+ if (textarea && hiddenField) {
23
+ const syncToHidden = () => {
24
+ hiddenField.value = textarea.innerText || '';
25
+ };
26
+ textarea.addEventListener('input', syncToHidden);
27
+ textarea.addEventListener('blur', syncToHidden);
28
+ // 初期化時にも同期
29
+ syncToHidden();
30
+ }
18
31
  } else {
19
32
  callback();
20
33
  }
@@ -8,22 +8,23 @@ module PonkotsuMdEditor
8
8
  # This module provides view helpers that can be used in ERB templates
9
9
  # to integrate the PonkotsuMdEditor functionality
10
10
  module Helpers
11
- # Renders a Markdown editor component with the specified content and options
11
+ # Renders a Markdown editor component for the given form and attribute.
12
12
  #
13
- # @param form [ActionView::Helpers::FormBuilder] Form builder object
14
- # @param content [String] Initial content to display in the editor (default: "")
15
- # @param options [Hash] Configuration options for the editor (default: {})
16
- # @return [String] Rendered HTML for the Markdown editor
13
+ # @param form [ActionView::Helpers::FormBuilder] The form builder object.
14
+ # @param attribute [Symbol, String] The attribute name to bind the editor to (e.g., :content).
15
+ # @param options [Hash] Editor configuration options (e.g., :lang, :preview, :tools, :placeholder).
16
+ # @return [String] The rendered HTML for the Markdown editor.
17
17
  #
18
18
  # Example usage in a Rails view:
19
19
  # <%= markdown_editor(f, :content, {
20
- # lang: :en,
21
- # preview: true,
22
- # tools: [ :bold, :italic, :strikethrough ],
23
- # placeholder: "This is Placeholder."
24
- # }) %>
20
+ # lang: :en,
21
+ # preview: true,
22
+ # tools: [:bold, :italic, :strikethrough],
23
+ # placeholder: "This is Placeholder."
24
+ # }) %>
25
25
  def markdown_editor(form, attribute, options = {})
26
26
  form = form[:form] if form.is_a?(Hash)
27
+ attribute = attribute[:attribute] if attribute.is_a?(Hash)
27
28
  render "ponkotsu_md_editor/editor", locals: { attribute: attribute, form: form, options: options }
28
29
  end
29
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PonkotsuMdEditor
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ponkotsu-md-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler