Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix blank cells at start and end #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ function looksLikeTable(data) {

editor.addEventListener("paste", function(event) {
var clipboard = event.clipboardData
var data = clipboard.getData('text/plain').trim()
var data = clipboard.getData('text/plain')

if(looksLikeTable(data)) {
event.preventDefault()
}else{
return
}

var rows = data.split((/[\u0085\u2028\u2029]|\r\n?/g)).map(function(row) {
row = row.replace('\n', ' ')
return row.split("\t")
})
var rows = data
.split(/[\u0085\u2028\u2029]|\r?\n/g)
.reduce(function (result, row) {
const re = /^[\t\n]*$/;
if (!re.test(row)) {
result.push(row.replace("\n", " ").split("\t"));
}
return result;
}, []);

var colAlignments = []

Expand Down