Skip to content
Discussion options

You must be logged in to vote

Ok, I think I got it. Sharing the code in case anyone finds this useful:

const capitalizeSelection = (editor: Editor) => {
  if (!editor.selection) {
    return;
  }
  // save the original selection
  const selection = { ...editor.selection };

  // get the affected nodes
  for (const [node, path] of Editor.nodes(editor, {
    at: selection,
    match: (n) => Text.isText(n)
  })) {
    // define a range containing the whole text
    const nodeRange: Range = {
      anchor: {
        path: path,
        offset: 0
      },
      focus: {
        path: path,
        offset: (node as Text).text.length
      }
    };

    // obtain the part of the selection withing this node containing range
    

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aarcoraci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant