Now.js Framework Documentation
TextareaElementFactory
TextareaElementFactory
TextareaElementFactory Builds <textarea> fields with optional auto-resize and a character counter. Always renders a real <textarea>, never <input type="textarea">.
หน้านี้สร้างจากซอร์สโดยตรงเมื่อ 2026-08-21 คำอธิบายมาจาก JSDoc ในไฟล์
รันซ้ำได้ด้วยdocs_scaffoldเมื่อโค้ดเปลี่ยน อย่าแก้ด้วยมือถ้าตั้งใจให้ generate ต่อ
ที่มา
- ไฟล์:
Now/js/TextareaElementFactory.js(365 บรรทัด) - รูปแบบ: ES class
เมธอดสาธารณะ (9)
static adjustHeight(element, config)
Resize a textarea to fit its content, within minRows/maxRows. Scroll position is captured and restored around the resize, since temporarily collapsing the height can otherwise jump the page.
static cleanup(instance)
Tear a textarea down: cancel any pending resize and restore its original styles.
static create(def)
Build a textarea from a field definition. Forces tagName/type to textarea regardless of what the definition says, so this factory never accidentally renders an input.
static extractCustomConfig(element, def, dataset)
Read the textarea options a single element declares. Covers data-auto-resize, data-min-rows, data-max-rows and data-char-count; anything absent falls back to def.
static setupAutoResize(instance)
Switch a textarea to grow with its content instead of being resizable. The original resize and overflow-y styles are stashed on the element so cleanup can restore them later.
static setupCounter(instance)
Add the character-count display below the textarea.
static setupElement(instance)
Prepare a textarea, clamping its size settings to sane values. minRows is at least 1, maxRows is at least minRows, and debounceDelay is at least 0 — any bad value from config or a data attribute is corrected rather than propagated.
static setupEventListeners(instance)
Bind the input handler that drives auto-resize and the counter. Resizing is debounced so a fast typist does not trigger a layout pass on every keystroke.
static updateCounters(instance)
Refresh the character counter to match the current value.
Data attribute ที่ใช้
data-auto-resize · data-char-count · data-enable-tab-indent · data-enter-behavior · data-word-count
พึ่งพาคลาสอื่น
ElementManager · EventSystemManager · Utils