-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cd63b5
commit fbb07e1
Showing
15 changed files
with
253 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<!--rehype:ignore:start--> | ||
|
||
# Red Theme | ||
|
||
<!--rehype:ignore:end--> | ||
|
||
[![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-red.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-red) | ||
|
||
Red theme for cm6, generated from [vscode themes](https://github.com/microsoft/vscode/blob/main/extensions/theme-red/themes/Red-color-theme.json). | ||
|
||
<a href="https://uiwjs.github.io/react-codemirror/#/theme/data/red"> | ||
<img width="436" alt="codemirror-theme-red" src="https://github.com/uiwjs/react-codemirror/assets/1680273/aef0a618-8c74-4466-9a04-35e368f582a7"> | ||
</a> | ||
|
||
## Install | ||
|
||
```bash | ||
npm install @uiw/codemirror-theme-red --save | ||
``` | ||
|
||
```jsx | ||
import { red, redInit } from '@uiw/codemirror-theme-red'; | ||
|
||
<CodeMirror theme={red} /> | ||
<CodeMirror | ||
theme={redInit({ | ||
settings: { | ||
caret: '#c6c6c6', | ||
fontFamily: 'monospace', | ||
} | ||
})} | ||
/> | ||
``` | ||
|
||
## API | ||
|
||
```tsx | ||
import { CreateThemeOptions } from '@uiw/codemirror-themes'; | ||
export declare const defaultSettingsQuietlight: CreateThemeOptions['settings']; | ||
export declare const redInit: (options?: Partial<CreateThemeOptions>) => import('@codemirror/state').Extension; | ||
export declare const red: import('@codemirror/state').Extension; | ||
``` | ||
|
||
## Usage | ||
|
||
```jsx | ||
import CodeMirror from '@uiw/react-codemirror'; | ||
import { red } from '@uiw/codemirror-theme-red'; | ||
import { javascript } from '@codemirror/lang-javascript'; | ||
|
||
function App() { | ||
return ( | ||
<CodeMirror | ||
value="console.log('hello world!');" | ||
height="200px" | ||
theme={red} | ||
extensions={[javascript({ jsx: true })]} | ||
onChange={(value, viewUpdate) => { | ||
console.log('value:', value); | ||
}} | ||
/> | ||
); | ||
} | ||
export default App; | ||
``` | ||
|
||
```js | ||
import { EditorView } from '@codemirror/view'; | ||
import { EditorState } from '@codemirror/state'; | ||
import { javascript } from '@codemirror/lang-javascript'; | ||
import { red } from '@uiw/codemirror-theme-red'; | ||
|
||
const state = EditorState.create({ | ||
doc: 'my source code', | ||
extensions: [red, javascript({ jsx: true })], | ||
}); | ||
|
||
const view = new EditorView({ | ||
parent: document.querySelector('#editor'), | ||
state, | ||
}); | ||
``` | ||
|
||
## Contributors | ||
|
||
As always, thanks to our amazing contributors! | ||
|
||
<a href="https://github.com/uiwjs/react-codemirror/graphs/contributors"> | ||
<img src="https://uiwjs.github.io/react-codemirror/CONTRIBUTORS.svg" /> | ||
</a> | ||
|
||
Made with [github-action-contributors](https://github.com/jaywcjlove/github-action-contributors). | ||
|
||
## License | ||
|
||
Licensed under the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@uiw/codemirror-theme-red", | ||
"version": "4.21.10", | ||
"description": "Theme red for CodeMirror.", | ||
"homepage": "https://uiwjs.github.io/react-codemirror/#/theme/data/red", | ||
"author": "kenny wong <[email protected]>", | ||
"license": "MIT", | ||
"main": "./cjs/index.js", | ||
"module": "./esm/index.js", | ||
"scripts": { | ||
"watch": "tsbb watch src/*.ts --use-babel", | ||
"build": "tsbb build src/*.ts --use-babel" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/uiwjs/react-codemirror.git" | ||
}, | ||
"files": [ | ||
"src", | ||
"esm", | ||
"cjs" | ||
], | ||
"dependencies": { | ||
"@uiw/codemirror-themes": "4.21.10" | ||
}, | ||
"keywords": [ | ||
"codemirror", | ||
"codemirror-theme", | ||
"codemirror6", | ||
"theme", | ||
"red", | ||
"syntax", | ||
"ide", | ||
"code" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const config = { | ||
background: '#390000', | ||
foreground: '#F8F8F8', | ||
selection: '#750000', | ||
cursor: '#970000', | ||
dropdownBackground: '#580000', | ||
activeLine: '#ff000033', | ||
matchingBracket: '#ff000033', | ||
keyword: '#f12727ff', | ||
storage: '#ff6262ff', | ||
variable: '#fb9a4bff', | ||
parameter: '#fb9a4bff', | ||
function: '#ffb454ff', | ||
string: '#cd8d8dff', | ||
constant: '#ec0d1e', | ||
type: '#9df39fff', | ||
class: '#fec758ff', | ||
number: '#994646ff', | ||
comment: '#e7c0c0ff', | ||
heading: '#fec758ff', | ||
invalid: '#ffffffff', | ||
regexp: '#ffb454ff', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { tags as t } from '@lezer/highlight'; | ||
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; | ||
import { config } from './color'; | ||
|
||
export const defaultSettingsRed: CreateThemeOptions['settings'] = { | ||
background: config.background, | ||
foreground: config.foreground, | ||
caret: config.cursor, | ||
selection: config.selection, | ||
selectionMatch: config.selection, | ||
gutterBackground: config.background, | ||
gutterForeground: config.foreground, | ||
lineHighlight: config.activeLine, | ||
}; | ||
|
||
export const redInit = (options?: Partial<CreateThemeOptions>) => { | ||
const { theme = 'dark', settings = {}, styles = [] } = options || {}; | ||
return createTheme({ | ||
theme: theme, | ||
settings: { | ||
...defaultSettingsRed, | ||
...settings, | ||
}, | ||
styles: [ | ||
{ tag: t.keyword, color: config.keyword }, | ||
{ tag: [t.name, t.deleted, t.character, t.macroName], color: config.variable }, | ||
{ tag: [t.propertyName], color: config.function }, | ||
{ tag: [t.processingInstruction, t.string, t.inserted, t.special(t.string)], color: config.string }, | ||
{ tag: [t.function(t.variableName), t.labelName], color: config.function }, | ||
{ tag: [t.color, t.constant(t.name), t.standard(t.name)], color: config.constant }, | ||
{ tag: [t.definition(t.name), t.separator], color: config.variable }, | ||
{ tag: [t.className], color: config.class }, | ||
{ tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], color: config.number }, | ||
{ tag: [t.typeName], color: config.type, fontStyle: config.type }, | ||
{ tag: [t.operator, t.operatorKeyword], color: config.keyword }, | ||
{ tag: [t.url, t.escape, t.regexp, t.link], color: config.regexp }, | ||
{ tag: [t.meta, t.comment], color: config.comment }, | ||
{ tag: t.strong, fontWeight: 'bold' }, | ||
{ tag: t.emphasis, fontStyle: 'italic' }, | ||
{ tag: t.link, textDecoration: 'underline' }, | ||
{ tag: t.heading, fontWeight: 'bold', color: config.heading }, | ||
{ tag: [t.atom, t.bool, t.special(t.variableName)], color: config.variable }, | ||
{ tag: t.invalid, color: config.invalid }, | ||
{ tag: t.strikethrough, textDecoration: 'line-through' }, | ||
...styles, | ||
], | ||
}); | ||
}; | ||
|
||
export const red = redInit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"outDir": "./cjs", | ||
"baseUrl": ".", | ||
"noEmit": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters