Open sophiebits opened 8 years ago
Unfortunately I don't have the energy right now to figure out the draft-js build + test system, but here's what I got working by editing SecondaryClipboard.js
directly in my node_modules folder so that I could test it in my toy editor:
https://gist.github.com/danneu/89cbcf64bcb62995b91cb80acf8bf79b#file-secondaryclipboard-js-L12-L32
Not sure the ideal way to delete the current block, either. Thought I'd be able to leverage the backspace behavior:
if (block.getText().length === 0) {
return RichUtils.onBackspace(editorState) || editorState
}
but got some runtime error after the block was deleted.
Could have updated the blockMap myself, but seemed like surely there was a helper I could use.
I recall @sophiebits addressed this issue with 645549343e7248ae07bf8e274de971acfe1c53c0, so it can be closed
@claudiopro That's a different issue; can you reopen?
Repro for this one:
* a
opt-enter b
then go to before the a
Expected: Only the "a" is deleted. Actual: "a", the newline, and "b" is deleted
In the line selection.set('focusOffset', blockEnd);
, instead of using blockEnd
it should find the first newline whose position is greater than the current focusOffset and then cut up to (but not including) that char.
Thanks for pointing that out, I'll look into that 👍
Usually blocks don't have newlines in them, but when they do (shift-enter in a list item, for example), Ctrl-K should delete to the newline, not the end of the block.
Also, Ctrl-K should delete an empty block.