how to remove selection

hello, I used the following code to select a portion of the text:

view.value.dispatch({
    selection: EditorSelection.create([
        EditorSelection.range(startPos.from, endPos.to),
    ]),
    scrollIntoView: true,
});

However, I want to clear this selection before the content of the editor changes. How can I achieve this?