Skip to content

Enhanced backspace#81

Open
bananaoomarang wants to merge 2 commits into
masterfrom
enhanced-backspace
Open

Enhanced backspace#81
bananaoomarang wants to merge 2 commits into
masterfrom
enhanced-backspace

Conversation

@bananaoomarang
Copy link
Copy Markdown
Contributor

Add special event for backspacing at the beginning of the editor

Comment thread source/Editor.js


// Merge any text nodes we split
mergeInlines( startContainer, range );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very irritating. There seems to be a bug where mergeInlines will actually screw up the range, giving getHTML dangerous side effects. Unsure why we need to mergeInlines instead of Node.normalize here, but if there is a real reason we will need to fix mergeInlines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably look at this anyway. I stepped through and noticed two things:

  1. The {start,end}Offset calculation doesn't seem accurate
  2. The actual process of detaching/re-appending the nodes seems to alter the selection (I guess possibly when the selection is 'dangling' it defaults to the end of the container node?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this is tricky. On master, if you have two adjacent bold tags backspace will merge them. In this PR that is no longer the case. Personally I like that behavior and it leads to cleaner content over time, but we can move the mergeinines into backspace to do the same thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However I'm not sure there aren't other side effects. Will play with this more over the weekend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I will take another look at that mergeInlines, there should be a way to get it to properly 'restore' the selection.

Alternatively we can just avoid using withBookmarks here and figure out the cursor position by just looking at the range, and sidestep this issue entirely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the mergeInlines is desirable in some cases, but don't think a method called getHTML should modify the content

@bananaoomarang
Copy link
Copy Markdown
Contributor Author

We should also add a mirror event for delete at the bottom-right of a block, so we can handle that case. Currently not handled at all I don't think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants