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

feature request: highlight characters in #input text box #3

Open
NovemLinguae opened this issue Nov 27, 2021 · 7 comments
Open

feature request: highlight characters in #input text box #3

NovemLinguae opened this issue Nov 27, 2021 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@NovemLinguae
Copy link

NovemLinguae commented Nov 27, 2021

Useful for spotting unescaped characters, spotting unclosed parentheses, etc. In lua's case, it might help the user identify differences between regular regex and lua regex.

Screenshot from a website that does this (https://regex101.com):

image

Later, could add a hover tooltip giving more info for each color.

image

@GitSparTV
Copy link
Owner

Hi, I want this too but I don't know JS enough to implement this is adequate way

@GitSparTV GitSparTV added the help wanted Extra attention is needed label Nov 27, 2021
@NovemLinguae
Copy link
Author

NovemLinguae commented Nov 27, 2021

One way to do it would be to use the HTML property contenteditable="true" and a bunch of <span> tags. Then use JavaScript to detect changes to a <textarea contenteditable="true"> and update the span tags as they type.

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable

I did this once for a project and I found it to be difficult. contenteditable has a lot of quirks.

You could mostly avoid JavaScript and also avoid contenteditable if you created a second text box below the first one, that was read only. The server could then generate <textarea disabled><span class="foo">ABC</span><span class="bar">DEF</span></textarea>. Then color the classes in CSS. JavaScript would only be needed for mouse hover tooltips.

@GitSparTV
Copy link
Owner

I will see what I can do

@xguhx
Copy link

xguhx commented Nov 30, 2021

Hello @GitSparTV, can I try to help you implementing this feature?

@GitSparTV
Copy link
Owner

@GMOTGIT Contributions are welcome.

@GitSparTV
Copy link
Owner

I got some resource help from discord for developers

image

image

@xguhx
Copy link

xguhx commented Nov 30, 2021

@GitSparTV Thank you, I will take a look at Slate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants