Hi,
I have to create a shortcut after which the bullet list will be created. The shortcut is * + Space (like in Slack). The problem is with the remained content which I need to replace. For now, when I press * + Space, I get the bullet list icon, and after it this content: "* ". I wrote this code to replace "* ", but it leaves the empty space at the beginning which I can’t get rid of.
What I get before executing the code below:
- “* (and space)”
After executing code:
- (one space here)
// Above is the function that creates bullet list and handle * + Space const { from, to } = state.selection;
customTransaction
.delete(from + 1, to + 2)
.setSelection(
new TextSelection(
customTransaction.doc.resolve(
customTransaction.selection.$cursor.pos - 1
)
)
);
dispatch(customTransaction);
Is there a method to move the cursor before space or remove it (replaceWith, replaceSelectionWith, deleteSelection I’ve already tried)?
Thanks