tiptap/packages/core/src/commands/selectAll.ts
Arnau Gómez Farell 89bd9c7d29
Fix/enforce-type-imports-so-that-bundler-ignores-types (#6132)
* fix: enforce type imports so that the bundler ignores types

* chore: add changeset

* fix: export types with export type keyword
2025-03-03 15:15:30 +01:00

28 lines
545 B
TypeScript

import { AllSelection } from '@tiptap/pm/state'
import type { RawCommands } from '../types.js'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
selectAll: {
/**
* Select the whole document.
* @example editor.commands.selectAll()
*/
selectAll: () => ReturnType
}
}
}
export const selectAll: RawCommands['selectAll'] =
() =>
({ tr, dispatch }) => {
if (dispatch) {
const selection = new AllSelection(tr.doc)
tr.setSelection(selection)
}
return true
}