mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-11 00:06:06 +00:00
* Remove $$props.field usage * Rename slots to ensure no hyphen * _props * _trigger * OnSelectedIteration type correct capitalization * rename _content * Remove afterUpdate * Migrate everything to svelte 5 * array bind * Fix popover * type never * nit fixes * Fixed many trivial errors * onClick * Fix errors * use let: * nit typing * fix: wrap state_referenced_locally vars with untrack() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add untrack import * Fix all syntax errors due to untrack migration * Fix undefined errors * Fix more undefined errors * untrack(() => initialOpen) * svelte-ignore * Fix state_descriptors_fixed error in Chart.svelte Use $state.snapshot() to pass plain copies of data/options to Chart.js instead of $state proxies. Chart.js's listenArrayEvents tries to define property descriptors on data arrays, which Svelte 5 proxies reject. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * nit typing * Merge issue * Fix "path is not set" error in resource picker / editor * Fix InputTransformForm error when rerunning some flows * fix npm run check --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
45 lines
1.2 KiB
Svelte
45 lines
1.2 KiB
Svelte
<script lang="ts">
|
|
import { untrack } from 'svelte'
|
|
import { AnsiUp } from 'ansi_up'
|
|
|
|
interface Props {
|
|
content: string
|
|
highlighted: any[]
|
|
onClick?: () => void
|
|
}
|
|
|
|
let { content, highlighted, onClick }: Props = $props()
|
|
|
|
const ansi_up = new AnsiUp()
|
|
ansi_up.use_classes = true
|
|
|
|
function highlightSnippet(snippet: string) {
|
|
const opener = '!-!-!_H_START_WMILL_!-!-!'
|
|
const closer = '!-!-!_H_ENDER_WMILL_!-!-!'
|
|
|
|
let offset = 0
|
|
let ret = snippet
|
|
for (const range of highlighted) {
|
|
ret = ret.slice(0, range.start + offset) + opener + ret.slice(range.start + offset)
|
|
offset += opener.length
|
|
ret = ret.slice(0, range.end + offset) + closer + ret.slice(range.end + offset)
|
|
offset += closer.length
|
|
}
|
|
|
|
let html = ansi_up.ansi_to_html(ret)
|
|
let html2 = html
|
|
.replaceAll(opener, '<span class="bg-amber-400 text-black">')
|
|
.replaceAll(closer, '</span>')
|
|
return html2
|
|
}
|
|
|
|
let html = highlightSnippet(untrack(() => content))
|
|
</script>
|
|
|
|
<button onclick={onClick} class="font-light !m-0 !p-0">
|
|
<pre
|
|
class="bg-surface-secondary hover:bg-surface px-2 py-1 text-secondary text-xs w-[100%] whitespace-pre border min-w-full text-start">
|
|
{@html html}
|
|
</pre>
|
|
</button>
|