Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This PR adds a highlighting API to the CodeEditor. It builds on top of the scroll state PR and allows programmatic setting of various background colors either at instantiation or via the data update WS message protocol. There is also an API for removing highlighted code.
Approach
Ace editor provides an
addMarker
(andremoveMarker
) editor session methods which are used to add (or remove) Ace content overlay element css classes. The advantage of these is that they provide a clean way to interact with the editor session state; the disadvantage is that we cannot directly manipulate the style attributes of any specific row elements. However, this is the recommended way to create various markers that won't interfere with the rest of the Ace environment. We use these methods to add classes for red, blue and green colors (other colors can be added as needed, by simply creating the corresponding css classes in ourapp.css
file).The CodeEditor cell class now has an
addRowHighlight()
as well as ahighlightRange
init param which allow setting the first row, last row and color (limited) of the highlighting. There is also a.removeRowHighlight()
which gets rid of the marker/highlight.How Has This Been Tested?
Playground demo examples have been added and web/selenium tests written & pass.
Types of changes
Checklist: