Skip to content

Commit 51bfa7f

Browse files
committed
feat(editor): use google-modes for syntax highlight
1 parent c0f6795 commit 51bfa7f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[
44
"@babel/preset-env",
55
{
6-
"modules": false,
6+
"modules": "commonjs",
77
"useBuiltIns": "usage",
88
"corejs": 2,
99
"exclude": [

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"babel-plugin-async-to-promises": "^1.0.5",
2424
"ci-publish": "^1.3.1",
2525
"codemirror": "^5.48.4",
26+
"codemirror-grammar-mode": "^0.1.9",
2627
"css-loader": "2.1.1",
2728
"debounce": "^1.2.0",
2829
"deepmerge": "^1.5.0",
@@ -32,6 +33,7 @@
3233
"fast-async": "7",
3334
"flatten": "^1.0.2",
3435
"github-markdown-css": "^3.0.1",
36+
"google_modes": "git+https://github.com/codemirror/google-modes.git",
3537
"html-webpack-plugin": "^3.2.0",
3638
"is-empty-object": "^1.1.1",
3739
"markdown-it": "^8.4.2",

src/executable-code/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'codemirror';
1+
import CodeMirror from 'codemirror';
22
import 'codemirror/lib/codemirror';
33
import 'codemirror/addon/hint/show-hint'
44
import 'codemirror/addon/hint/anyword-hint'
@@ -24,6 +24,10 @@ import TargetPlatform from '../target-platform'
2424
import ExecutableFragment from './executable-fragment';
2525
import '../styles.scss';
2626

27+
globalThis.CodeMirror = CodeMirror;
28+
require('codemirror-grammar-mode');
29+
require('google_modes/dist/kotlin');
30+
2731
const INITED_ATTRIBUTE_NAME = 'data-kotlin-playground-initialized';
2832
const DEFAULT_INDENT = 4;
2933

@@ -51,7 +55,7 @@ const ATTRIBUTES = {
5155

5256
const MODES = {
5357
JAVA: "text/x-java",
54-
KOTLIN: "text/x-kotlin",
58+
KOTLIN: "google-kotlin",
5559
JS: "text/javascript",
5660
GROOVY: "text/x-groovy",
5761
XML: "text/html",

0 commit comments

Comments
 (0)