Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: empty tags when splitting nested tags #46

Merged
merged 10 commits into from
Sep 19, 2013
Merged

Conversation

matteoagosti
Copy link
Contributor

When working with nested tags something bad can happen.

Example:

<strong>uris</strong>

Making the initial u italic results in

<strong><em>u</em></strong>

Moving the cursor after the u and pressing enter results in the cursor at the beginning of the next block. Pressing backspace doesn't work because of that:

screen shot 2013-09-13 at 13 14 05

The cursor is placed after the nested em tag, so beginning of host won't work. In general we should be robust against this situation by dealing with empty tags (but br), however I wonder if we should clean these in normalizeTags (the one that merge tags due to split). If I think about it, in my opinion it doesn't make sense to have a formatting tag without any content, thus it should be deleted. @peyerluk shall I fix normalizeTags for that?

@ghost ghost assigned matteoagosti Sep 13, 2013
@matteoagosti
Copy link
Contributor Author

content.normalizeTags should take care of empty tags

I added the remove empty tag logic to normalize tags
as within that function we are already iterating for all
nodes.
Previously we were cleaning out content on focus and
blur despite what was happening, this resulted in bad
markup when merging. In my opinion a better approach
is to do the cleaning you need, only when you need it.
Thus, I did the cleaning in merge and split. Still we have
something when blur that is necessary as it has to
happen after leaving a block where we inserted a new
line; we will use the blur also for trimming traling spaces.
We cannot assume that the underlying HTML is clean
so we should take the chance to clean up stuff once
we initialize editable.
This doesn't remove spaces at the end, it just converts
the last one to make it visible. I think the strategy of not
having spaces at all in the end should go in a config
option and shouldn't be a task of normalizeSpaces.

Conflicts:
	src/content.js
@matteoagosti
Copy link
Contributor Author

While sorting out the empty tags I also fixed the way we run the sanitization logic in default behavior. Instead of having everthing on focus/blur I added what is needed where it is needed (so split/merge basically). @peyerluk what do you think?

@peyerluk
Copy link
Member

👍

This description follows the old guidelines, but I see that
we have a conflict with the current master branch as
we already refactored this test file. This needs to be
fixed when merging.
@matteoagosti
Copy link
Contributor Author

Should be OK now for merging, I'll take care of this as several conflicts need to be solved first. Just let me know if it is OK for you or we should integrate something else.

@peyerluk
Copy link
Member

Looks great to me :)

matteoagosti added a commit that referenced this pull request Sep 19, 2013
Bug: empty tags when splitting nested tags
@matteoagosti matteoagosti merged commit 0514b85 into master Sep 19, 2013
@matteoagosti matteoagosti deleted the normalize-tags branch September 19, 2013 13:15
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