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