Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Ctrl-K at end of line should delete newline
Browse files Browse the repository at this point in the history
Summary: If you're at the end of a line and press Ctrl-K (on Mac OS), it should delete the newline (same as if you had just pressed forward-delete). Now it does (and stores the newline in the secondary clipboard, as Ctrl-K always does).

Reviewed By: claudiopro

Differential Revision: D13085302

fbshipit-source-id: b32cfcd41ad4ff482ff71621f98bd6524c415fc5
  • Loading branch information
sophiebits authored and facebook-github-bot committed Nov 19, 2018
1 parent 010fce7 commit 6455493
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/component/handlers/edit/commands/SecondaryClipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ const SecondaryClipboard = {
const blockEnd = content.getBlockForKey(anchorKey).getLength();

if (blockEnd === selection.getAnchorOffset()) {
return editorState;
targetRange = selection
.set('focusKey', content.getKeyAfter(anchorKey))
.set('focusOffset', 0);
} else {
targetRange = selection.set('focusOffset', blockEnd);
}

targetRange = selection.set('focusOffset', blockEnd);
} else {
targetRange = selection;
}

targetRange = nullthrows(targetRange);
// TODO: This should actually append to the current state when doing
// successive ^K commands without any other cursor movement
clipboard = getContentStateFragment(content, targetRange);

const afterRemoval = DraftModifier.removeRange(
Expand Down

0 comments on commit 6455493

Please sign in to comment.