Skip to content

Commit bafb258

Browse files
committed
Add files
1 parent 028334d commit bafb258

File tree

13 files changed

+2389
-0
lines changed

13 files changed

+2389
-0
lines changed

.github/workflows/publish_demo.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Publish Demo
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
deploy:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-node@v2
12+
with:
13+
node-version: "16"
14+
cache: "npm"
15+
- run: npm ci
16+
- run: npm run build
17+
- uses: peaceiris/actions-gh-pages@v3
18+
with:
19+
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
publish_dir: ./dist
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v2
13+
with:
14+
node-version: "16"
15+
cache: "npm"
16+
registry-url: https://registry.npmjs.org/
17+
- run: npm ci
18+
- run: npm publish --access public
19+
env:
20+
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
21+
22+
- uses: actions/setup-node@v2
23+
with:
24+
node-version: "16"
25+
cache: "npm"
26+
registry-url: https://npm.pkg.github.com/
27+
- run: npm publish --access public
28+
env:
29+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx pretty-quick

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 kazk
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# codemirror-riscv
2+
3+
RISC-V mode for CodeMirror.
4+
5+
- `defineMode(CodeMirror)`: Define `riscv` mode and MIME `text/x-riscv`
6+
7+
## Usage
8+
9+
```javascript
10+
import CodeMirror from "codemirror";
11+
import "codemirror/addon/mode/simple.js"; // `CodeMirror.defineSimpleMode`
12+
13+
import { defineMode } from "@codewars/codemirror-riscv";
14+
15+
defineMode(CodeMirror);
16+
```
17+
18+
## Demo
19+
20+
See https://codewars.github.io/codemirror-riscv/
21+
22+
## Development
23+
24+
Run `npm run dev` to start a local dev server.

