Turn position/margin/sizing/direction env fields into dropdown selects.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 19:41:47 +08:00
parent 53e55aa4b4
commit aabbbef0a9
5 changed files with 150 additions and 10 deletions
@@ -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;