codemirror-lang-svelte 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/package.json +19 -21
package/README.md
CHANGED
|
@@ -10,18 +10,54 @@ This is a CodeMirror 6 extension that adds support for Svelte.
|
|
|
10
10
|
|
|
11
11
|
_As some parts are partially rewritten, the behaviour is slightly different from `@replit/codemirror-lang-svelte`. This version tends to be stricter towards grammar than the original one._
|
|
12
12
|
|
|
13
|
+
### API Reference
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
svelte(config: Config): LanguageSupport
|
|
17
|
+
```
|
|
18
|
+
**Config:**
|
|
19
|
+
- [`jsParser: LRParser`](https://lezer.codemirror.net/docs/ref/#lr.LRParser) \
|
|
20
|
+
Javascript parser used to parse nodes inside `<script>` tags and template javascript expressions. \
|
|
21
|
+
Default: `javascriptLanguage.parser` from [`@codemirror/lang-javascript`](https://github.com/codemirror/lang-javascript/tree/main) \
|
|
22
|
+
Useful for providing a parser with custom configs (e.g. overriding syntax highlighting)
|
|
23
|
+
|
|
24
|
+
- [`tsParser: LRParser`](https://lezer.codemirror.net/docs/ref/#lr.LRParser) \
|
|
25
|
+
Typescript parser used to parse nodes inside `<script lang="ts">` tags. \
|
|
26
|
+
Default: `typescriptLanguage.parser` from [`@codemirror/lang-javascript`](https://github.com/codemirror/lang-javascript/tree/main) \
|
|
27
|
+
Useful for providing a parser with custom configs (e.g. overriding syntax highlighting)
|
|
28
|
+
|
|
29
|
+
- [`cssParser: LRParser`](https://lezer.codemirror.net/docs/ref/#lr.LRParser) \
|
|
30
|
+
CSS parser used to parse nodes inside `<style>` tags. \
|
|
31
|
+
Default: `cssLanguage.parser` from [`@codemirror/lang-css`](https://github.com/codemirror/lang-css/tree/main) \
|
|
32
|
+
Useful for providing a parser with custom configs (e.g. overriding syntax highlighting)
|
|
33
|
+
|
|
13
34
|
### Usage
|
|
14
35
|
|
|
15
36
|
```typescript
|
|
16
37
|
import { EditorState } from '@codemirror/state';
|
|
17
38
|
import { EditorView } from '@codemirror/view';
|
|
18
|
-
import { svelte } from
|
|
39
|
+
import { svelte } from 'codemirror-lang-svelte';
|
|
19
40
|
import { basicSetup } from 'codemirror';
|
|
41
|
+
import { javascriptLanguage } from '@codemirror/lang-javascript';
|
|
42
|
+
import { styleTags, tags } from '@lezer/highlight';
|
|
20
43
|
|
|
21
44
|
new EditorView({
|
|
22
45
|
state: EditorState.create({
|
|
23
46
|
doc: `<script>let a = "hello world";</script> <div>{a}</div>`,
|
|
24
|
-
extensions: [
|
|
47
|
+
extensions: [
|
|
48
|
+
basicSetup,
|
|
49
|
+
svelte({
|
|
50
|
+
jsParser: javascriptLanguage.parser.configure({
|
|
51
|
+
props: [
|
|
52
|
+
styleTags({
|
|
53
|
+
'CallExpression/MemberExpression/PropertyName': tags.function(
|
|
54
|
+
tags.variableName
|
|
55
|
+
),
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
}),
|
|
59
|
+
})
|
|
60
|
+
],
|
|
25
61
|
}),
|
|
26
62
|
parent: document.querySelector('#editor'),
|
|
27
63
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codemirror-lang-svelte",
|
|
3
3
|
"description": "Svelte language support for CodeMirror6",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"author": "Kynson Szetau (https://kynsonszetau.com/)",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.cjs",
|
|
@@ -34,34 +34,32 @@
|
|
|
34
34
|
"@codemirror/view": "^6.0.0",
|
|
35
35
|
"@lezer/common": "^1.0.0",
|
|
36
36
|
"@lezer/highlight": "^1.0.0",
|
|
37
|
-
"@lezer/javascript": "^1.2.0",
|
|
38
37
|
"@lezer/lr": "^1.0.0"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@codemirror/autocomplete": "^6.
|
|
42
|
-
"@codemirror/lang-css": "^6.
|
|
43
|
-
"@codemirror/lang-html": "^6.
|
|
44
|
-
"@codemirror/lang-javascript": "^6.
|
|
45
|
-
"@codemirror/language": "^6.
|
|
46
|
-
"@codemirror/state": "^6.
|
|
47
|
-
"@codemirror/theme-one-dark": "^6.
|
|
48
|
-
"@codemirror/view": "^6.
|
|
49
|
-
"@kynsonszetau/lint": "^
|
|
50
|
-
"@lezer/common": "^1.
|
|
51
|
-
"@lezer/generator": "^1.
|
|
52
|
-
"@lezer/highlight": "^1.
|
|
53
|
-
"@lezer/
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"eslint": "^9.34.0",
|
|
40
|
+
"@codemirror/autocomplete": "^6.20.0",
|
|
41
|
+
"@codemirror/lang-css": "^6.3.1",
|
|
42
|
+
"@codemirror/lang-html": "^6.4.11",
|
|
43
|
+
"@codemirror/lang-javascript": "^6.2.4",
|
|
44
|
+
"@codemirror/language": "^6.12.1",
|
|
45
|
+
"@codemirror/state": "^6.5.3",
|
|
46
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
47
|
+
"@codemirror/view": "^6.39.8",
|
|
48
|
+
"@kynsonszetau/lint": "^2.0.0",
|
|
49
|
+
"@lezer/common": "^1.5.0",
|
|
50
|
+
"@lezer/generator": "^1.8.0",
|
|
51
|
+
"@lezer/highlight": "^1.2.3",
|
|
52
|
+
"@lezer/lr": "^1.4.5",
|
|
53
|
+
"@types/node": "^25.0.3",
|
|
54
|
+
"codemirror": "^6.0.2",
|
|
55
|
+
"eslint": "^9.39.2",
|
|
58
56
|
"unplugin-dts": "1.0.0-beta.6",
|
|
59
|
-
"vite": "^7.
|
|
57
|
+
"vite": "^7.3.0",
|
|
60
58
|
"vite-plugin-dts": "^4.5.4"
|
|
61
59
|
},
|
|
62
60
|
"repository": {
|
|
63
61
|
"type": "git",
|
|
64
|
-
"url": "https://github.com/Kynson/codemirror-lang-svelte.git"
|
|
62
|
+
"url": "git+https://github.com/Kynson/codemirror-lang-svelte.git"
|
|
65
63
|
},
|
|
66
64
|
"bugs": {
|
|
67
65
|
"url": "https://github.com/Kynson/codemirror-lang-svelte/issues"
|