fix: site example(Search Highlighting) range #5670
Merged
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.
Description
When I was testing the 'decorations' feature on the official website (search-highlighting), I noticed that there were some issues with supporting content that had been split into multiple formats.
Issue
none
Example
When I search for "adds", it works pretty well. However, when I perform a search that spans nodes, it doesn't highlight the content very effectively.
Context
I think it's necessary to tackle this issue. Initially, I planned to start with Range.intersection, by calculating the overlapping ranges at the parent node and judging the intersection of multiple nodes to address this issue. However, I realized that this might impose a burden on the rendering performance of Slate, as it may need to constantly traverse nodes for searching.
Therefore, I resolved this issue here by modifying the example of the site. By clearly identifying the content to be searched and the boundaries of the split nodes to obtain smaller values to form a range, even if the content being searched is very long, it will only save the search content within its own range.
Additionally, I noticed that there's no option for
site
changes in the changeset config. Therefore, I believe that this change doesn't require a changeset.Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)