From 9a3964842150f17a63a5c944d3d9619ed6a50fda Mon Sep 17 00:00:00 2001 From: Wild Karl-Heinz Date: Mon, 28 Sep 2026 02:12:29 +0200 Subject: [PATCH] Searchable command reference in the macro and function editors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both editors get a side panel listing everything that can go into the code: search (incl. German synonyms), category chips, expandable entries with description and a complete example, and "Einfügen" to put a snippet or the example at the caret. The list adapts to the editor -- macros see write actions, GET/POST/JSONGET and the document's sheets/tables; "Mit Schleife" functions see FOR/IF/RETURN; single formulas only operators and functions; function editors also list their own parameters. The catalog lives in src/data/codeReference.ts (built-in functions derived from BUILTIN_SIGNATURES). Tests check that every write action is documented, that function editors never offer write/network commands, and that every example parses in each context it is shown in. BaseModal gains a `wide` prop for the two-column edit layout. Co-Authored-By: Claude Opus 5.5 --- src/components/BaseModal.vue | 7 +- src/components/CodeReference.vue | 328 +++++++++++++++ src/components/CustomFunctionsModal.vue | 188 +++++---- src/components/MacrosModal.vue | 115 ++++-- src/data/__tests__/codeReference.spec.ts | 54 +++ src/data/codeReference.ts | 488 +++++++++++++++++++++++ 6 files changed, 1075 insertions(+), 105 deletions(-) create mode 100644 src/components/CodeReference.vue create mode 100644 src/data/__tests__/codeReference.spec.ts create mode 100644 src/data/codeReference.ts diff --git a/src/components/BaseModal.vue b/src/components/BaseModal.vue index 91d1d14..4e54e99 100644 --- a/src/components/BaseModal.vue +++ b/src/components/BaseModal.vue @@ -1,7 +1,7 @@ + + + + diff --git a/src/components/CustomFunctionsModal.vue b/src/components/CustomFunctionsModal.vue index c0ace01..a09944c 100644 --- a/src/components/CustomFunctionsModal.vue +++ b/src/components/CustomFunctionsModal.vue @@ -6,9 +6,10 @@ * and a form shared by both "new" and "edit". See the plan's "Bedienung" * section for the exact mockups this follows. */ -import { reactive, ref, watch } from 'vue'; +import { nextTick, reactive, ref, watch } from 'vue'; import { useDocument } from '../store/document'; import BaseModal from './BaseModal.vue'; +import CodeReference from './CodeReference.vue'; const props = defineProps<{ open: boolean }>(); const emit = defineEmits<{ (e: 'close'): void }>(); @@ -87,6 +88,20 @@ function removeFunction(id: string, name: string) { } } +const bodyInput = ref(null); + +/** Put a reference snippet at the caret (replacing any selection). */ +async function insertSnippet(text: string) { + const el = bodyInput.value; + const start = el?.selectionStart ?? form.body.length; + const end = el?.selectionEnd ?? form.body.length; + form.body = form.body.slice(0, start) + text + form.body.slice(end); + await nextTick(); + if (!el) return; + el.focus(); + el.setSelectionRange(start + text.length, start + text.length); +} + function close() { emit('close'); } @@ -95,6 +110,7 @@ function close() { -