-
Notifications
You must be signed in to change notification settings - Fork 25
Fix for onEnter and onTab #24
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
Comments
Thank you very much for this; it appears to solve so many problems! I will look at it and integrate it into the repo when I have time. |
You are very much welcome. Cheers, Kai |
Hi WebCoder, i just changed my solution to use the (slightly depreciated) execCommand() approach. Compared to the previously used setRangeText() apporach, the benefit is that the UNDO/REDO buffer remains accessible after TAB/Enter sequences. Also added detection for computed Line-Heigh so that you don't have to use any hard coded values. Note: The execCommand() simulates a 'oninput' change, so you don't have to call updateCode() manually inside the function. The edit->view update will be handled by the textarea 'oninput' event without any further adjustments.
Cheers, Kai |
I'm afraid that I cannot implement this code because it does not appear to fix the issues in Microsoft Edge v111.0 or Google Chrome v111.0, but it does work in Firefox. Please let me know if I am missing something. |
I have released this in version 1.2.4. |
Uh oh!
There was an error while loading. Please reload this page.
Hi WebCoder,
many thanks for your work. Your project inspired me very much and I finally created my own solution based on your original demo.
I've noticed that your onEnter and onTab functions causing annoying results when:
1.) Holding Enter till carrot floats out of the window (Chrome does not auto adjust scrollTop)
2.) Pressing Enter while scrollLeft is active and visible area is deep inside scrollLeft (it does not set scrollLeft to 0)
3.) Tabbing while selecting entire lines adds Tabs to lines outside of selectionStart/End.
4.) Tabbing on STRG+A does not adjust selectionStart accordingly.
5.) Shift-Tab on a given line does not remove leading tabs when carrot sits at the beginning of the line.
Feel free to integrate the Tab/Enter code I wrote for my solution. It also includes feature to convert leading space to tabs and remove intents from otherwise empty lines:
Note: The convert of leading space to tabs is hardcoded for Tab-Size:4 and the Enter scroll adjustments are based on a line-height of hardcoded 15px.
Update: Slightly modified the provided code to include adjustment of selectionStart for empty lines on multi line selections. That was somehow left over. But I guess that there is no such perfect TAB sequence, since mileage may vary... .
Thanks and Cheers, Kai
The text was updated successfully, but these errors were encountered: