Immediate help needed in building auto highlight feature by matching with preloaded list of words

I am trying to build an auto highlight feature if matches with an list of available words maybe like 500 words. Suggest an optimized technical approach without affecting performance to build this feature in tiptap editor. I have seen the Linter example similar the badWords example there will be around 500 to 1000 words in the example regex is operation performed and I am concerned about the performance of the editor as the user input grows.