editor: better multiline input (x-scroll, height based on number of newline char)

This commit is contained in:
jean-emmanuel 2017-03-14 19:56:50 +01:00
parent 1c15e3a3a8
commit 5c50553181
2 changed files with 4 additions and 5 deletions

View file

@ -74,9 +74,7 @@ var editObject = function(container, data, refresh){
input = $(`<textarea data-type="${type}" title="${i}" rows="${value.split('\n').length}">${value}</textarea>`)
input.on('input focus', function(){
if (this.scrollHeight==0) return
this.style.height = 'auto'
this.style.height = this.scrollHeight + 'px'
this.setAttribute('rows',$(this).val().split('\n').length)
})
input.on('keydown', (e)=>{
if (e.keyCode == 13 && !e.shiftKey) {