File tree Expand file tree Collapse file tree 2 files changed +2
-22
lines changed
Expand file tree Collapse file tree 2 files changed +2
-22
lines changed Original file line number Diff line number Diff line change 11/* @flow strict */
22
3- import { copyInput , copyNode , copyText } from './clipboard'
3+ import { copyNode , copyText } from './clipboard'
44
55function copy ( button : HTMLElement ) {
66 const id = button . getAttribute ( 'for' )
@@ -22,11 +22,7 @@ function copy(button: HTMLElement) {
2222
2323function copyTarget ( content : Element ) {
2424 if ( content instanceof HTMLInputElement || content instanceof HTMLTextAreaElement ) {
25- if ( content . type === 'hidden' ) {
26- return copyText ( content . value )
27- } else {
28- return copyInput ( content )
29- }
25+ return copyText ( content . value )
3026 } else if ( content instanceof HTMLAnchorElement && content . hasAttribute ( 'href' ) ) {
3127 return copyText ( content . href )
3228 } else {
Original file line number Diff line number Diff line change @@ -51,19 +51,3 @@ export function copyText(text: string): Promise<void> {
5151 body . removeChild ( node )
5252 return Promise . resolve ( )
5353}
54-
55- export function copyInput ( node : HTMLInputElement | HTMLTextAreaElement ) : Promise < void > {
56- if ( 'clipboard' in navigator ) {
57- // eslint-disable-next-line flowtype/no-flow-fix-me-comments
58- // $FlowFixMe Clipboard is not defined in Flow yet.
59- return navigator . clipboard . writeText ( node . value )
60- }
61-
62- node . select ( )
63- document . execCommand ( 'copy' )
64- const selection = getSelection ( )
65- if ( selection != null ) {
66- selection . removeAllRanges ( )
67- }
68- return Promise . resolve ( )
69- }
You can’t perform that action at this time.
0 commit comments