Skip to content

Feature: add a “move” event? #214

@jenstroeger

Description

@jenstroeger
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.

Activity

peyerluk

peyerluk commented on Jun 28, 2021

@peyerluk
Member

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

jenstroeger commented on Jun 28, 2021

@jenstroeger
CollaboratorAuthor

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

peyerluk commented on Jun 28, 2021

@peyerluk
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

jenstroeger commented on Jun 29, 2021

@jenstroeger
CollaboratorAuthor

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

peyerluk commented on Jun 30, 2021

@peyerluk
Member

Yes. That's a relic.

jenstroeger

jenstroeger commented on Jun 30, 2021

@jenstroeger
CollaboratorAuthor

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

marcbachmann

marcbachmann commented on Oct 5, 2021

@marcbachmann
Member

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

marcbachmann commented on Oct 5, 2021

@marcbachmann
Member

I guess we can close this for now

jenstroeger

jenstroeger commented on Oct 5, 2021

@jenstroeger
CollaboratorAuthor

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

marcbachmann commented on Oct 5, 2021

@marcbachmann
Member

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 commented on Oct 5, 2021

@marcbachmann
Member

I'd rather bind CMD + ALT + ⬆️

jenstroeger

jenstroeger commented on Oct 5, 2021

@jenstroeger
CollaboratorAuthor

@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

marcbachmann commented on Oct 5, 2021

@marcbachmann
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @peyerluk@marcbachmann@jenstroeger

        Issue actions

          Feature: add a “move” event? · Issue #214 · livingdocsIO/editable.js