1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-02 19:52:32 +02:00

fix: promptMention not defined (#3195)

* fix: promptMention not defined

* style: eslint
This commit is contained in:
Ziad Beyens
2019-12-02 02:56:28 +01:00
committed by Ian Storm Taylor
parent b2d0255097
commit b1b0052705

View File

@@ -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 (
<Slate editor={editor} defaultValue={initialValue}>
<Toolbar>
@@ -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)
}}
>
<Icon>person_pin</Icon>