マイペースなRailsおじさん

Ruby、Ruby on Rails、オブジェクト指向設計を主なテーマとして扱います。だんだん大きくなっていくRuby on Rails製プロダクトのメンテナンス性を損なわない方法を考えたり考えなかったりしている人のブログです。

tribute.js supports `contenteditable`

tribute.js is used to implement mention feature.

GitHub - zurb/tribute: ES6 Native @mentions

By the way, in Slack (and some chat applications) highlights inputted mentions as illustrated below.

f:id:ytnk531:20210217042734p:plain

tribute.js can implement such decoration. I implemented very simple example in jsfiddle.

https://jsfiddle.net/ntxmrc5y/3/

This can be realized by contenteditable specification. If we use textarea, or text input field, we can not decorate input text. But we can, by using contenteditable element.