mirror of
https://github.com/simonw/datasette.git
synced 2026-09-27 20:34:08 +02:00
textarea column type
Shows as multiline edit in edit/insert dialog
This commit is contained in:
parent
2b61c916d0
commit
5490c7b794
6 changed files with 29 additions and 8 deletions
|
|
@ -792,12 +792,15 @@ function valueToEditText(value) {
|
|||
return String(value);
|
||||
}
|
||||
|
||||
function shouldUseTextarea(value) {
|
||||
function shouldUseTextarea(value, columnType) {
|
||||
if (columnType && columnType.type === "textarea") {
|
||||
return true;
|
||||
}
|
||||
if (value && typeof value === "object") {
|
||||
return true;
|
||||
}
|
||||
var text = valueToEditText(value);
|
||||
return text.length > 80 || text.indexOf("\n") !== -1;
|
||||
return text.length > 80 || /[\r\n]/.test(text);
|
||||
}
|
||||
|
||||
function rowEditValueType(value) {
|
||||
|
|
@ -835,7 +838,7 @@ function createRowEditField(column, value, isPk, columnType, index, options) {
|
|||
var controlWrap = document.createElement("div");
|
||||
controlWrap.className = "row-edit-control-wrap";
|
||||
|
||||
var control = shouldUseTextarea(value)
|
||||
var control = shouldUseTextarea(value, columnType)
|
||||
? document.createElement("textarea")
|
||||
: document.createElement("input");
|
||||
control.className = "row-edit-input";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue