Skip to content

Commit e6b66d0

Browse files
committed
feat(bbedit): add bbeditInit method to bbedit theme.
1 parent 0515402 commit e6b66d0

File tree

2 files changed

+62
-29
lines changed

2 files changed

+62
-29
lines changed

themes/bbedit/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@
1616
npm install @uiw/codemirror-theme-bbedit --save
1717
```
1818

19+
```jsx
20+
import { tags as t } from '@lezer/highlight';
21+
import { bbedit, bbeditInit } from '@uiw/codemirror-theme-bbedit';
22+
23+
<CodeMirror theme={bbedit} />
24+
<CodeMirror
25+
theme={bbeditInit({
26+
settings: {
27+
caret: '#c6c6c6',
28+
fontFamily: 'monospace',
29+
},
30+
styles: [
31+
{ tag: t.comment, color: '#6272a4' },
32+
]
33+
})}
34+
/>
35+
```
36+
37+
## API
38+
39+
```tsx
40+
import { CreateThemeOptions } from '@uiw/codemirror-themes';
41+
export declare const bbeditInit: (options?: CreateThemeOptions) => import('@codemirror/state').Extension;
42+
export declare const bbedit: import('@codemirror/state').Extension;
43+
```
44+
1945
## Usage
2046

2147
```jsx

themes/bbedit/src/index.ts

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
import { tags as t } from '@lezer/highlight';
2-
import { createTheme } from '@uiw/codemirror-themes';
2+
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
33

4-
export const bbedit = createTheme({
5-
theme: 'light',
6-
settings: {
7-
background: '#FFFFFF',
8-
foreground: '#000000',
9-
caret: '#FBAC52',
10-
selection: '#FFD420',
11-
selectionMatch: '#FFD420',
12-
gutterBackground: '#f5f5f5',
13-
gutterForeground: '#4D4D4C',
14-
lineHighlight: '#00000012',
15-
},
16-
styles: [
17-
{ tag: [t.meta, t.comment], color: '#804000' },
18-
{ tag: [t.keyword, t.strong], color: '#0000FF' },
19-
{ tag: [t.number], color: '#FF0080' },
20-
{ tag: [t.string], color: '#FF0080' },
21-
{ tag: [t.variableName], color: '#006600' },
22-
{ tag: [t.escape], color: '#33CC33' },
23-
{ tag: [t.tagName], color: '#1C02FF' },
24-
{ tag: [t.heading], color: '#0C07FF' },
25-
{ tag: [t.quote], color: '#000000' },
26-
{ tag: [t.list], color: '#B90690' },
27-
{ tag: [t.documentMeta], color: '#888888' },
28-
{ tag: [t.function(t.variableName)], color: '#0000A2' },
29-
{ tag: [t.definition(t.typeName), t.typeName], color: '#6D79DE' },
30-
],
31-
});
4+
export const bbeditInit = (options?: CreateThemeOptions) => {
5+
const { theme = 'light', settings = {}, styles = [] } = options || {};
6+
return createTheme({
7+
theme: theme,
8+
settings: {
9+
background: '#FFFFFF',
10+
foreground: '#000000',
11+
caret: '#FBAC52',
12+
selection: '#FFD420',
13+
selectionMatch: '#FFD420',
14+
gutterBackground: '#f5f5f5',
15+
gutterForeground: '#4D4D4C',
16+
lineHighlight: '#00000012',
17+
...settings,
18+
},
19+
styles: [
20+
{ tag: [t.meta, t.comment], color: '#804000' },
21+
{ tag: [t.keyword, t.strong], color: '#0000FF' },
22+
{ tag: [t.number], color: '#FF0080' },
23+
{ tag: [t.string], color: '#FF0080' },
24+
{ tag: [t.variableName], color: '#006600' },
25+
{ tag: [t.escape], color: '#33CC33' },
26+
{ tag: [t.tagName], color: '#1C02FF' },
27+
{ tag: [t.heading], color: '#0C07FF' },
28+
{ tag: [t.quote], color: '#000000' },
29+
{ tag: [t.list], color: '#B90690' },
30+
{ tag: [t.documentMeta], color: '#888888' },
31+
{ tag: [t.function(t.variableName)], color: '#0000A2' },
32+
{ tag: [t.definition(t.typeName), t.typeName], color: '#6D79DE' },
33+
...styles,
34+
],
35+
});
36+
};
37+
38+
export const bbedit = bbeditInit();

0 commit comments

Comments
 (0)