How can I add a custom-style text in the editor through the button click event?

147 Views Asked by At

I expect that through the click event of the button, A piece of text can be injected behind $selection in the current editor, and has a customized style

example:

<span class"custom-style">MyFriendName</span>

trying now

I go to read the similar plugin in lexical-editor plugin, This effect is what I want to achieve, but this effect is currently converted into a hashtag tag by inputting text. I hope that this tag can be injected into the back of $selection through a button

lexical-editor demo

Result Expected screenshot:

enter image description here

0

There are 0 best solutions below