sibiraj-s / ngx-editor

🖋️ Rich Text Editor for angular using ProseMirror
https://sibiraj-s.github.io/ngx-editor/
MIT License
458 stars 191 forks source link

[Bug]: Command Exec scrolls without scrollIntoView #389

Closed jode-reflact closed 2 years ago

jode-reflact commented 2 years ago

What happened?

Im using the following code snippet for enabling an bullet list in my editor this.editor.commands.toggleBulletList().exec();

Besides not using the scrollIntoView Function the window is still scrolled to the editor after execution. If this is not a bug, how do I prevent such behaviour?

Version

v12.2.2

What browsers are you seeing the problem on?

Chrome

Link to reproduce

No response

Relevant log output

No response

Willing to submit a PR?

No response

thuh-reflact commented 2 years ago

any news on this?

sibiraj-s commented 2 years ago

Sorry, had some personal emergencies. Back now. will look into it this weekend.

sibiraj-s commented 2 years ago

Sorry for the delay.

If this is not a bug, how do I prevent such behaviour?

This is not a bug. All commands automatically scrolls into view by default. scrollIntoView is to explicitly scroll based on the need. The editor uses prosemirror-commands under to work with commands. so unless natively rewriting all commands, its not possible to fix straightaway.

But, looking into other options to mitigate this issue.

jode-reflact commented 2 years ago

Thank you for the reply. A possible solution might be a passed function that is executed after all commands are done, which could be used to reset the window for example.

sibiraj-s commented 2 years ago

That might not look neat. there will be a jump.

Alternatively, there is handleScrollToSelection which could help.

handleScrollToSelection() {
 return true
}

but this will block all the scrolls including scrollIntoView method. looking into a way to differentiate them.

jode-reflact commented 2 years ago

handleScrollToSelection looks useful, is there any way to override it? Maybe through the editor config?

sibiraj-s commented 2 years ago

Not possible, I can add but it will block all scrolls. unless able to differentiate the transaction. that is okay?

jode-reflact commented 2 years ago

Yes that would be okay for my purpose

sibiraj-s commented 2 years ago

Will add that by today or tomorrow.

sibiraj-s commented 2 years ago

@jode-reflact handleScrollToSelection is added in v12.4.0

jode-reflact commented 2 years ago

Thanks, works like a charm!

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in the thread.