Closed jakeburden closed 7 years ago
oh this works with plucker too!
window.addEventListener('keyup', function (e) {
// press 'c' to copy value to clipboard
if (e.keyCode === 67) {
var object = { hello: { world: { lorem: 'ipsum' } } }
window.choo.copy('hello.world.lorem', object)
}
})
will copy 'ipsum'
to the clipboard
Nice work! Lil nit on the API tho, would be cool if this just workedâ„¢:
window.choo.copy() // => copied the whole state
window.choo.copy('state.form.foo') // => copied a specific path
Also probably worth filtering out any functions b/c if they're stringified you get the weird [Object function]
style blocks haha
hey @yoshuawuyts :wave: I just pushed up a change to this branch that lets .copy()
get the whole state, it also checks if a function was passed in and if so, ignores it and just copies the whole state.
Not done yet though, I'll get this part working next:
window.choo.copy('state.form.foo') // => copied a specific path
just pushed up a change that lets window.choo.copy('state.form.foo')
copy choo state at a specific path to clipboard :)
howdy @yoshuawuyts :wave:
are there any outstanding features of this api thats left to complete?
v1.3.0
- added you as an owner too! :sparkles:
ref: #4
allows for exposing a
window.choo.copy
method the lets users copy state to clipboard.example:
Note: it turns out document.execCommand('copy') only works with user gestured events such as click and keyup. Thats the reason why the example has an event listener. I had an idea too, it might be useful for there to be a choo-expose-ui that creates a nice button for choo devs to click and get application state in the clipboard. Would love to get your thoughts!
Cheers!