svhighlight icon indicating copy to clipboard operation
svhighlight copied to clipboard

Reactivity not working

Open SylvanFranklin opened this issue 9 months ago • 5 comments
trafficstars

Maybe I'm misreading the docs, but when passing in state that changes, the code blocks do not reflect the change. I'm using svelte five runes.

SylvanFranklin avatar Jan 30 '25 13:01 SylvanFranklin

Hi, I actually haven't updated this library in quite a while and I'm not yet sure if I will. There are now some much better solutions than highlight.js, so you might consider trying out shiki instead. It also shouldn't be too difficult to set up and style. Skeleton for example has a guide on it: https://next.skeleton.dev/docs/integrations/code-block/svelte

bennymi avatar Jan 30 '25 16:01 bennymi

@SylvanFranklin I had a similar problem, namely with the code prop. The main value for me in using svhighlight is that focus, blurring etc. was already done very well here. I understand I can do the same with shiki, but that's not an effort I wanted to make.

So I came up with a rudimentary implementation of reactivity under Svelte 5 (with my quite limited knowledge of Svelte). It probably has more changes than necessary, because there was a lot of trial-and-error involved. But in the end it works for me, so I'm sharing it here in case someone wants something similar.

https://github.com/katafrakt/svhighlight/tree/code-reactivity

katafrakt avatar Feb 15 '25 12:02 katafrakt

Thanks fam, I'll definitely check this out because you're right this repo did a lot right.

SylvanFranklin avatar Feb 15 '25 14:02 SylvanFranklin

@bennymi any plans to add maintainers or support svelte 5? This seems like a really nice library.

niemyjski avatar Apr 02 '25 02:04 niemyjski

@niemyjski Since there seems to be some interest in it, I'll try updating it to Svelte 5, but it might take some time since I'm busy with work and some other projects. It would also be using shiki instead of highlightjs, so the API might change a bit.

bennymi avatar Apr 06 '25 10:04 bennymi