Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't override behaviour of Home / End in pc keymap #2691

Merged
merged 1 commit into from Apr 9, 2022

Conversation

scottsidwell
Copy link

@scottsidwell scottsidwell commented Apr 8, 2022

Description

Fixes #2685 by removing the Home/End keybindings in the PC keymap.

This was similarly removed in Prosemirror at ProseMirror/prosemirror-commands@20371c58, to favour default browser / OS behaviour.

Note: This behaviour continues to be preserved on Mac under the Ctrl-a and Ctrl-e keys

For users who wish to preserve this behaviour, they can achieve this via a custom extension:

const CustomKeyboardBehaviour = Extension.create({
  addKeyboardShortcuts() {
    return {
      ['Home']: () => this.editor.commands.selectTextblockStart(),
      ['End']: () => this.editor.commands.selectTextblockEnd(),
    }
  }
})

const editor = new Editor({
  extensions: [
    // Register your custom extension with the editor.
    CustomKeyboardBehaviour,
  ]
});

If we haven't reached consensus on this change, then feel free to ignore. Just raising the PR in case this is all that's missing to resolve the issue.

@netlify
Copy link

netlify bot commented Apr 8, 2022

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit d270419
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/624f8ab0eb015f0009a36d03
😎 Deploy Preview https://deploy-preview-2691--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Similarly removed in Prosemirror at ProseMirror/prosemirror-commands@20371c58

For users who wish to preserve this behaviour, they can achieve this via:

```javascript
const CustomKeyboardBehaviour = Extension.create({
  addKeyboardShortcuts() {
    return {
      ['Home']: () => this.editor.commands.selectTextblockStart(),
      ['End']: () => this.editor.commands.selectTextblockEnd(),
    }
  }
})

const editor = new Editor({
  extensions: [
    // Register your custom extension with the editor.
    CustomKeyboardBehaviour,
  ]
});
```
@scottsidwell scottsidwell force-pushed the fix/pc-keymap-for-home-and-end branch from 3cbe6e6 to d270419 Compare April 8, 2022 01:06
@bdbch
Copy link
Contributor

bdbch commented Apr 9, 2022

Looks good to me, thank your for your contribution. I agree - the default editor should always be mimicking the default OS behaviour.

@bdbch bdbch merged commit fb7a80d into ueberdosis:main Apr 9, 2022
@rfgamaral
Copy link
Contributor

@bdbch Are you able to build and publish new releases? Would love to get a version with this in...

@bdbch
Copy link
Contributor

bdbch commented Apr 12, 2022

We're looking for releasing a new version very soon! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Home/End buttons don't move the cursor to the start/end of the text line
3 participants