codewars.css

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/* The demo uses dark theme. Remove `.dark` from body to see the light theme */
2+
/* Codewars CodeMirror Theme: Light */
3+
:root {
4+
--color-cm-editor-bg: #ffffff;
5+
--color-cm-editor-fg: #000000;
6+
7+
--color-cm-editor-selection: #e0e0e0;
8+
--color-cm-editor-gutter: #f9f9f9;
9+
--color-cm-editor-gutter-border: #ebebeb;
10+
--color-cm-editor-line-number: #b0b0b0;
11+
--color-cm-editor-cursor: #505050;
12+
--color-cm-editor-fat-cursor: #7e7;
13+
--color-cm-editor-active-line-bg: #fafafa;
14+
--color-cm-editor-dialog-bg: var(--color-cm-editor-bg);
15+
--color-cm-editor-dialog-fg: var(--color-cm-editor-fg);
16+
--color-cm-editor-hint-bg: var(--color-cm-editor-bg);
17+
--color-cm-editor-hint-fg: var(--color-cm-editor-fg);
18+
--color-cm-editor-hint-active-bg: var(--color-cm-editor-hint-fg);
19+
--color-cm-editor-hint-active-fg: var(--color-cm-editor-hint-bg);
20+
--color-cm-editor-matching-bracket: #000000;
21+
--color-cm-editor-matching-bracket-outline: #bbbbbb;
22+
23+
--color-cm-atom: #7b007b;
24+
--color-cm-attribute: #7b007b;
25+
--color-cm-bracket: #333;
26+
--color-cm-builtin: #46438f;
27+
--color-cm-comment: #8e8e8e;
28+
--color-cm-def: #aa6c0b;
29+
--color-cm-error: #fdd;
30+
--color-cm-keyword: #850921;
31+
--color-cm-link: #448844;
32+
--color-cm-meta: #6b6bbc;
33+
--color-cm-number: #a34503;
34+
--color-cm-operator: #445358;
35+
--color-cm-placeholder: #bbb;
36+
--color-cm-property: #3a4f4a;
37+
--color-cm-qualifier: #555;
38+
--color-cm-string: #887836;
39+
--color-cm-symbol: #2aa198;
40+
--color-cm-tag: #850921;
41+
--color-cm-variable-2: #0d5a72;
42+
--color-cm-variable-3: #006c47;
43+
--color-cm-variable: #000000;
44+
}
45+
46+
/* Codewars CodeMirror Theme: Dark */
47+
.dark {
48+
--color-cm-editor-bg: #131414;
49+
--color-cm-editor-fg: #cccccc;
50+
51+
--color-cm-editor-selection: #4a5964;
52+
--color-cm-editor-gutter: #131414;
53+
--color-cm-editor-gutter-border: #222222;
54+
--color-cm-editor-line-number: #515151;
55+
--color-cm-editor-cursor: #999999;
56+
--color-cm-editor-fat-cursor: #7e7;
57+
--color-cm-editor-active-line-bg: rgba(255, 255, 255, 0.05);
58+
--color-cm-editor-matching-bracket: #cccccc;
59+
--color-cm-editor-matching-bracket-outline: #555555;
60+
--color-cm-editor-dialog-bg: var(--color-cm-editor-bg);
61+
--color-cm-editor-dialog-fg: var(--color-cm-editor-fg);
62+
--color-cm-editor-hint-bg: var(--color-cm-editor-bg);
63+
--color-cm-editor-hint-fg: #cccccc;
64+
--color-cm-editor-hint-active-bg: var(--color-cm-editor-hint-fg);
65+
--color-cm-editor-hint-active-fg: var(--color-cm-editor-hint-bg);
66+
67+
--color-cm-atom: #dc7069;
68+
--color-cm-attribute: #dc7069;
69+
--color-cm-bracket: #cccccc;
70+
--color-cm-builtin: #fff0f6;
71+
--color-cm-comment: #969896;
72+
--color-cm-def: #de935f;
73+
--color-cm-error: #b15255;
74+
--color-cm-keyword: #b294bb;
75+
--color-cm-link: #a16a94;
76+
--color-cm-meta: var(--color-cm-editor-fg);
77+
--color-cm-number: #de935f;
78+
--color-cm-operator: #ddd;
79+
--color-cm-placeholder: #444;
80+
--color-cm-property: #81a2be;
81+
--color-cm-qualifier: #bbb;
82+
--color-cm-string: #b5bd68;
83+
--color-cm-symbol: #ddd;
84+
--color-cm-tag: #f0c674;
85+
--color-cm-variable-2: #89b6c5;
86+
--color-cm-variable-3: #6abe79;
87+
--color-cm-variable: #eee;
88+
}
89+
90+
/* prettier-ignore */
91+
.cm-s-codewars {
92+
background: var(--color-cm-editor-bg);
93+
color: var(--color-cm-editor-fg);
94+
95+
& span.cm-atom { color: var(--color-cm-atom); }
96+
& span.cm-attribute { color: var(--color-cm-attribute); }
97+
& span.cm-bracket { color: var(--color-cm-bracket); }
98+
& span.cm-builtin { color: var(--color-cm-builtin); }
99+
& span.cm-comment { color: var(--color-cm-comment); }
100+
& span.cm-def { color: var(--color-cm-def); }
101+
& span.cm-error { background: var(--color-cm-error); }
102+
& span.cm-keyword, & span.cm-type { color: var(--color-cm-keyword); }
103+
& span.cm-link { color: var(--color-cm-link); }
104+
& span.cm-meta { color: var(--color-cm-meta); }
105+
& span.cm-number { color: var(--color-cm-number); }
106+
& span.cm-operator { color: var(--color-cm-operator); }
107+
& span.cm-property { color: var(--color-cm-property); }
108+
& span.cm-qualifier { color: var(--color-cm-qualifier); }
109+
& span.cm-string, & span.cm-string-2 { color: var(--color-cm-string); }
110+
& span.cm-tag { color: var(--color-cm-tag); }
111+
& span.cm-variable { color: var(--color-cm-variable); }
112+
& span.cm-variable-2 { color: var(--color-cm-variable-2); }
113+
& span.cm-variable-3 { color: var(--color-cm-variable-3); }
114+
115+
& .CodeMirror-scrollbar-filler {
116+
background: var(--color-cm-editor-bg);
117+
}
118+
119+
& .CodeMirror-selected {
120+
background: var(--color-cm-editor-selection) !important;
121+
}
122+
123+
& .CodeMirror-gutters {
124+
background: var(--color-cm-editor-gutter);
125+
border-right: 1px solid var(--color-cm-editor-gutter-border);
126+
}
127+
128+
& .CodeMirror-linenumber {
129+
color: var(--color-cm-editor-line-number);
130+
}
131+
132+
& .CodeMirror-activeline-background {
133+
background: var(--color-cm-editor-active-line-bg) !important;
134+
}
135+
136+
& .CodeMirror-matchingbracket {
137+
color: var(--color-cm-editor-matching-bracket) !important;
138+
outline: 1px solid var(--color-cm-editor-matching-bracket-outline) !important;
139+
}
140+
141+
&:not(.cm-fat-cursor) .CodeMirror-cursor {
142+
border-left: 1px solid var(--color-cm-editor-cursor) !important;
143+
}
144+
145+
&.cm-fat-cursor .CodeMirror-cursor {
146+
background: var(--color-cm-editor-fat-cursor);
147+
}
148+
}

index.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>CodeMirror: RISC-V Mode</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
8+
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/awsm_theme_black.min.css">
9+
<style>
10+
.CodeMirror { margin: auto; }
11+
.text-center { text-align: center; }
12+
.mb-8 { margin-bottom: 2rem; }
13+
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }
14+
.mx-auto { margin-left: auto; margin-right: auto; }
15+
</style>
16+
</head>
17+
18+
<body class="dark">
19+
<header class="text-center mb-8">
20+
<img class="my-4 mx-auto" src="./riscv.svg" alt="RISC-V" width="64" height="64">
21+
<h1>RISC-V mode for CodeMirror</h1>
22+
<p><code>text/x-riscv</code></p>
23+
<p><a href="https://github.com/codewars/codemirror-riscv">codewars/codemirror-riscv</a></p>
24+
</header>
25+
26+
<main>
27+
<textarea id="editor">
28+
# comment
29+
.globl multiply
30+
multiply:
31+
mulw a0, a0, a1
32+
ret
33+
</textarea>
34+
</main>
35+
36+
<script type="module">
37+
import CodeMirror from "codemirror";
38+
import "codemirror/addon/mode/simple.js";
39+
import "codemirror/lib/codemirror.css";
40+
import "./codewars.css";
41+
42+
import { defineMode } from "./riscv.js";
43+
defineMode(CodeMirror);
44+
const editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
45+
mode: "riscv",
46+
lineNumbers: true,
47+
theme: "codewars",
48+
});
49+
editor.setSize(650, 500);
50+
</script>
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)