diff --git a/.changeset/six-islands-breathe.md b/.changeset/six-islands-breathe.md new file mode 100644 index 0000000000..e4d80bb155 --- /dev/null +++ b/.changeset/six-islands-breathe.md @@ -0,0 +1,5 @@ +--- +"@tiptap/core": patch +--- + +Use an AllSelection for the selectAll command #5516 diff --git a/packages/core/src/commands/selectAll.ts b/packages/core/src/commands/selectAll.ts index b29baa8b09..5cb2208bf3 100644 --- a/packages/core/src/commands/selectAll.ts +++ b/packages/core/src/commands/selectAll.ts @@ -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 }