From 11c714a9571f83e19678ee9d0d4d4d2471976ea6 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Thu, 9 Mar 2023 11:47:25 +0530 Subject: [PATCH] feat: add autocomplete for linklabels - update editor styling --- package.json | 1 + src/pages/TemplateBuilder/TemplateBuilder.vue | 17 ++- .../TemplateBuilder/TemplateBuilderHint.vue | 6 +- src/pages/TemplateBuilder/TemplateEditor.vue | 143 +++++++++++++++++- yarn.lock | 2 +- 5 files changed, 150 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 42069858..0c05a90e 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "test": "scripts/test.sh" }, "dependencies": { + "@codemirror/autocomplete": "^6.4.2", "@codemirror/lang-vue": "^0.1.1", "@popperjs/core": "^2.10.2", "better-sqlite3": "^7.5.3", diff --git a/src/pages/TemplateBuilder/TemplateBuilder.vue b/src/pages/TemplateBuilder/TemplateBuilder.vue index 62e4e9e2..407f3663 100644 --- a/src/pages/TemplateBuilder/TemplateBuilder.vue +++ b/src/pages/TemplateBuilder/TemplateBuilder.vue @@ -178,7 +178,7 @@ >
-
+

{{ t`Value Keys` }}

@@ -186,7 +186,7 @@ class="overflow-auto custom-scroll p-4" style="max-height: 80vh; width: 25vw" > - +
@@ -196,11 +196,12 @@ {{ t`Template` }}
@@ -253,14 +254,14 @@ export default defineComponent({ return { doc: null, showEditor: false, - hint: null, + hints: undefined, values: null, templateCollapsed: false, helpersCollapsed: true, displayDoc: null, scale: 0.65, } as { - hint: null | Record; + hints?: Record; values: null | PrintValues; doc: PrintTemplate | null; showEditor: boolean; @@ -344,7 +345,7 @@ export default defineComponent({ }, async setDisplayDoc(value: string) { if (!value) { - this.hint = null; + delete this.hints; this.values = null; this.displayDoc = null; return; @@ -356,7 +357,7 @@ export default defineComponent({ } const displayDoc = await getDocFromNameIfExistsElseNew(schemaName, value); - this.hint = getPrintTemplatePropHints(displayDoc); + this.hints = getPrintTemplatePropHints(displayDoc); this.values = await getPrintTemplatePropValues(displayDoc); this.displayDoc = displayDoc; }, diff --git a/src/pages/TemplateBuilder/TemplateBuilderHint.vue b/src/pages/TemplateBuilder/TemplateBuilderHint.vue index 4f2cf7bd..a2dab9c5 100644 --- a/src/pages/TemplateBuilder/TemplateBuilderHint.vue +++ b/src/pages/TemplateBuilder/TemplateBuilderHint.vue @@ -55,7 +55,7 @@
@@ -74,7 +74,7 @@ export default defineComponent({ name: 'TemplateBuilderHint', props: { prefix: { type: String, default: '' }, - hint: { type: Object, required: true }, + hints: { type: Object, required: true }, level: { type: Number, default: 0 }, }, data() { @@ -83,7 +83,7 @@ export default defineComponent({ }; }, mounted() { - this.rows = Object.entries(this.hint) + this.rows = Object.entries(this.hints) .map(([key, value]) => ({ key, value, diff --git a/src/pages/TemplateBuilder/TemplateEditor.vue b/src/pages/TemplateBuilder/TemplateEditor.vue index 2b84ca77..fd989e2a 100644 --- a/src/pages/TemplateBuilder/TemplateEditor.vue +++ b/src/pages/TemplateBuilder/TemplateEditor.vue @@ -2,8 +2,13 @@
diff --git a/yarn.lock b/yarn.lock index d9b6cec5..a24f1143 100644 --- a/yarn.lock +++ b/yarn.lock @@ -962,7 +962,7 @@ "@babel/helper-validator-identifier" "^7.15.7" to-fast-properties "^2.0.0" -"@codemirror/autocomplete@^6.0.0": +"@codemirror/autocomplete@^6.0.0", "@codemirror/autocomplete@^6.4.2": version "6.4.2" resolved "https://registry.yarnpkg.com/@codemirror/autocomplete/-/autocomplete-6.4.2.tgz#938b25223bd21f97b2a6d85474643355f98b505b" integrity sha512-8WE2xp+D0MpWEv5lZ6zPW1/tf4AGb358T5GWYiKEuCP8MvFfT3tH2mIF9Y2yr2e3KbHuSvsVhosiEyqCpiJhZQ==