Skip to content

Commit 722ec00

Browse files
fix(core): use an AllSelection for the selectAll command #5516 (#5900)
1 parent ec8d654 commit 722ec00

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

.changeset/six-islands-breathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tiptap/core": patch
3+
---
4+
5+
Use an AllSelection for the selectAll command #5516

packages/core/src/commands/selectAll.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { AllSelection } from '@tiptap/pm/state'
2+
13
import { RawCommands } from '../types.js'
24

35
declare module '@tiptap/core' {
@@ -12,9 +14,12 @@ declare module '@tiptap/core' {
1214
}
1315
}
1416

15-
export const selectAll: RawCommands['selectAll'] = () => ({ tr, commands }) => {
16-
return commands.setTextSelection({
17-
from: 0,
18-
to: tr.doc.content.size,
19-
})
17+
export const selectAll: RawCommands['selectAll'] = () => ({ tr, dispatch }) => {
18+
if (dispatch) {
19+
const selection = new AllSelection(tr.doc)
20+
21+
tr.setSelection(selection)
22+
}
23+
24+
return true
2025
}

0 commit comments

Comments
 (0)