-
Notifications
You must be signed in to change notification settings - Fork 25
feat(highlighting): Can display textrange-based highlights #164
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
Conversation
|
Closed for now in favor of #166 |
f4b3005 to
9f5ee6b
Compare
src/core.js
Outdated
| * @param {String} options.text | ||
| * @param {String} options.highlightId Added to the highlight markups in the property `data-word-id` | ||
| * @param {Object} [options.textRange] An optional range which gets used to set the markers. | ||
| * @param {Number} [options.textRange.start] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think start and end are not optional if a textRange object is passed, right? So I think we can remove the square brackets around the param name here and in the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
|
||
| describe('highlightSupport', () => { | ||
| beforeEach(() => { | ||
| setupHighlightEnv(this, 'People Make The <br> World Go Round') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should replace all arrow functions in this file with regular functions if you use this here. Otherwise this code is quite misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(We could also do this in a separate PR for all tests in editable.js)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to go with your second suggestion, as currently a lot of tests misbehave if you only just adjust the beforeEach scopings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to go with your second suggestion
That's ok
as currently a lot of tests misbehave if you only just adjust the beforeEach scopings.
This is because you have to change all methods in the same file at once, otherwise you mix scopes which does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did replace all of them to the point where I had now arrow functions at all anymore (at least in this spec), but still all hell broke loose. I'd rather do this with a little more focus and time.
| }) | ||
| }) | ||
|
|
||
| describe('highlightSupport', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these tests never test if we actually to the right thing! You only check that the index positions are the same, we do not know that the right characters are selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests now check for the text equivalent of the ranges. See also comment below.
| * | ||
| * @param {Object} options | ||
| * @param {DOMNode} options.editableHos | ||
| * @return {Object} ranges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not include the text in the ranges? Otherwise how do you get the text of a range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not include the text in the ranges?
Done. Good point. Will have to adjust specs in the framework as well. JFYI
src/highlighting.js
Outdated
| throttle: 1000, | ||
| // remove highlights after a change if the cursor is inside a highlight | ||
| removeOnCorrection: true, | ||
| removeOnCorrection: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
| end: 9 | ||
| } | ||
| } | ||
| const expectedHtml = this.formatHtml(`People M |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two closing spans. Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my typo. The test was still passing because of this
|
🎉 This PR is included in version 1.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Relations:
Changelog
highlightnow takes an additional optional option argumenttextRange {start: number, end: number, text: string }. If given, it is used to determine the span position rather than the regex matches ontext.Known issues
Pull Request Checklist