Browse Source

[Fix][UI Next][V1.0.0-Beta] Fix bug where name copy is invalid (#9684)

3.0.0/version-upgrade
Devosend 3 years ago committed by GitHub
parent
commit
99678c097c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      dolphinscheduler-ui-next/src/utils/clipboard.ts

12
dolphinscheduler-ui-next/src/utils/clipboard.ts

@ -16,16 +16,14 @@
*/ */
export const copy = (text: string): boolean => { export const copy = (text: string): boolean => {
const range = document.createRange() const inp = document.createElement('input')
const node = document.createTextNode(text) document.body.appendChild(inp)
document.body.append(node) inp.value = text
range.selectNode(node) inp.select()
window.getSelection()?.addRange(range)
let result = false let result = false
try { try {
result = document.execCommand('copy') result = document.execCommand('copy')
} catch (err) {} } catch (err) {}
window.getSelection()?.removeAllRanges() inp.remove()
document.body.removeChild(node)
return result return result
} }

Loading…
Cancel
Save