Turn position/margin/sizing/direction env fields into dropdown selects.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -215,6 +215,27 @@
|
||||
});
|
||||
const cur = (field.current || field.default || "false").toLowerCase();
|
||||
input.value = cur === "true" || cur === "1" ? "true" : "false";
|
||||
} else if (field.type === "select" && Array.isArray(field.options) && field.options.length) {
|
||||
input = document.createElement("select");
|
||||
input.id = "env-f-" + field.key;
|
||||
const cur = String(field.current || field.default || "");
|
||||
const seen = new Set();
|
||||
field.options.forEach((opt) => {
|
||||
const v = String(opt.value != null ? opt.value : "");
|
||||
if (seen.has(v)) return;
|
||||
seen.add(v);
|
||||
const o = document.createElement("option");
|
||||
o.value = v;
|
||||
o.textContent = opt.label || v;
|
||||
input.appendChild(o);
|
||||
});
|
||||
if (cur && !seen.has(cur)) {
|
||||
const o = document.createElement("option");
|
||||
o.value = cur;
|
||||
o.textContent = cur;
|
||||
input.insertBefore(o, input.firstChild);
|
||||
}
|
||||
input.value = cur || (field.options[0] && field.options[0].value) || "";
|
||||
} else {
|
||||
input = document.createElement("input");
|
||||
input.id = "env-f-" + field.key;
|
||||
|
||||
Reference in New Issue
Block a user