From 41cff2af6c79969ad38115fd4641a0dc03a70024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hornych?= Date: Wed, 6 Dec 2023 22:45:54 +0100 Subject: [PATCH] feat(#70): codemirror status bar with selection info and spaces info --- src/components/base/CodemirrorFull.vue | 21 ++++++-- .../base/CodemirrorFullStatusBar.vue | 37 ++++++++++++++ .../base/CodemirrorFullStatusBarSelection.vue | 49 +++++++++++++++++++ src/model/lab.ts | 13 +++-- 4 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 src/components/base/CodemirrorFullStatusBar.vue create mode 100644 src/components/base/CodemirrorFullStatusBarSelection.vue diff --git a/src/components/base/CodemirrorFull.vue b/src/components/base/CodemirrorFull.vue index 18a66a80..e4ea7931 100644 --- a/src/components/base/CodemirrorFull.vue +++ b/src/components/base/CodemirrorFull.vue @@ -5,6 +5,8 @@ import { EditorState, Extension } from '@codemirror/state' import { keymap } from '@codemirror/view' import { basicSetup } from 'codemirror' import { dracula } from '@ddietr/codemirror-themes/dracula.js' +import { ref } from 'vue' +import CodemirrorFullStatusBar from '@/components/base/CodemirrorFullStatusBar.vue' const props = withDefaults( defineProps<{ @@ -12,11 +14,13 @@ const props = withDefaults( additionalExtensions?: Extension[] placeholder?: string readOnly?: boolean, - disabled?: boolean + disabled?: boolean, + statusBar?: boolean }>(), { readOnly: false, disabled: false, + statusBar: true, additionalExtensions: () => [] } ) @@ -43,18 +47,24 @@ const extensions: Extension[] = [ if (props.readOnly) { extensions.push(EditorState.readOnly.of(true)) } + +const state = ref() @@ -65,6 +75,11 @@ if (props.readOnly) { left: 0; right: 0; top: 0; - bottom: 0; + bottom: 2rem; +} + +.status-bar { + display: flex; + justify-content: right; } diff --git a/src/components/base/CodemirrorFullStatusBar.vue b/src/components/base/CodemirrorFullStatusBar.vue new file mode 100644 index 00000000..5024396a --- /dev/null +++ b/src/components/base/CodemirrorFullStatusBar.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/components/base/CodemirrorFullStatusBarSelection.vue b/src/components/base/CodemirrorFullStatusBarSelection.vue new file mode 100644 index 00000000..4e546fe5 --- /dev/null +++ b/src/components/base/CodemirrorFullStatusBarSelection.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/src/model/lab.ts b/src/model/lab.ts index e5813e1c..916516f1 100644 --- a/src/model/lab.ts +++ b/src/model/lab.ts @@ -12,11 +12,11 @@ export class EvitaDBConnection { readonly id: EvitaDBConnectionId readonly name: string readonly preconfigured: boolean - readonly labApiUrl: string - readonly restUrl: string - readonly gqlUrl: string + readonly labApiUrl?: string + readonly restUrl?: string + readonly gqlUrl?: string - constructor(id: EvitaDBConnectionId | undefined, name: string, preconfigured: boolean, labApiUrl: string, restUrl: string, gqlUrl: string) { + constructor(id: EvitaDBConnectionId | undefined, name: string, preconfigured: boolean, labApiUrl?: string, restUrl?: string, gqlUrl?: string) { this.id = id ? id : uuidv4() this.name = name this.preconfigured = preconfigured @@ -29,7 +29,10 @@ export class EvitaDBConnection { return new EvitaDBConnection(json.id, json.name, preconfigured, json.labApiUrl, json.restUrl, json.gqlUrl) } - private normalizeApiUrl(url: string): string { + private normalizeApiUrl(url: string | undefined): string | undefined { + if (url == undefined) { + return undefined + } return url.endsWith('/') ? url.substring(0, url.length - 1) : url } }