From b1b00527054ff29dc80c8eb7abd3b7b56111031b Mon Sep 17 00:00:00 2001 From: Ziad Beyens Date: Mon, 2 Dec 2019 02:56:28 +0100 Subject: [PATCH] fix: promptMention not defined (#3195) * fix: promptMention not defined * style: eslint --- site/examples/mentions.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/site/examples/mentions.js b/site/examples/mentions.js index 0761ff222..3e757445e 100644 --- a/site/examples/mentions.js +++ b/site/examples/mentions.js @@ -12,21 +12,21 @@ import { import { Button, Icon, Toolbar } from '../components' +const promptMention = editor => { + const name = window.prompt('Who would you like to mention?') + if (!name) return + const regex = new RegExp(`^${name}`, 'i') + const match = Object.entries(USERS).find(([, name]) => regex.test(name)) + const id = match ? match[0] : 57 + editor.exec({ type: 'insert_mention', id }) +} + const MentionExample = () => { const editor = useMemo( () => withMentions(withReact(withHistory(createEditor()))), [] ) - const promptMention = () => { - const name = window.prompt('Who would you like to mention?') - if (!name) return - const regex = new RegExp(`^${name}`, 'i') - const match = Object.entries(USERS).find(([, name]) => regex.test(name)) - const id = match ? match[0] : 57 - editor.exec({ type: 'insert_mention', id }) - } - return ( @@ -38,7 +38,7 @@ const MentionExample = () => { onKeyDown={event => { if (event.key === '@') { event.preventDefault() - promptMention() + promptMention(editor) } }} /> @@ -121,7 +121,7 @@ const MentionButton = () => { active={isMentionActive(editor)} onMouseDown={event => { event.preventDefault() - promptMention() + promptMention(editor) }} > person_pin