File tree Expand file tree Collapse file tree 4 files changed +38
-29
lines changed Expand file tree Collapse file tree 4 files changed +38
-29
lines changed Original file line number Diff line number Diff line change 8
8
register: LanguageFn ;
9
9
}
10
10
11
+ export interface Slots {
12
+ default: {
13
+ /**
14
+ * The highlighted code.
15
+ */
16
+ highlighted: HighlightedCode ;
17
+ };
18
+ }
19
+
11
20
export interface Events {
12
- highlight: {
21
+ highlight: CustomEvent <{
22
+ /**
23
+ * The highlighted code.
24
+ */
13
25
highlighted? : HighlightedCode ;
14
- };
26
+ }> ;
15
27
}
16
28
</script >
17
29
35
47
langtag? : boolean ;
36
48
}
37
49
38
- interface $$Slots {
39
- default: {
40
- highlighted: HighlightedCode ;
41
- };
42
- }
50
+ interface $$Slots extends Slots {}
51
+
52
+ interface $$Events extends Events {}
43
53
44
54
export let language: Language = {
45
55
name: undefined ,
53
63
import hljs from " highlight.js/lib/core" ;
54
64
import { createEventDispatcher , afterUpdate } from " svelte" ;
55
65
56
- const dispatch = createEventDispatcher < Events > ();
66
+ const dispatch = createEventDispatcher ();
57
67
58
68
let highlighted: HighlightedCode = undefined ;
59
69
Original file line number Diff line number Diff line change 1
1
<script context =" module" lang =" ts" >
2
- import type { HighlightedCode , Language , Events } from " ./Highlight.svelte" ;
2
+ import type { HighlightedCode , Slots , Events } from " ./Highlight.svelte" ;
3
3
</script >
4
4
5
5
<script lang =" ts" >
9
9
*/
10
10
code? : any ;
11
11
12
- /**
13
- * Provide the language to highlight the code.
14
- * Import languages from `svelte-highlight/languages/*`.
15
- */
16
- language? : Language ;
17
-
18
12
/**
19
13
* Set to `true` for the language name to be
20
14
* displayed at the top right of the code block.
21
15
*/
22
16
langtag? : boolean ;
23
17
}
24
18
25
- interface $$Slots {
26
- default: {
27
- highlighted: HighlightedCode ;
28
- };
29
- }
19
+ interface $$Slots extends Slots {}
20
+
21
+ interface $$Events extends Events {}
30
22
31
23
export let code = undefined ;
32
24
35
27
import hljs from " highlight.js" ;
36
28
import { createEventDispatcher , afterUpdate } from " svelte" ;
37
29
38
- const dispatch = createEventDispatcher < Events > ();
30
+ const dispatch = createEventDispatcher ();
39
31
40
32
let highlighted: HighlightedCode = undefined ;
41
33
let language = undefined ;
Original file line number Diff line number Diff line change 1
1
<script context =" module" lang =" ts" >
2
- import type { HighlightedCode , Events } from " ./Highlight.svelte" ;
2
+ import type { Slots , Events } from " ./Highlight.svelte" ;
3
3
</script >
4
4
5
5
<script lang =" ts" >
16
16
langtag? : boolean ;
17
17
}
18
18
19
- interface $$Slots {
20
- default: {
21
- highlighted: HighlightedCode ;
22
- };
23
- }
19
+ interface $$Slots extends Slots {}
20
+
21
+ interface $$Events extends Events {}
24
22
25
23
export let code = undefined ;
26
24
32
30
import css from " highlight.js/lib/languages/css" ;
33
31
import { createEventDispatcher , afterUpdate } from " svelte" ;
34
32
35
- const dispatch = createEventDispatcher < Events > ();
33
+ const dispatch = createEventDispatcher ();
36
34
37
35
hljs .registerLanguage (" xml" , xml );
38
36
hljs .registerLanguage (" javascript" , javascript );
Original file line number Diff line number Diff line change 7
7
import " ../package/styles/3024.css" ;
8
8
</script >
9
9
10
- <Highlight code ="" language ={javascript || typescript } />
10
+ <Highlight
11
+ code =" "
12
+ language ={javascript || typescript }
13
+ on:highlight ={(e ) => {
14
+ console .log (e .detail );
15
+ }}
16
+ let:highlighted
17
+ >
18
+ {@html highlighted }
19
+ </Highlight >
11
20
12
21
<svelte:component this ={Highlight2 } />
13
22
You can’t perform that action at this time.
0 commit comments