Skip to content

Commit

Permalink
fix(core): use an AllSelection for the selectAll command #5516 (#5900)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyChelnokov authored Dec 2, 2024
1 parent ec8d654 commit 722ec00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-islands-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tiptap/core": patch
---

Use an AllSelection for the selectAll command #5516
15 changes: 10 additions & 5 deletions packages/core/src/commands/selectAll.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AllSelection } from '@tiptap/pm/state'

import { RawCommands } from '../types.js'

declare module '@tiptap/core' {
Expand All @@ -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
}

0 comments on commit 722ec00

Please sign in to comment.