question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use decorator with `findWithRegex` strategy along with `entityMap`

See original GitHub issue

Do you want to request a feature or report a bug? question

I’m struggling to understand the right way to use decorators in my use case.

I want to decorate/annotate a list of words that match a set of rules/regexs and allow the user to ignore certain words, so that they are not being highlighted anymore.

The idea of the ignore feature goes like this: I want to allow the user to ignore certain matches. For this I added a tooltip above the highlighted word. The issue is, if I just add a filter to ignore this specific regex, all the matches are ignored and I don’t want this. I want to ignore only this specific occurrence.

My idea was to get the entities from the entityMap and store the key in a ignore data structure. Now since I use the findWithRegex approach my entities and not really distinguishable since they are not listed in the entityMap.

Can you guys help me with it?

Any help would be highly appreciated. I’ve looked at the example (https://github.com/facebook/draft-js/blob/master/examples/draft-0-10-0/entity/entity.html) and read the docs (https://draftjs.org/docs/advanced-topics-decorators.html#content) and still don’t know what’s the best way of going about it.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
roundrobincommented, Jan 16, 2018

Let me know if you have any questions.

0reactions
ghostcommented, Sep 1, 2021

So was able to solve my use case at the end. The solution was still using composite decorators alongside with a regex strategy and on top of that using entities to store the ignored words.

Hey @roundrobin I know you posted this message a long time ago, but if by any chance you still have a snippet of a working solution that would help us very much 🙏 We are trying to do exactly the same feature but have not found how yet

Read more comments on GitHub >

github_iconTop Results From Across the Web

Decorators - Draft.js
The decorator concept is based on scanning the contents of a given ContentBlock for ranges of text that match a defined strategy, then...
Read more >
Draft-js building search and replace functionality - React Rocket
In this tutorial you'll learn how to implement a search and replace functionality. You'll use Modifiers to update state and decorators to ...
Read more >
Draftjs components with props - reactjs - Stack Overflow
I have a string with twitter handles. I use the decorator to detect regex @[{handle}] which replaces the handle and renders the component...
Read more >
Decorators - Learn DraftJS
The official recommended way of using decorators is super simple; there is a strategy; a function which searches for patterns in content blocks, ......
Read more >
How to use the draft-js.CompositeDecorator function in ... - Snyk
CompositeDecorator examples, based on popular ways it is used in public ... const decorator = new CompositeDecorator([ { strategy: findLinkEntities, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found