-
Notifications
You must be signed in to change notification settings - Fork 210
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
Add feature for moving the current block up and down #204
base: main
Are you sure you want to change the base?
Conversation
**ISSUE RESOLVED** @heyman Hello! I've implemented block moving feature requested in #37, but currently have a problem. Want to hear any ideas about the problem! Currently, moving a block up and down works when it is not related to the first block of the buffer. For example, as you can see in below example, moving the 2nd block down works, however, moving the 2nd block up is removing the content of the 1st block and the 2nd block. Same problem happens when moving the 1st block down. There is no problem when the moving block up or down, when the 1st block is not contained in the moving process.
I'm using following code to update the block ordering, dispatch(state.update({
changes: {
from: up ? neighborBlock.delimiter.from : currentBlock.delimiter.from,
to: up ? currentBlock.content.to : neighborBlock.content.to,
insert: newContent,
},
selection: newSelectionRange,
} and when moving the 2nd block up (or moving the 1st block down), it become something like this: dispatch(
state.update({
changes: {
from: 0,
to: "\n∞∞∞text-a\n1st block\n∞∞∞text-a\n2st block".length,
insert: "\n∞∞∞text-a\n2nd block\n∞∞∞text-a\n1st block",
},
}),
) The |
**ISSUE RESOLVED** Also, I found below example which I think is simpler example related to the above problem. dispatch(
state.update({
changes: {
from: 0,
to: "\n∞∞∞text-a\n012345".length,
insert: "\n∞∞∞text-a\n012345",
},
}),
) Running above code on the below left buffer should not change the buffer, however, it removes some text and changes the buffer to the right one.
|
I'll try to add some tests too! Also, I want to hear about the keyboard shortcuts. I've set
|
Ah, found what was causing it. Added an annotation to ignore the filter. heynote/src/editor/block/block.js Lines 236 to 253 in 387ef33
|
@heyman Any chance you could review this one? |
Hey! I'm swamped with other work at the moment, but I plan to get to it soon. |
Totally understandable. Thank you for your work and don't sweat it! |
@heyman, any update on this one? |
Support moving the current block up and down with keyboard shortcuts.
Closes #37.