Tuesday | 05 NOV 2024
[ previous ]
[ next ]

Textarea Fun

Title:
Date: 2022-05-23
Tags:  

I didn't want to pull in a big dependency like codemirror or ace editor to get fancy textareas. All I really wanted was a textarea that could do line numbers and have rows alternating between gray and white.

I'm happy to say that it is quite doable with some javascript and css styling!

https://medium.com/weekly-webtips/enable-line-numbering-to-any-html-textarea-35e15ea320e2

This link was the big one that showed me it was possible to do the line numbers. I basically stole the logic of it and re-wrote it in svelte with reactive variables. This went pretty well.

https://stackoverflow.com/questions/7713873/javascript-html-to-alternate-row-colors-for-input-type-textarea

I used this link to do the colors and this worked with some fudging. Unfortunately the background-attachment property doesn't seem to work in firefox but does in chrome. I can live with that. I use firefox as my daily driver but I don't think its worth fixing for now.

I'm really happy that I could get so much out of the textarea. I have played around with textareas before and used codemirror and ace editor elsewhere but for something dead simple this is pretty good.