dom-highlight-range
dom-highlight-range copied to clipboard
Customize the element used for highlighting
Changes the exported highlightRange function signature to accept an HTMLElement, a callback function, or a string as the second parameter. This is used to create the highlight wrapper nodes. This is useful for adding context from the calling application to each logical highlight. This is backward-compatible with the current behavior (string).
Fixes #1.
Argh. I screwed up the whitespace, so the diff is messier than it should be. I’ll clean this up later and push to this PR.
@Treora, OK, I think I’ve cleaned up my commits, if you want to take a look. I’ll try to put together an HTML test page to exercise the new capabilities this weekend.
@Treora, I’ve added example.html to illustrate the four options and fixed a few bugs in the early PR (oops!). Please let me know if this works for you.
Thanks for taking a look. All good suggestions. I’ll address these and update the PR (hopefully this weekend).
I’d been avoiding ES2015, such as arrow functions, because it looks like you’d stuck to ES5. Is ES5 a goal?
Also, did you have any feedback on example.html. It’s not unit tests, but it exercises the functionality and provides some implementation guidance.
I’d been avoiding ES2015, such as arrow functions, because it looks like you’d stuck to ES5. Is ES5 a goal?
Oh yes I forgot this module is plain ES5, so let's indeed stick with that. :)
Also, did you have any feedback on example.html
Had to try that still; looks pretty cool! Needs a <meta charset="utf-8"> still for the pencil to render correctly.
OK, I think I’ve incorporated your feedback. Let me know how this looks.