- {list.map((t) => (
-
-
setPostfixTemplateEnabled(t.id, v)}
- aria-label={tx`Enable .${t.key}`}
- />
- .{t.key}
-
- {t.description}
-
+ {settings.enabled && settings.expandWithTab && (
+
+ Type an expression followed by .key, e.g. user.name.nn or{" "}
+ items.for
+ , then press Tab.
+
+ )}
+
+
+
+ {POSTFIX_GROUPS.map((g) => (
+
+ ))}
- ))}
+
{
+ const next = listNavigate(event.key, { items: list, active: selectedIndex });
+ if (next === null) return;
+ event.preventDefault();
+ const template = list[next];
+ if (!template) return;
+ select(template.id);
+ event.currentTarget.querySelectorAll("button")[next]?.focus();
+ }}
+ >
+ {list.map((t) => {
+ const active = t.id === selected?.id;
+ return (
+
+ {
+ select(t.id);
+ setPostfixTemplateEnabled(t.id, v);
+ }}
+ aria-label={tx`Enable .${t.key}`}
+ />
+
+
+ );
+ })}
+
+
+ {selected &&
}
);
diff --git a/src/features/templates/settings/Settings.module.css b/src/features/templates/settings/Settings.module.css
index a1976483c..86504554c 100644
--- a/src/features/templates/settings/Settings.module.css
+++ b/src/features/templates/settings/Settings.module.css
@@ -173,11 +173,40 @@
gap: var(--space-1-5);
justify-content: flex-end;
}
+.postfixOptions,
+.postfixDependentOptions {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: var(--space-1);
+}
+.postfixDependentOptions {
+ padding-inline-start: calc(var(--space-4) + var(--space-2));
+}
+.postfixWorkspace {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
+ flex: 1;
+ min-height: 320px;
+ border: 1px solid var(--border-strong);
+ border-radius: var(--radius-small);
+ overflow: hidden;
+}
+.postfixBrowser {
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+ min-width: 0;
+ border-inline-end: 1px solid var(--border);
+}
+.postfixBrowser .tabs {
+ flex: none;
+ padding: var(--space-1);
+ border-bottom: 1px solid var(--border);
+}
.list {
display: flex;
flex-direction: column;
- border: 1px solid var(--border-strong);
- border-radius: var(--radius-small);
overflow: auto;
flex: 1;
min-height: 0;
@@ -185,13 +214,83 @@
.listRow {
display: flex;
align-items: center;
- gap: 10px;
+ gap: var(--space-2);
min-height: var(--h-row);
padding: 0 8px;
}
.listRow:hover {
background: var(--bg-hover);
}
+.listRow.itemSelected {
+ background: var(--bg-selected);
+}
+.listRow.itemSelected .itemDetail {
+ color: var(--fg);
+}
+.postfixChoice {
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+ flex: 1;
+ min-width: 0;
+ height: var(--h-row);
+ padding: 0;
+ border: 0;
+ background: none;
+ color: inherit;
+ font: inherit;
+ text-align: start;
+}
+.postfixChoice:focus-visible {
+ outline-offset: -2px;
+}
+.postfixPreview {
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-4);
+ min-width: 0;
+ overflow: auto;
+ padding: var(--space-3);
+}
+.postfixDescription {
+ display: flex;
+ align-items: baseline;
+ flex-wrap: wrap;
+ gap: var(--space-1) var(--space-2);
+ overflow-wrap: anywhere;
+ color: var(--fg-strong);
+}
+.postfixDescription code,
+.postfixPreview pre {
+ font-family: var(--font-mono);
+}
+.postfixPreview pre {
+ margin: var(--space-1) 0 0;
+ padding: var(--space-2);
+ border: 1px solid var(--border);
+ border-radius: var(--radius-small);
+ background: var(--bg-app);
+ color: var(--fg-emphasis);
+ font-size: var(--fs-code);
+ line-height: var(--lh-code);
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+ tab-size: 4;
+}
+@container settings-content (width < 600px) {
+ .postfixWorkspace {
+ grid-template-columns: minmax(0, 1fr);
+ flex: none;
+ min-height: 0;
+ }
+ .postfixBrowser {
+ border-inline-end: 0;
+ border-bottom: 1px solid var(--border);
+ }
+ .postfixBrowser .list {
+ max-height: clamp(128px, 24vh, 192px);
+ }
+}
.mono {
font-family: var(--font-mono);
color: var(--fg-emphasis);
diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json
index aa9f33dd4..cf09c4ad7 100644
--- a/src/platform/locales/text/en.json
+++ b/src/platform/locales/text/en.json
@@ -1680,6 +1680,8 @@
"New Project": "New Project",
"{path} already exists and is not empty": "{path} already exists and is not empty",
"Example": "Example",
+ "Template preview": "Template preview",
+ "Fallback expansion": "Fallback expansion",
"Shows how to use the plugin API; not maintained as a product.": "Shows how to use the plugin API; not maintained as a product.",
"{count} downloads": "{count} downloads",
"This plugin shows how to use the plugin API and is not maintained as a product. Build on it in your own repository.": "This plugin shows how to use the plugin API and is not maintained as a product. Build on it in your own repository.",
diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json
index 92f239cfe..77c49c763 100644
--- a/src/platform/locales/text/zh.json
+++ b/src/platform/locales/text/zh.json
@@ -2196,6 +2196,8 @@
"Postfix Completion": "后缀补全",
"Poetry Environment": "Poetry 环境",
"Postfix templates": "后缀模板",
+ "Template preview": "模板预览",
+ "Fallback expansion": "备用展开结果",
"Prefer": "首选",
"Prefer moving caret line to minimize editor scrolling": "优先移动光标所在行,以尽量减少编辑器滚动",
"Prefer scrolling editor canvas to keep caret line centered": "优先滚动编辑器画布,使光标所在行保持居中",