Comparing version 1.0.0 to 1.0.1
31
index.js
@@ -1,16 +0,23 @@ | ||
const onpaste = (e) => { | ||
const onpaste = (e, type) => { | ||
if (e.clipboardData) { | ||
// console.log('谷歌') | ||
for (let i = 0, len = e.clipboardData.items.length; i < len; i++) { | ||
const item = e.clipboardData.items[i] | ||
if (item.kind === 'string' && (item.type.match('^text/plain'))) { | ||
item.getAsString((str) => { | ||
const result = str.split('\r\n').filter(v => v).map(v => v.split('\t')) // 分隔回车,过滤空字符串 | ||
return result | ||
}) | ||
} else if (item.kind === 'file') { | ||
const result = item.getAsFile() | ||
return result | ||
return new Promise((resolve, reject) => { | ||
// e.clipboardData.items[0].getAsString((str) => { | ||
// const result = str.split('\r\n').filter(v => v).map(v => v.split('\t')) // 分隔回车,过滤空字符串 | ||
// resolve(result) | ||
// }) | ||
for (let i = 0, len = e.clipboardData.items.length; i < len; i++) { | ||
const item = e.clipboardData.items[i] | ||
const isString = !type || (type === 'string') | ||
if (isString && item.kind === 'string' && (item.type.match('^text/plain'))) { | ||
item.getAsString((str) => { | ||
const result = str.split('\r\n').filter(v => v).map(v => v.split('\t')) | ||
resolve(result) | ||
}) | ||
} else if (type === 'file' && item.kind === 'file') { | ||
const result = item.getAsFile() | ||
resolve(result) | ||
} | ||
} | ||
} | ||
}).catch((err) => console.log(err)) | ||
} else if (window.clipboardData) { | ||
@@ -17,0 +24,0 @@ // console.log('I9及以上') |
{ | ||
"name": "copytable", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "This is a method to copy table data and return the processed array.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1536
30