Skip to content

Commit 8ffcb52

Browse files
authored
feat: adding highlight support for graphql (#173)
1 parent fd2b221 commit 8ffcb52

File tree

10 files changed

+197
-2
lines changed

10 files changed

+197
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const ele = syntaxHighlighter('console.log("Hello, world!");', 'js', { ...opts,
7575
| Docker | `dockerfile` |
7676
| Erlang | `erl`, `erlang` |
7777
| Go | `go` |
78+
| GraphQL | `gql`, `graphql` |
7879
| Groovy | `gradle`, `groovy` |
7980
| Handlebars | `handlebars`, `hbs` |
8081
| HTML/XML | `html`, `xhtml`, `xml` |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
language: 'GraphQL',
3+
mode: {
4+
primary: 'graphql',
5+
aliases: {
6+
gql: 'GraphQL',
7+
},
8+
},
9+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
person(id: 4) {
3+
name
4+
}
5+
allFilms {
6+
totalCount
7+
films {
8+
releaseDate
9+
planetConnection {
10+
planets {
11+
id
12+
surfaceWater
13+
climates
14+
terrains
15+
}
16+
}
17+
}
18+
}
19+
}

__tests__/__snapshots__/codeMirror.test.js.snap

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,29 @@ exports[`Supported languages Go should syntax highlight an example 1`] = `
112112
</div>"
113113
`;
114114
115+
exports[`Supported languages GraphQL should syntax highlight an example 1`] = `
116+
"<div class=\\"cm-s-neo\\"><span class=\\"cm-punctuation\\">{</span>
117+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">person</span><span class=\\"cm-punctuation\\">(</span><span class=\\"cm-attribute\\">id</span><span class=\\"cm-punctuation\\">:</span><span class=\\"cm-ws\\"> </span><span class=\\"cm-number\\">4</span><span class=\\"cm-punctuation\\">)</span><span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">{</span>
118+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">name</span>
119+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">}</span>
120+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">allFilms</span><span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">{</span>
121+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">totalCount</span>
122+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">films</span><span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">{</span>
123+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">releaseDate</span>
124+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">planetConnection</span><span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">{</span>
125+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">planets</span><span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">{</span>
126+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">id</span>
127+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">surfaceWater</span>
128+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">climates</span>
129+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-property\\">terrains</span>
130+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">}</span>
131+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">}</span>
132+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">}</span>
133+
<span class=\\"cm-ws\\"> </span><span class=\\"cm-punctuation\\">}</span>
134+
<span class=\\"cm-punctuation\\">}</span>
135+
</div>"
136+
`;
137+
115138
exports[`Supported languages Groovy should syntax highlight an example 1`] = `
116139
"<div class=\\"cm-s-neo\\"><span class=\\"cm-variable\\">println</span> <span class=\\"cm-string\\">&quot;Hello World&quot;</span>
117140
</div>"

package-lock.json

Lines changed: 139 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
},
2525
"dependencies": {
2626
"codemirror": "^5.48.2",
27+
"codemirror-graphql": "^1.0.2",
2728
"prop-types": "^15.7.2",
2829
"react-codemirror2": "^7.2.1"
2930
},

src/utils/canonical.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const modeAliases = {
1313
docker: 'dockerfile',
1414
ecmascript: 'javascript',
1515
erl: 'erlang',
16+
gql: 'graphql',
1617
gradle: 'groovy',
1718
handlebars: 'html',
1819
hbs: 'html',

src/utils/cm-mode-imports.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ require('codemirror/mode/sql/sql');
2626
require('codemirror/mode/swift/swift');
2727
require('codemirror/mode/toml/toml');
2828
require('codemirror/mode/yaml/yaml');
29+
require('codemirror-graphql/mode');

src/utils/modes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const modes = {
3131
erl: 'erlang',
3232
go: ['go', 'text/x-go'],
3333
gradle: 'groovy',
34+
gql: 'graphql',
3435
handlebars: 'htmlmixed',
3536
hbs: 'htmlmixed',
3637
html: 'htmlmixed',

src/utils/uppercase.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ const codeTypes = {
2525
erl: 'Erlang',
2626
erlang: 'Erlang',
2727
go: 'Go',
28+
gql: 'GraphQL',
2829
gradle: 'Gradle',
30+
graphql: 'GraphQL',
2931
groovy: 'Groovy',
3032
handlebars: 'Handlebars',
3133
hbs: 'Handlebars',

0 commit comments

Comments
 (0)