Files
windmill/frontend/src/lib/components/HighlightCode.svelte
T
Faton RamadaniandRuben Fiszel 7e9ee39aa6 feat(frontend): Global CSS editor (#2178)
* feat(frontend): add global css

* feat(frontend): working styling

* feat(frontend): Add default classes

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* feat(frontend): Add global css v0

* feat(frontend): Add global css v0

* add css workers

* fix(frontend): Fix overflow issue

* wip

* feat(frontend): check for EE before injecting global css

* wip

* wip

* wip

* fix(frontend): fix typing issues

* fix(frontend): fix typing issues

* fix(frontend): fix global css

* fix(frontend): add missing mapping

* fix(frontend): Fix how styles are loaded

* fix(frontend): fix preview

* feat(frontend): fix everything

* feat(frontend): fix class autocomplete

* feat(frontend): remove console.log

* feat(frontend): update tooltup

* feat(frontend): eval

* feat(frontend): eval

* feat(frontend): fix build

* feat(frontend): fix initial binding

* feat(frontend): wip

* wip

* feat(frontend): Finish theme v0

* feat(frontend): Fix resource page

* feat(frontend): fix build

* feat(frontend): theme UI

* feat(frontend): theme UI

* feat(frontend): theme UI

* feat(frontend): fix EE

* feat(frontend): add missing warning

* feat(frontend): fix preview

* feat(frontend): fix global css by component initialisation

* feat(frontend): remove unused libraries

* feat(frontend): fix EE check

* feat(frontend): fix EE check

* feat(frontend): fix preview

* feat(frontend): Fix migration

* feat(frontend): Fix issues

* feat(frontend): add missing disabled in migration modal

* feat(frontend): Fix preview

* feat(frontend): Fix preview

* all

* all

* all

* sqlx

---------

Co-authored-by: Ruben Fiszel <ruben@rubenfiszel.com>
2023-09-15 22:55:47 +02:00

67 lines
1.7 KiB
Svelte

<script lang="ts">
import Highlight, { LineNumbers } from 'svelte-highlight'
import python from 'svelte-highlight/languages/python'
import typescript from 'svelte-highlight/languages/typescript'
import go from 'svelte-highlight/languages/go'
import shell from 'svelte-highlight/languages/shell'
import graphql from 'svelte-highlight/languages/graphql'
import javascript from 'svelte-highlight/languages/javascript'
import sql from 'svelte-highlight/languages/sql'
import powershell from 'svelte-highlight/languages/powershell'
import type { Script } from '$lib/gen'
export let code: string = ''
export let language: Script.language | 'frontend' | undefined
export let lines = false
function getLang(lang: Script.language | 'frontend' | undefined) {
switch (lang) {
case 'python3':
return python
case 'deno':
return typescript
case 'nativets':
return typescript
case 'bun':
return typescript
case 'go':
return go
case 'bash':
return shell
case 'frontend':
return javascript
case 'graphql':
return graphql
case 'mysql':
return sql
case 'postgresql':
return sql
case 'snowflake':
return sql
case 'bigquery':
return sql
case 'powershell':
return powershell
default:
return typescript
}
}
$: lang = getLang(language)
</script>
{#if code?.length < 5000}
{#if !lines}
<Highlight class="nowrap {$$props.class}" language={lang} {code} />
{:else}
<Highlight class="nowrap {$$props.class}" language={lang} {code} let:highlighted>
<LineNumbers {highlighted} />
</Highlight>
{/if}
{:else}
<pre class="overflow-auto max-h-screen {$$props.class}"
><code class="language-{language}">{code}</code></pre
>
{/if}