Skip to content

Dynamic highlighter while typing #1812

Discussion options

You must be logged in to vote

You could also solve this with decorations. Read about it in the ProseMirror guide. The linter experiment is maybe a good reference.

Another way is to dynamically add a class to the editor based on its content:

new Plugin({
  props: {
    attributes: state => {
      if (state.doc.textContent.length <= 10) {
        return {
          class: 'your-custom-class',
        }
      }
    },
  },
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hanspagel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants