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

Pass changeObject to onChange #196

Merged
merged 1 commit into from
Apr 13, 2022
Merged

Pass changeObject to onChange #196

merged 1 commit into from
Apr 13, 2022

Conversation

tonyjmnz
Copy link
Contributor

There are cases where it's useful to know which type of change was made (specific key press, paste from clipboard) and while it is possible to achieve this by adding another change handler to the CodeMirror instance, this seems to be simple

From CodeMirror's docs:

"change" (instance: CodeMirror, changeObj: object)
Fires every time the content of the editor is changed. The changeObj is a {from, to, text, removed, origin} object containing information about the changes that occurred as second argument. from and to are the positions (in the pre-change coordinate system) where the change started and ended (for example, it might be {ch:0, line:18} if the position is at the beginning of line #19). text is an array of strings representing the text that replaced the changed range (split by line). removed is the text that used to be between from and to, which is overwritten by this change. This event is fired before the end of an operation, before the DOM updates happen.

Pass CodeMirror changeObject to the onChange event handler
@RIP21
Copy link
Owner

RIP21 commented Apr 13, 2022

Deploy broken for some reason, but change is legit. Merging it. Will publish it tomorrow.

@RIP21 RIP21 merged commit 5db3acc into RIP21:master Apr 13, 2022
@RIP21
Copy link
Owner

RIP21 commented Apr 13, 2022

Thanks for contribution!

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.

2 participants