iWOLFSTEIN / mention_tag_text_field

Other
9 stars 9 forks source link

[Question] How to work with mentionStarts: [ '{{', '{' ] #8

Open DenserMeerkat opened 3 months ago

DenserMeerkat commented 3 months ago

Say I want to allow my users to use both {{ and { to trigger the suggestions, but since { is a substring of {{ , I don't think so it ever identifies the user as entered {{. So even if user types {{ only one of them get replaced while mention gets add. So I wanted to know is there a way to control what string gets replaced when mention gets added?

iWOLFSTEIN commented 3 months ago

You can use your own custom styling widget while adding the mentions.

DenserMeerkat commented 3 months ago

Yes, I'm using that feature, but what I'm asking is when I have mentionStart: ['{{', '{'] and the user types {{ the mentionValue sent to the onMention function is { and not {{.

Hence when adding a mention it replaces a single { and I get it like this. image

iWOLFSTEIN commented 3 months ago

@DenserMeerkat mention start currently doesn't support a start character with length greater than 1. That's why you are getting unexpected behavior for "{{". One way around you can use is to check if onMention return "{{" when user add double brackets, in that case you add mention and then manually remove the extra bracket from the controller. Don't remove the bracket first before adding mention cause it'll lead to unexpected behavior.

DenserMeerkat commented 3 months ago

mention start currently doesn't support a start character with length greater than 1

Ohh okay 👍.

One way around you can use is to check if onMention return "{{" when user add double brackets.

It always reads only a single {.