mirror of
https://github.com/outline/outline.git
synced 2026-11-21 05:24:03 +03:00
17 lines
454 B
TypeScript
17 lines
454 B
TypeScript
import type { Command } from "prosemirror-state";
|
|
import { 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;
|
|
};
|