mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-15 03:33:59 +02:00
Fix triple click handling in nested blocks (#4965)
This commit is contained in:
5
.changeset/neat-pets-grow.md
Normal file
5
.changeset/neat-pets-grow.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix tripple click handling in nested blocks
|
@@ -780,9 +780,17 @@ export const Editable = (props: EditableProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.detail === TRIPLE_CLICK && path.length >= 1) {
|
if (event.detail === TRIPLE_CLICK && path.length >= 1) {
|
||||||
const start = Editor.start(editor, [path[0]])
|
let blockPath = path
|
||||||
const end = Editor.end(editor, [path[0]])
|
if (!Editor.isBlock(editor, node)) {
|
||||||
const range = Editor.range(editor, start, end)
|
const block = Editor.above(editor, {
|
||||||
|
match: n => Editor.isBlock(editor, n),
|
||||||
|
at: path,
|
||||||
|
})
|
||||||
|
|
||||||
|
blockPath = block?.[1] ?? path.slice(0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const range = Editor.range(editor, blockPath)
|
||||||
Transforms.select(editor, range)
|
Transforms.select(editor, range)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user