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 +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/rails/clipboard/helper/version.rb +1 -1
- data/lib/rails/clipboard/helper/view_helpers.rb +17 -17
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ee315e134b969a778faf20d364cc9347f7535740b507f12ec2abe533f746430
|
|
4
|
+
data.tar.gz: db64ecd464944c6193a34c61e3a65fed79657d61c5da6404f524db5bc0d7e9c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
@@ -70,26 +70,25 @@ module Rails
|
|
|
70
70
|
|
|
71
71
|
# Inline JavaScript for clipboard functionality
|
|
72
72
|
onclick_js = <<~JS.strip.gsub("\n", ' ')
|
|
73
|
-
(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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}"
|
|
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
|
|