Skip to content

Commit

Permalink
feat: highlithg sql in notes, history and console
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Dec 22, 2023
1 parent 08e5a13 commit bfa3924
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 10 deletions.
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
"source-map-support": "~0.5.20",
"spectre.css": "~0.5.9",
"sql-formatter": "~13.0.0",
"sql-highlight": "~4.4.0",
"v-mask": "~2.3.0",
"vue": "~3.3.4",
"vue-i18n": "~9.2.2",
Expand Down
16 changes: 14 additions & 2 deletions src/renderer/components/ModalHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<code
class="cut-text"
:title="query.sql"
v-html="highlightWord(query.sql)"
v-html="highlight(highlightWord(query.sql), {html: true})"
/>
</div>
<div class="tile-bottom-content">
Expand Down Expand Up @@ -126,7 +126,19 @@

<script setup lang="ts">
import { ConnectionParams } from 'common/interfaces/antares';
import { Component, computed, ComputedRef, onBeforeUnmount, onMounted, onUpdated, Prop, Ref, ref, watch } from 'vue';
import { highlight } from 'sql-highlight';
import {
Component,
computed,
ComputedRef,
onBeforeUnmount,
onMounted,
onUpdated,
Prop,
Ref,
ref,
watch
} from 'vue';
import { useI18n } from 'vue-i18n';
import BaseIcon from '@/components/BaseIcon.vue';
Expand Down
8 changes: 6 additions & 2 deletions src/renderer/components/ModalNoteEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
</div>
</div>
<div class="form-group">
<label class="form-label">{{ t('general.content') }}</label>
<label class="form-label">{{ t('general.content') }} <small
v-if="localNote.type !== 'query'"
style="line-height: 1;"
class="text-gray"
>({{ t('application.markdownSupported') }})</small></label>
<BaseTextEditor
v-model="localNote.note"
:mode="editorMode"
Expand Down Expand Up @@ -110,7 +114,7 @@ watch(() => localNote.value.type, () => {
});
onBeforeMount(() => {
localNote.value = props.note;
localNote.value = JSON.parse(JSON.stringify(props.note));
});
</script>
6 changes: 5 additions & 1 deletion src/renderer/components/ModalNoteNew.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
</div>
</div>
<div class="form-group">
<label class="form-label">{{ t('general.content') }}</label>
<label class="form-label">{{ t('general.content') }} <small
v-if="newNote.type !== 'query'"
style="line-height: 1;"
class="text-gray"
>({{ t('application.markdownSupported') }})</small></label>
<BaseTextEditor
v-model="newNote.note"
:mode="editorMode"
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/components/ScratchpadNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<code
v-if="note.type === 'query'"
ref="noteParagraph"
class="tile-paragraph"
v-html="highlightWord(note.note)"
class="tile-paragraph sql"
v-html="highlight(highlightWord(note.note), {html: true})"
/>
<div
v-else
Expand Down Expand Up @@ -104,6 +104,7 @@
<script setup lang="ts">
import { useElementBounding } from '@vueuse/core';
import { marked } from 'marked';
import { highlight } from 'sql-highlight';
import { computed, PropType, Ref, ref } from 'vue';
import { useI18n } from 'vue-i18n';
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/WorkspaceQueryConsole.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
tabindex="0"
@contextmenu.prevent="contextMenu($event, wLog)"
>
<span class="type-datetime">{{ moment(wLog.date).format('HH:mm:ss') }}</span>: <code class="query-console-log-sql">{{ wLog.sql }}</code>
<span class="type-datetime">{{ moment(wLog.date).format('HH:mm:ss') }}</span>: <code class="query-console-log-sql" v-html="highlight(wLog.sql, {html: true})" />
</div>
</div>
</div>
Expand All @@ -47,6 +47,7 @@
<script setup lang="ts">
import * as moment from 'moment';
import { storeToRefs } from 'pinia';
import { highlight } from 'sql-highlight';
import { computed, nextTick, onMounted, Ref, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
Expand Down
32 changes: 30 additions & 2 deletions src/renderer/scss/main.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* stylelint-disable selector-class-pattern */
/* stylelint-disable */
@import "~spectre.css/src/variables";
@import "variables";
@import "transitions";
Expand Down Expand Up @@ -109,7 +109,6 @@ option:checked {

> div {
padding: 0.1rem 0.2rem;
/* stylelint-disable-next-line value-no-vendor-prefix */
min-width: -webkit-fill-available;
}
}
Expand Down Expand Up @@ -429,3 +428,32 @@ option:checked {
}
}
}

/* sql-highlight */
code.sql {
font-family: monospace;
}

.sql-hl-keyword {
color: $primary-color;
}

.sql-hl-function {
color: darkorchid;
}

.sql-hl-number {
color: $number-color;
}

.sql-hl-string {
color: $string-color;
}

.sql-hl-special {
color: goldenrod;
}

.sql-hl-bracket {
color: darkorchid;
}

0 comments on commit bfa3924

Please sign in to comment.