easy-markdown-editor icon indicating copy to clipboard operation
easy-markdown-editor copied to clipboard

How to use tribute.js to achieve the mentions?

Open sTeaPig opened this issue 5 years ago • 10 comments

Is there any way to use tribute.js to achieve the mentions in the EasyMDE? or other ways to achieve mentions? thanks!

sTeaPig avatar May 30 '20 09:05 sTeaPig

@sTeaPig did you ever implement tribute.js in easyMDE? If yes, please shine some light :)

artknight avatar Oct 19 '21 22:10 artknight

I'm not familiar with tribute.js, but maybe something similar to https://froala.com/wysiwyg-editor/examples/tribute-js can be done.

Ionaru avatar Oct 20 '21 22:10 Ionaru

@Ionaru how soon do you think this could be implemented?

artknight avatar Oct 21 '21 00:10 artknight

@Ionaru One issue I noticed is that it seems the keyup and keydown events never make it to tribute. I added a few breakpoints and those never get hit.

artknight avatar Oct 21 '21 14:10 artknight

@Ionaru an update: setting inputStyle: 'contenteditable' seems to have resolved the event propagation. However, when using the keyboard up/down keys the enter does not select the option... simply goes to the new line leaving just the @ sign

artknight avatar Oct 21 '21 15:10 artknight

Check out https://github.com/zurb/tribute/issues/511

Ionaru avatar Oct 21 '21 18:10 Ionaru

@Ionaru lol I had already commented on there :)

artknight avatar Oct 21 '21 18:10 artknight

@Ionaru how can i insert an html element into the easymde editor without it getting stripped out?

ex. I would like to add <span contenteditable="false"><a href="...">@JackBauer</a></span>

However, all i get added is the @JackBauer.. the html wrappers are stripped out

artknight avatar Oct 22 '21 15:10 artknight

Maybe you can insert the element after the editor itself is rendered, using DOM manipulation or jQuery.

Tbh this sounds like it's more a CodeMirror issue than something for this repo. I'd suggest you try and get it working using CodeMirror first and then try applying that to easyMDE.

Also you don't need to @ me in every reply.

Ionaru avatar Oct 22 '21 16:10 Ionaru

@Ionaru so it turns out that the reason for the html tags getting stripped out is due to the gfm mode. I have modified my template to return a true md syntax [...](link address...) instead of an actual html tag. However, I would prefer to be able to add an html tag that could be ignored by the sanitizer. Any ideas?

artknight avatar Oct 23 '21 23:10 artknight