bentd / outline-editor

outline editor component for standardnotes
0 stars 0 forks source link

Highlighting/selecting text with ctrl/cmd + a immediately dehighlights the text #1

Closed moughxyz closed 5 years ago

moughxyz commented 5 years ago

Tested on Safari and Chrome 73 on macOS.

bentd commented 5 years ago

So this one was actually rather simple. When a bullet is edited (a key is pressed), the cursor automatically moves to the end of the line on keyup. So if you also clicked on the middle of a line and typed a letter, the cursor would also move to the end of line. By disabling the cursor from moving the bullet's text can be selected with ctrl/cmd+a as well as edited in the middle of the text rather than just the end.

bentd commented 5 years ago

Changed this:

function editBullet(address, content) {
  return {
    type: EDIT_BULLET,
    exec: (state) => {
      let node = getNode(copy(address), state.root);
      node.content = content;
      focusNode(node); // moves cursor to end of the bullet
      return state;
    }
  }
}

To this:

function editBullet(address, content, focus=false) {
  return {
    type: EDIT_BULLET,
    exec: (state) => {
      let node = getNode(copy(address), state.root);
      node.content = content;
      if (focus) {
        focusNode(node);
      }
      return state;
    }
  }
}
moughxyz commented 5 years ago

It's good to close issues via commits, this way, there's a historical record of how each issue was fixed without having to comment it. So in your code, when you make the fix, you create a new commit with the text "Fixes #1", and when you push it to GitHub, it will automatically close this issue and link the commit, so we can see the exact code changes.