diff --git a/lxl-web/src/lib/components/Search.svelte b/lxl-web/src/lib/components/Search.svelte index fdcd82546..376cbb595 100644 --- a/lxl-web/src/lib/components/Search.svelte +++ b/lxl-web/src/lib/components/Search.svelte @@ -7,10 +7,14 @@ import getSortedSearchParams from '$lib/utils/getSortedSearchParams'; import BiSearch from '~icons/bi/search'; import { lxlQueryLanguage } from 'codemirror-lang-lxlquery'; + import { highlightExtension } from '$lib/utils/LxlQueryHighlight'; + import '$lib/styles/lxlquery.css'; export let placeholder: string; export let autofocus: boolean = false; + const supersearchExtensions = [highlightExtension]; + $: showAdvanced = $page.url.searchParams.get('_x') === 'advanced'; let q = $page.params.fnurgel ? '' //don't reflect related search on resource pages @@ -49,6 +53,7 @@ name="_q" bind:value={q} language={lxlQueryLanguage} + extensions={supersearchExtensions} placeholder={$page.data.t('search.search')} /> {:else} diff --git a/lxl-web/src/lib/styles/lxlquery.css b/lxl-web/src/lib/styles/lxlquery.css new file mode 100644 index 000000000..18bc06a79 --- /dev/null +++ b/lxl-web/src/lib/styles/lxlquery.css @@ -0,0 +1,28 @@ +.lxlq.qualifier { + color:lightgreen; +} + +.lxlq.qualifierkey { + color:green; +} + +.lxlq.qualifiervalue { + color:green; +} + +.lxlq.equaloperator, +.lxlq.compareoperator { + color:darkolivegreen; +} + +.lxlq.booleanoperator { + color: #935493; +} + +.lxlq.booleanquery { + color: purple; +} + +.lxlq.wildcard { + color: orange; +} \ No newline at end of file diff --git a/lxl-web/src/nprogress.css b/lxl-web/src/lib/styles/nprogress.css similarity index 100% rename from lxl-web/src/nprogress.css rename to lxl-web/src/lib/styles/nprogress.css diff --git a/lxl-web/src/lib/utils/LxlQueryHighlight.ts b/lxl-web/src/lib/utils/LxlQueryHighlight.ts new file mode 100644 index 000000000..b9cd93156 --- /dev/null +++ b/lxl-web/src/lib/utils/LxlQueryHighlight.ts @@ -0,0 +1,18 @@ +import { syntaxHighlighting } from '@codemirror/language'; +import { customTags as t } from 'codemirror-lang-lxlquery'; +import { tagHighlighter } from '@lezer/highlight'; + +const highlighter = tagHighlighter([ + { tag: t.Qualifier, class: 'qualifier' }, + { tag: t.QualifierKey, class: 'qualifierkey' }, + { tag: t.QualifierValue, class: 'qualifiervalue' }, + { tag: t.EqualOperator, class: 'equaloperator' }, + { tag: t.CompareOperator, class: 'compareoperator' }, + { tag: t.BooleanOperator, class: 'booleanoperator' }, + { tag: t.BooleanQuery, class: 'booleanquery' }, + { tag: t.Wildcard, class: 'wildcard' } +], { + all: 'lxlq', +}) + +export const highlightExtension = syntaxHighlighting(highlighter); \ No newline at end of file diff --git a/lxl-web/src/routes/+layout.svelte b/lxl-web/src/routes/+layout.svelte index 44bc43542..428145a69 100644 --- a/lxl-web/src/routes/+layout.svelte +++ b/lxl-web/src/routes/+layout.svelte @@ -1,7 +1,7 @@ - +