mirror of
https://github.com/outline/outline.git
synced 2025-03-14 10:07:11 +00:00
16 lines
413 B
TypeScript
16 lines
413 B
TypeScript
import { Command, TextSelection } from "prosemirror-state";
|
|
|
|
/**
|
|
* A prosemirror command to collapse the current selection to a cursor at the start of the selection.
|
|
*
|
|
* @returns A prosemirror command.
|
|
*/
|
|
export const collapseSelection = (): Command => (state, dispatch) => {
|
|
dispatch?.(
|
|
state.tr.setSelection(
|
|
TextSelection.create(state.doc, state.tr.selection.from)
|
|
)
|
|
);
|
|
return true;
|
|
};
|