1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-29 11:18:25 +01:00

fix the bug of user can't use 'mod + a' to select or delete all nodes when use image(void) element (#5344)

Co-authored-by: linqirong <609413692@qq.com>
This commit is contained in:
qirong77 2023-03-08 21:51:12 +08:00 committed by GitHub
parent 2a0a530931
commit ee7eac4331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
import React, { useMemo } from 'react'
import imageExtensions from 'image-extensions'
import isUrl from 'is-url'
import isHotkey from 'is-hotkey'
import { Transforms, createEditor, Descendant } from 'slate'
import {
Slate,
@ -29,6 +30,12 @@ const ImagesExample = () => {
<InsertImageButton />
</Toolbar>
<Editable
onKeyDown={event => {
if (isHotkey('mod+a', event)) {
event.preventDefault()
Transforms.select(editor, [])
}
}}
renderElement={props => <Element {...props} />}
placeholder="Enter some text..."
/>