fix(core): use an AllSelection for the selectAll command #5516 (#5900)

This commit is contained in:
Andrye Chelnokov 2024-12-02 12:28:50 +03:00 committed by GitHub
parent ec8d654dc8
commit 722ec00fb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/core": patch
---
Use an AllSelection for the selectAll command #5516

View File

@ -1,3 +1,5 @@
import { AllSelection } from '@tiptap/pm/state'
import { RawCommands } from '../types.js'
declare module '@tiptap/core' {
@ -12,9 +14,12 @@ declare module '@tiptap/core' {
}
}
export const selectAll: RawCommands['selectAll'] = () => ({ tr, commands }) => {
return commands.setTextSelection({
from: 0,
to: tr.doc.content.size,
})
export const selectAll: RawCommands['selectAll'] = () => ({ tr, dispatch }) => {
if (dispatch) {
const selection = new AllSelection(tr.doc)
tr.setSelection(selection)
}
return true
}