A little lost in ProseMirror at the moment and trying to understand the correct way to replace the text of the current selection. I want to be able to toggle the case between lower/upper case.
state.selection.content();
will return slice of the relevant nodes under the selection, and the content that is selected, but does not return the range within each node that would need to replaced.
I assume I would need to create a new text node to replace the range within each selected node something like:
const updatedText = node.textContent.toUpperCase();
const textNode = state.schema.text(updatedText);
transaction = transaction.replaceWith(startPos, startPos + node.nodeSize, textNode);
How do I get the range to replace within each node?
Unfortunately, I cannot find a suitable example.