At the moment, every <th> and <td> has contenteditable set to true unless the column is autoincrementing. When the user begins typing, presses paste, or hits enter, the sheet enters editing mode, which adds a drop shadow to the selected cell and tells the onblur listener to save changes. When the cell is blurred (or the user presses escape), editing mode is deactivated.
An alternative is to only make <th>s and <td>s contenteditable during edit mode. In theory, this should be more performant(?) because there's only a single contenteditable cell at a time. Also, we don't have to do the cursor magic when navigating between cells to ensure the entire contents are highlighted.
For some reason, entering editing mode is slower on large tables with this route (which is quite peculiar). Copy and paste works well, and sets us up to handle more complicated copies and pastes (like handling multiple cells). But the former approach has the advantage of copy and past just working, and it actually supports undo/redo -- multiple of them!!
So I think the former approach wins, even though it's a bit odder. Really just leaving this discussion here for posterity.
At the moment, every
<th>
and<td>
hascontenteditable
set totrue
unless the column is autoincrementing. When the user begins typing, presses paste, or hits enter, the sheet entersediting
mode, which adds a drop shadow to the selected cell and tells theonblur
listener to save changes. When the cell is blurred (or the user presses escape),editing
mode is deactivated.An alternative is to only make
<th>
s and<td>
scontenteditable
during edit mode. In theory, this should be more performant(?) because there's only a singlecontenteditable
cell at a time. Also, we don't have to do the cursor magic when navigating between cells to ensure the entire contents are highlighted.Here's how it can be accomplished:
For some reason, entering
editing
mode is slower on large tables with this route (which is quite peculiar). Copy and paste works well, and sets us up to handle more complicated copies and pastes (like handling multiple cells). But the former approach has the advantage of copy and past just working, and it actually supports undo/redo -- multiple of them!!So I think the former approach wins, even though it's a bit odder. Really just leaving this discussion here for posterity.