Ability to tag mark elements belonging to the same keyword when acrossElements = true
See original GitHub issueI would like to request an enhancement request to allow tagging mark elements belonging to the same keyword occurrence when acrossElements
is set to true
.
For example, I would like to search for “1st OCT” and I turn on option acrossElements
so the following occurrences could be found:
- 1st OCT
- 1st OCT (html code:
1<sup>st</sup> OCT
) - 1st OCT (html code:
1st <b>OCT</b>
)
Now, I would like to be able to correlate mark elements for each of the last 2 examples to know that they are coupled. I could use #each callback to add a custom attribute with magic value to mark elements of each occurrence, but the problem is that as it seems I’m not able to distinguish when to change the magic value between occurrences.
It would be nice to either add another callback option to be informed that the occurrence of keyword is about to be processed, or update #each callback to provide additional two parameters: fragmentCount, fragmentsTotal. Then I could update magic value each time when fragmentCount==fragmentsTotal.
The use case is to be able to handle right click on coupled elements and for example allow user to remove mark elements from the particular occurrence.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9
That would be a useful feature if mark.js could return groups of mark nodes for every match rather than separate mark nodes it inserts in the DOM. We are developing a rich text editor and using mark.js to highligh search matches and faced the same problem as @pskowronek. I’ve slightly modified the “jump to matches” example to show the issue: https://jsfiddle.net/4hrk6v7s/. When you enter
Lorem
in the search box you will have two matches instead of a single match for the word Lorem, which is partially in bold.A possible solution may by a callback option that triggers every time a whole match gets highlighted and receives the array of the inserted <mark> nodes
This is an issue I’m also running into! Seconding the above.