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

Feature: add a “move” event? #214

Open
jenstroeger opened this issue Jun 23, 2021 · 13 comments
Open

Feature: add a “move” event? #214

jenstroeger opened this issue Jun 23, 2021 · 13 comments

Comments

@jenstroeger
Copy link
Collaborator

I think it would be useful (at least for my use case) to have a “move” event, similar to the current switch event. It fires when the user holds e.g. the Alt key together with the arrow up/down key at the top/bottom of the element, thus indicating that the element should be moved up or down.

If you’re open to that, then I’d supply a PR.

@peyerluk
Copy link
Member

peyerluk commented Jun 28, 2021

It fires when the user holds e.g. the Alt key together with the arrow up/down key

Is this inspired from some other tool where you can move elements this way? I'm not familiar with this combo.

But generally we're open to the idea.

There is a PR on the way regarding the switch event to allow for some more natural cursor interaction when switching between blocks. It probably makes sense to build your work from that or wait until we merge it in the coming days.

@jenstroeger
Copy link
Collaborator Author

Is this inspired from some other tool where you can move elements this way? I'm not familiar with this combo.

It’s not.

I’m just looking for a comfortable way to move paragraphs in a document up/down. Click-and-drag works already, but the grip icon doesn’t seem to work for users. Holding Alt seems nice and unintrusive, although the actual key should probably be configured (even disabled in the default config, in which case the “move” event wouldn’t fire).

There is a PR on the way regarding the switch event […]

Do you have an ETA for that PR? It would probably make sense for me to wait and build on top of that?

@peyerluk
Copy link
Member

Do you have an ETA for that PR? It would probably make sense for me to wait and build on top of that?

It's merged now :)

@jenstroeger
Copy link
Collaborator Author

It's merged now :)

Great, thank you!

Also, I just noticed that the 'move' event is already added but doesn’t seem to be used anywhere? Is that a relic from previous versions?

editable.js/src/core.js

Lines 511 to 514 in 8e477fa

;['focus', 'blur', 'flow', 'selection', 'cursor', 'newline',
'insert', 'split', 'merge', 'empty', 'change', 'switch',
'move', 'clipboard', 'paste', 'spellcheckUpdated'
].forEach((name) => {

@peyerluk
Copy link
Member

Yes. That's a relic.

@jenstroeger
Copy link
Collaborator Author

Lucky me, I’ve repurposed it for now 👍🏼

@marcbachmann
Copy link
Member

marcbachmann commented Oct 5, 2021

the Alt key together with the arrow up/down key at the top/bottom of the element, thus indicating that the element should be moved up or down.

Actually, vscode is using ALT + ⬆️ or ALT + ⬇️ to move text around.
But its' slightly unintuitive because ALT + ⬅️ and ALT + ➡️ are shortcut to move the cursor one word to the left and right.

@marcbachmann
Copy link
Member

I guess we can close this for now

@jenstroeger
Copy link
Collaborator Author

jenstroeger commented Oct 5, 2021

Actually, vscode is using ALT + ⬆️ or ALT + ⬇️ to move text around.

Dang, I didn’t know! (Well, I barely use VS Code anyway.) But yes, just tried it out and that’s exactly how ALT + ⬆️ or ALT + ⬇️ work on my site 👍🏼

I wouldn’t say it’s unintuitive — I got used to it quickly 😉

I guess we can close this for now

Bummer. Well, I’ll just keep it in my fork… But in that case, you might want to remove the "move" string above?

@marcbachmann
Copy link
Member

marcbachmann commented Oct 5, 2021

Oh, we could implement if you really want to. But at the moment it's also conflicting with jumping to the end of a block.

I'm not really a fan to change the default behavior.

@marcbachmann marcbachmann reopened this Oct 5, 2021
@marcbachmann
Copy link
Member

I'd rather bind CMD + ALT + ⬆️

@jenstroeger
Copy link
Collaborator Author

@marcbachmann, well if you want I can create a PR from my local change and you can take a look. If it’s too invasive and not too useful we can always close later…

I'd rather bind CMD + ALT + ⬆️

And on Windows that’d be CTRL + ALT + ⬆️?

@marcbachmann
Copy link
Member

And on Windows that’d be CTRL + ALT + ⬆️?

yes

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

No branches or pull requests

3 participants