Fix Escape key propagation from MentionList/MentionPopup (#4038)

Signed-off-by: anotherpit <anotherpit@gmail.com>
Signed-off-by: Petr Vyazovetskiy <develop.pit@gmail.com>
This commit is contained in:
Pete Anøther 2023-11-23 03:02:55 -03:00 committed by GitHub
parent 9a0f5da25b
commit 7ac12a4ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ import MentionList from './MentionList.svelte'
import { NodeUuidExtension } from './extension/nodeUuid' import { NodeUuidExtension } from './extension/nodeUuid'
import { SvelteRenderer } from './node-view' import { SvelteRenderer } from './node-view'
import { CodemarkExtension } from './extension/codemark' import { CodemarkExtension } from './extension/codemark'
import type { SuggestionKeyDownProps, SuggestionProps } from './extension/suggestion'
export const tableExtensions = [ export const tableExtensions = [
Table.configure({ Table.configure({
@ -157,14 +158,14 @@ export const completionConfig: Partial<CompletionOptions> = {
class: 'reference' class: 'reference'
}, },
suggestion: { suggestion: {
items: async (query: { query: string }) => { items: async () => {
return [] return []
}, },
render: () => { render: () => {
let component: any let component: any
return { return {
onStart: (props: any) => { onStart: (props: SuggestionProps) => {
component = new SvelteRenderer(MentionList, { component = new SvelteRenderer(MentionList, {
element: document.body, element: document.body,
props: { props: {
@ -175,10 +176,13 @@ export const completionConfig: Partial<CompletionOptions> = {
} }
}) })
}, },
onUpdate (props: any) { onUpdate (props: SuggestionProps) {
component.updateProps(props) component.updateProps(props)
}, },
onKeyDown (props: any) { onKeyDown (props: SuggestionKeyDownProps) {
if (props.event.key === 'Escape') {
props.event.stopPropagation()
}
return component.onKeyDown(props) return component.onKeyDown(props)
}, },
onExit () { onExit () {