rails-clipboard-helper 0.1.2 → 0.1.4

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: c0677492d465fef53bf7ac5e072f8588305f52c9fbf9ca492ea244dcc236536f
4
- data.tar.gz: 8d7083bd4bbf188e7ccdf55f8ea10745dddcea0a5817d8d00eb7573d2a180a62
3
+ metadata.gz: 8ee315e134b969a778faf20d364cc9347f7535740b507f12ec2abe533f746430
4
+ data.tar.gz: db64ecd464944c6193a34c61e3a65fed79657d61c5da6404f524db5bc0d7e9c6
5
5
  SHA512:
6
- metadata.gz: a08bc12b49178a98d48b116b08c98361d6e312eca98471d80fca5c92613ae73bf8ad7fd89178ed50de5513298c9615146234403c007b6622de9d8839487917f0
7
- data.tar.gz: ab6aa201508f6d34af7c05741e94f03051ee0a8980906e465fd726e48fb8fb478c8d2fb9d7d560bddd4b45cf19a824facd445759d7d973e1c380c1d69b1b994f
6
+ metadata.gz: 2ab94059e4c3cbec455f2c8a4722b86fed215ce44673361769c92a80b78374b4098288edd98d632db2b96a0c53fc6be78c6c701721a5678a59fca942e515e1ce
7
+ data.tar.gz: 3a4fb74ffcab2d0309d03bcda5ec695696ddaf48835947290be4192f21125083fd305eac49bf17a1ec980265577452b22f48273a19e5083fb6c461b76098f045
data/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.4] - 2025-11-09
9
+
10
+ ### Changed
11
+ - Removed `display: flex` from container default style for better layout flexibility
12
+ - Container now renders elements inline by default
13
+
14
+ ## [0.1.3] - 2025-11-09
15
+
16
+ ### Fixed
17
+ - Fixed HTML entity escaping issue in onclick JavaScript
18
+ - Simplified inline JavaScript by removing IIFE wrapper and using `this` directly
19
+
20
+ ### Changed
21
+ - Changed implementation to use hidden DOM element for copied content instead of string escaping
22
+ - Improved code readability and maintainability
23
+
8
24
  ## [0.1.2] - 2025-11-09
9
25
 
10
26
  ### Changed
@@ -39,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
39
55
  - Implemented `clipboard_javascript_tag` helper method (for backward compatibility)
40
56
  - Clipboard copy functionality with automatic JavaScript loading
41
57
  - Rails Engine for automatic asset integration
58
+ [0.1.3]: https://github.com/dhq_boiler/rails-clipboard-helper/releases/tag/v0.1.3
42
59
  - Support for Sprockets, Importmap, esbuild, and webpack
43
60
  - Turbo/Hotwire and Turbolinks support
44
61
  - Customizable button text and CSS classes
@@ -3,7 +3,7 @@
3
3
  module Rails
4
4
  module Clipboard
5
5
  module Helper
6
- VERSION = "0.1.2"
6
+ VERSION = "0.1.4"
7
7
  end
8
8
  end
9
9
  end
@@ -70,26 +70,25 @@ module Rails
70
70
 
71
71
  # Inline JavaScript for clipboard functionality
72
72
  onclick_js = <<~JS.strip.gsub("\n", ' ')
73
- (function(btn) {
74
- const target = document.getElementById('#{unique_id}');
75
- const text = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' ? target.value : target.textContent;
76
- navigator.clipboard.writeText(text).then(() => {
77
- const original = btn.innerHTML;
78
- btn.innerHTML = '#{copied_content.gsub("'", "\\\\'")}';
79
- btn.style.color = '#28a745';
80
- setTimeout(() => {
81
- btn.innerHTML = original;
82
- btn.style.color = '#0066cc';
83
- }, 2000);
84
- }).catch(err => {
85
- console.error('Failed to copy:', err);
86
- alert('Failed to copy to clipboard');
87
- });
88
- })(this);
73
+ const target = document.getElementById('#{unique_id}');
74
+ const copiedElement = document.getElementById('#{unique_id}-copied');
75
+ const text = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' ? target.value : target.textContent;
76
+ navigator.clipboard.writeText(text).then(() => {
77
+ const original = this.innerHTML;
78
+ this.innerHTML = copiedElement.innerHTML;
79
+ this.style.color = '#28a745';
80
+ setTimeout(() => {
81
+ this.innerHTML = original;
82
+ this.style.color = '#0066cc';
83
+ }, 2000);
84
+ }).catch(err => {
85
+ console.error('Failed to copy:', err);
86
+ alert('Failed to copy to clipboard');
87
+ });
89
88
  JS
90
89
 
91
90
  html = <<~HTML
92
- <div class="#{container_class}" style="display: flex; align-items: center; gap: 10px;">
91
+ <div class="#{container_class}">
93
92
  #{show_content ? %Q(<span class="#{content_class}" id="#{unique_id}">#{ERB::Util.html_escape(content)}</span>) : %Q(<input type="hidden" id="#{unique_id}" value="#{ERB::Util.html_escape(content)}">)}
94
93
  <button
95
94
  type="button"
@@ -101,6 +100,7 @@ module Rails
101
100
  >
102
101
  #{button_content}
103
102
  </button>
103
+ <span id="#{unique_id}-copied" style="display: none;">#{copied_content}</span>
104
104
  </div>
105
105
  HTML
106
106
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-clipboard-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler