more normalization and copy button
This commit is contained in:
@ -20,10 +20,7 @@ import {LiveSocket} from "phoenix_live_view"
|
||||
let Hooks = {}
|
||||
Hooks.SnippetInput = {
|
||||
updated(){
|
||||
// + cursor reposition logic
|
||||
// console.log(['dings', this.el.dataset])
|
||||
this.el.value = this.el.dataset.updatedVal
|
||||
// this.el.select()
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,3 +38,13 @@ liveSocket.connect()
|
||||
// >> liveSocket.enableDebug()
|
||||
// >> liveSocket.enableLatencySim(1000)
|
||||
window.liveSocket = liveSocket
|
||||
|
||||
document.querySelector("button[id='copy-button']").onclick = function(){
|
||||
var ta = document.querySelector("textarea[name='snippet']")
|
||||
var start = ta.selectionStart
|
||||
var end = ta.selectionEnd
|
||||
ta.select()
|
||||
document.execCommand("copy");
|
||||
ta.selectionStart = start
|
||||
ta.selectionEnd = end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user