From a7040f725b3aef80e717673511556e170d989dd9 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 31 Jan 2017 13:44:39 -0800 Subject: Expand compose box to fit previewed text --- lib/serve.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/serve.js b/lib/serve.js index 51a7a5d..e4d5911 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -685,6 +685,10 @@ Serve.prototype.wrapChannel = function (channel) { }) } +function rows(str) { + return String(str).split(/[^\n]{70}|\n/).length +} + Serve.prototype.composer = function (opts, cb) { var self = this opts = opts || {} @@ -697,7 +701,7 @@ Serve.prototype.composer = function (opts, cb) { h('textarea', { id: opts.id, name: 'text', - rows: 4, + rows: Math.max(4, rows(data.text)), cols: 70, placeholder: opts.placeholder || 'public message', }, data.text || ''), -- cgit v1.2.3