added experimental combined normalize/copy-button

This commit is contained in:
Thelonius Kort
2020-08-31 17:58:12 +02:00
parent 2a43868956
commit eeb200bd98
5 changed files with 47 additions and 11 deletions

View File

@ -17,10 +17,14 @@ import {Socket} from "phoenix"
import NProgress from "nprogress"
import {LiveSocket} from "phoenix_live_view"
import '@babel/polyfill'
import { copy_func } from './buttons'
let Hooks = {}
Hooks.SnippetInput = {
updated(){
this.el.value = this.el.dataset.updatedVal
copy_func()
}
}
@ -38,13 +42,3 @@ 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
}