mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Add emoji button to text editor toolbar
This commit is contained in:
parent
0c5aa10812
commit
00b3d7b19a
|
@ -2,6 +2,8 @@ import getCaretCoordinates from 'textarea-caret';
|
|||
|
||||
import { extend } from 'flarum/extend';
|
||||
import ComposerBody from 'flarum/components/ComposerBody';
|
||||
import TextEditor from 'flarum/components/TextEditor';
|
||||
import TextEditorButton from 'flarum/components/TextEditorButton';
|
||||
import emojiMap from './generated/emojiMap.json';
|
||||
import getEmojiIconCode from './helpers/getEmojiIconCode';
|
||||
import KeyboardNavigatable from 'flarum/utils/KeyboardNavigatable';
|
||||
|
@ -45,7 +47,7 @@ export default function addComposerAutocomplete() {
|
|||
|
||||
$textarea
|
||||
.after($container)
|
||||
.on('click keyup', function(e) {
|
||||
.on('click keyup input', function(e) {
|
||||
// Up, down, enter, tab, escape, left, right.
|
||||
if ([9, 13, 27, 40, 38, 37, 39].indexOf(e.which) !== -1) return;
|
||||
|
||||
|
@ -162,4 +164,12 @@ export default function addComposerAutocomplete() {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
extend(TextEditor.prototype, 'toolbarItems', function(items) {
|
||||
items.add('emoji', (
|
||||
<TextEditorButton onclick={() => this.insertAtCursor(':')} icon="far fa-smile">
|
||||
{app.translator.trans('flarum-emoji.forum.composer.emoji_tooltip')}
|
||||
</TextEditorButton>
|
||||
));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user