stimulus-clipboard
Advanced tools
Comparing version 3.2.1 to 3.2.2
@@ -9,2 +9,8 @@ # Changelog | ||
## [3.2.2] | ||
### Chore | ||
- Allow `sourceTarget` to be any HTML element to copy its `innerHTML`. | ||
## [3.2.1] | ||
@@ -11,0 +17,0 @@ |
@@ -10,3 +10,4 @@ import { Controller } from "@hotwired/stimulus"; | ||
event.preventDefault(); | ||
navigator.clipboard.writeText(this.sourceTarget.value).then(() => this.copied()); | ||
const text = this.sourceTarget.innerHTML || this.sourceTarget.value; | ||
navigator.clipboard.writeText(text).then(() => this.copied()); | ||
} | ||
@@ -13,0 +14,0 @@ copied() { |
@@ -1,1 +0,1 @@ | ||
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t(require("@hotwired/stimulus")):typeof define=="function"&&define.amd?define(["@hotwired/stimulus"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,e["stimulus-clipboard"]=t(e.Stimulus))})(this,function(e){"use strict";class t extends e.Controller{connect(){!this.hasButtonTarget||(this.originalContent=this.buttonTarget.innerHTML)}copy(i){i.preventDefault(),navigator.clipboard.writeText(this.sourceTarget.value).then(()=>this.copied())}copied(){!this.hasButtonTarget||(this.timeout&&clearTimeout(this.timeout),this.buttonTarget.innerText=this.data.get("successContent"),this.timeout=setTimeout(()=>{this.buttonTarget.innerHTML=this.originalContent},this.successDurationValue))}}return t.targets=["button","source"],t.values={successDuration:{type:Number,default:2e3}},t}); | ||
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t(require("@hotwired/stimulus")):typeof define=="function"&&define.amd?define(["@hotwired/stimulus"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,e["stimulus-clipboard"]=t(e.Stimulus))})(this,function(e){"use strict";class t extends e.Controller{connect(){!this.hasButtonTarget||(this.originalContent=this.buttonTarget.innerHTML)}copy(i){i.preventDefault();const s=this.sourceTarget.innerHTML||this.sourceTarget.value;navigator.clipboard.writeText(s).then(()=>this.copied())}copied(){!this.hasButtonTarget||(this.timeout&&clearTimeout(this.timeout),this.buttonTarget.innerText=this.data.get("successContent"),this.timeout=setTimeout(()=>{this.buttonTarget.innerHTML=this.originalContent},this.successDurationValue))}}return t.targets=["button","source"],t.values={successDuration:{type:Number,default:2e3}},t}); |
{ | ||
"name": "stimulus-clipboard", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"description": "A Stimulus controller to copy text to clipboard.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
6782
36