Allow Shift-Delete to be used for Cut
This PR updates the handler in cleditKeystroke.js that implements Delete functionality (to remove the selected text) to ignore events where the key event is Shift-Delete.
First, some backstory: Two eternities ago, when user interfaces that didn't require you to type commands in one by one were a brand new thing, there were two different schools of thought that arose independently:
-
At the Xerox PARC, they created a user interface where Ctrl-X, Ctrl-C and Ctrl-V were mapped to cut, copy and paste, respectively. This was inherited by the Apple Lisa and subsequently the Macintosh, and became the standard for clipboard operations on Mac systems.
-
At IBM, a document was developed called the IBM Common User Access standard -- IBM CUA. Per IBM CUA, the cut, copy and paste operations are Shift-Delete, Ctrl-Insert and Shift-Insert, respectively. Applications by IBM for the IBM PC used this standard.
When Microsoft was mashing together the IBM world and the Macintosh world in a little DOS app called Windows, they saw both of these standards and implemented them both. As a result, from day 1, on Windows systems, you have always been able to take your pick between ^X ^C ^V and Shift-Del, Ctrl-Ins and Shift-Ins. This continues to this day. Modern Linux windowing systems often also set up these same mappings -- historically, ^X ^C ^V was for the Clipboard buffer and Shift-Del, Ctrl-Ins and Shift-Ins was for the Selection buffer, but common household distributions like Ubuntu do not preserve this distinction.
It is notable that to this day, the IBM CUA clipboard keys continue to be absent in Macintosh UI.
Now, to the issue at hand: Per issue #1279, in a much earlier revision of StackEdit, at least 6 years ago and probably a bit longer, clipboard manipulation keyboard mappings were delegated to the browser. Whatever the browser supported and turned into 'cut', 'copy' and 'paste' events would behave this way within StackEdit. But, a change made back then added a new keystroke handler specific to Delete operations, and this handler reacts to any Backspace or Delete keystroke, irrespective of whether the shift key is down. As a result, it hijacks the browser's default behaviour for Shift-Delete.
Ever since this change, Shift-Delete in StackEdit just deletes the selection, exactly as if Shift weren't pressed. People who use ^X ^C ^V for clipboard actions never even noticed this, but people whose muscle memory presses Shift-Delete for Cut have been very frustrated by this ever since. (I am one of them.)
(Note that Ctrl-Insert still copies and Shift-Insert still pastes, only Shift-Delete is inadvertently intercepted and remapped.)
This PR restores the functionality by adding a filter to the keystroke handler so that it responds to Delete but not to Shift-Delete.
Closes: #1279
Wow I rarely enjoy reading a pull request 👏🏿