Skip to content

Commit 6eb324f

Browse files
committed
Stop emoji autocompletion when it got escaped by hitting <Esc>
Signed-off-by: Jonas <[email protected]>
1 parent f090c52 commit 6eb324f

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

src/EditorFactory.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { translate as t } from '@nextcloud/l10n'
3333
import { listLanguages, registerLanguage } from 'lowlight/lib/core.js'
3434
import { emojiSearch } from '@nextcloud/vue/dist/Functions/emoji.js'
3535
import { VueRenderer } from '@tiptap/vue-2'
36-
import EmojiList from './components/EmojiList.vue'
36+
import EmojiListWrapper from './components/EmojiListWrapper.vue'
3737
import MentionSuggestion from './components/Mention/suggestion.js'
3838
import tippy from 'tippy.js'
3939

@@ -73,7 +73,7 @@ const createEditor = ({ content, onCreate, onUpdate, extensions, enableRichEditi
7373

7474
return {
7575
onStart: props => {
76-
component = new VueRenderer(EmojiList, {
76+
component = new VueRenderer(EmojiListWrapper, {
7777
parent: this,
7878
propsData: props,
7979
})
@@ -98,7 +98,8 @@ const createEditor = ({ content, onCreate, onUpdate, extensions, enableRichEditi
9898

9999
onKeyDown(props) {
100100
if (props.event.key === 'Escape') {
101-
popup[0].hide()
101+
component.destroy()
102+
popup[0].destroy()
102103
return true
103104
}
104105
return component.ref?.onKeyDown(props)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!--
2+
- @copyright Copyright (c) 2021 Jonas <[email protected]>
3+
-
4+
- @author Jonas <[email protected]>
5+
-
6+
- @license GNU AGPL version 3 or any later version
7+
-
8+
- This program is free software: you can redistribute it and/or modify
9+
- it under the terms of the GNU Affero General Public License as
10+
- published by the Free Software Foundation, either version 3 of the
11+
- License, or (at your option) any later version.
12+
-
13+
- This program is distributed in the hope that it will be useful,
14+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
- GNU Affero General Public License for more details.
17+
-
18+
- You should have received a copy of the GNU Affero General Public License
19+
- along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
-
21+
-->
22+
23+
<template>
24+
<EmojiList ref="emojiList"
25+
:items="items"
26+
:command="command" />
27+
</template>
28+
29+
<script>
30+
import EmojiList from './EmojiList.vue'
31+
32+
export default {
33+
name: 'EmojiListWrapper',
34+
35+
components: {
36+
EmojiList,
37+
},
38+
39+
props: {
40+
items: {
41+
type: Array,
42+
required: true,
43+
},
44+
command: {
45+
type: Function,
46+
required: true,
47+
},
48+
},
49+
50+
methods: {
51+
onKeyDown({ event }) {
52+
// Ignore any key modifier combinations
53+
return this.$refs.emojiList?.onKeyDown({ event })
54+
},
55+
},
56+
}
57+
</script>

0 commit comments

Comments
 (0)