Experiments in <textarea> Automation
These are a collection of various experiments written in the development of my own "paste-bin service", with efforts to improve the interactive behaviors of the basic <textarea> to potential suitability for developers wanting to quickly share short, but formatted, code snippets.
Without ripping their hair out because they can't get rid of global extraneous indentation.
For any given technique with multiple proivded approaches or examples, each will be given with its own set of pros and cons clearly listed. Ultimately reasons why you might choose one over the other. Syntax highlighting, regular expression-based search and replace, or other more advanced "programmers' editor" features are not planned for inclusion. Only the basic necessities.
Content-Aware Sizing
- Line-Based Automatic Sizing (With Optional Constraints)
- The most basic technique, and most logically precice, by dynamically adjusting the
rows attribute of the element to precicely define height in terms of lines of text. Unable to handle soft–wrappd text.
- "Scrollable Region" Automatic Sizing (With Optional Constraints & Animation)
-
Utilizing the metrics for the content of the scrollable region, match the height of the scrollable region to the possible scrollable area.
Where the above techniqe can not handle soft–wrapped lines, this can, however definitions by pixel height are less natral.
Tab Character Input & Indentation
- Permitting Entry of Literal Tabs
- It can be desireable to permit entry of literal tab characters into text entry boxes, though this breaks tab-based accessible navigation of the page elements.
- Indentation-Matching on Enter (With Occasional Variation)
- When writing code, it's fairly expected to match any existing indentation on the last line on the newly created one.
Miscellaneous Behaviors
- Pure CSS Approaches to Image Placeholders
- Under casual searches, there are many implementations of this desired design pattern, often for the wrong reasons, or not actually implementing what is written on the label.