Skip to content

Conversation

@javan
Copy link
Contributor

@javan javan commented Jan 18, 2016

When re-parsing the editor's HTML, we create a location range using points because the unknown input may have removed Trix's block comment nodes. Calculating a location range from HTML with missing comment nodes would often result in the wrong cursor position after rendering. Usually off by 1, at the end of the preceding block. See #116 and #131.

Using points works well most of the time, but occasionally fails in conditions that are difficult to reproduce. This change removes the use of points, and goes back to using LocationMapper, but with a new strict: false mode that uses the containing elements to make an assumption about where a block starts. getLocationRange(strict: false) is only used by Composition#replaceHTML so all other getLocationRange calls continue to work as normal (looking for <!--block--> nodes to mark a block's start).

javan added 3 commits January 18, 2016 11:04
When re-parsing the HTML, we previously created a location range using points because the unknown input may have removed Trix's block comment nodes. This worked well most of the time, but occasionally it failed in conditions that are difficult to reproduce.
javan added a commit that referenced this pull request Jan 19, 2016
@javan javan merged commit e29c5a7 into master Jan 19, 2016
@javan javan deleted the fuzzy-location-mapping branch January 19, 2016 15:53
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