@scalar/use-codemirror 0.11.57 → 0.11.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @scalar/use-codemirror
|
|
2
2
|
|
|
3
|
+
## 0.11.59
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7f3aa9c: refactor: remove @uiw/codemirror-themes
|
|
8
|
+
|
|
9
|
+
## 0.11.58
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [2ad0407]
|
|
14
|
+
- Updated dependencies [e866487]
|
|
15
|
+
- @scalar/components@0.13.14
|
|
16
|
+
|
|
3
17
|
## 0.11.57
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is copied from @uiw/codemirror-themes.
|
|
3
|
+
* We’ve had issues with the import (something to do with CJS/ESM).
|
|
4
|
+
*
|
|
5
|
+
* @see https://github.com/uiwjs/react-codemirror
|
|
6
|
+
* @see https://github.com/scalar/scalar/issues/4222
|
|
7
|
+
*/
|
|
8
|
+
import { type TagStyle } from '@codemirror/language';
|
|
9
|
+
import type { Extension } from '@codemirror/state';
|
|
10
|
+
import type { StyleSpec } from 'style-mod';
|
|
11
|
+
export type CreateThemeOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* Theme inheritance. Determines which styles CodeMirror will apply by default.
|
|
14
|
+
*/
|
|
15
|
+
theme: Theme;
|
|
16
|
+
/**
|
|
17
|
+
* Settings to customize the look of the editor, like background, gutter, selection and others.
|
|
18
|
+
*/
|
|
19
|
+
settings: Settings;
|
|
20
|
+
/** Syntax highlighting styles. */
|
|
21
|
+
styles: TagStyle[];
|
|
22
|
+
};
|
|
23
|
+
type Theme = 'light' | 'dark';
|
|
24
|
+
export type Settings = {
|
|
25
|
+
/** Editor background color. */
|
|
26
|
+
background?: string;
|
|
27
|
+
/** Editor background image. */
|
|
28
|
+
backgroundImage?: string;
|
|
29
|
+
/** Default text color. */
|
|
30
|
+
foreground?: string;
|
|
31
|
+
/** Caret color. */
|
|
32
|
+
caret?: string;
|
|
33
|
+
/** Selection background. */
|
|
34
|
+
selection?: string;
|
|
35
|
+
/** Selection match background. */
|
|
36
|
+
selectionMatch?: string;
|
|
37
|
+
/** Background of highlighted lines. */
|
|
38
|
+
lineHighlight?: string;
|
|
39
|
+
/** Gutter background. */
|
|
40
|
+
gutterBackground?: string;
|
|
41
|
+
/** Text color inside gutter. */
|
|
42
|
+
gutterForeground?: string;
|
|
43
|
+
/** Text active color inside gutter. */
|
|
44
|
+
gutterActiveForeground?: string;
|
|
45
|
+
/** Gutter right border color. */
|
|
46
|
+
gutterBorder?: string;
|
|
47
|
+
/** set editor font */
|
|
48
|
+
fontFamily?: string;
|
|
49
|
+
/** set editor font size */
|
|
50
|
+
fontSize?: StyleSpec['fontSize'];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Creates a CodeMirror theme from a set of options.
|
|
54
|
+
*/
|
|
55
|
+
export declare const createCodeMirrorTheme: ({ theme, settings, styles, }: CreateThemeOptions) => Extension;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=createCodeMirrorTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCodeMirrorTheme.d.ts","sourceRoot":"","sources":["../../src/themes/createCodeMirrorTheme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;IACZ;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAA;IAClB,kCAAkC;IAClC,MAAM,EAAE,QAAQ,EAAE,CAAA;CACnB,CAAA;AAED,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;AAE7B,MAAM,MAAM,QAAQ,GAAG;IACrB,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,yBAAyB;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gCAAgC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,uCAAuC;IACvC,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,sBAAsB;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;CACjC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,iCAI/B,kBAAkB,KAAG,SA4EvB,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';
|
|
2
|
+
import { EditorView } from '@codemirror/view';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file is copied from @uiw/codemirror-themes.
|
|
6
|
+
* We’ve had issues with the import (something to do with CJS/ESM).
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/uiwjs/react-codemirror
|
|
9
|
+
* @see https://github.com/scalar/scalar/issues/4222
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Creates a CodeMirror theme from a set of options.
|
|
13
|
+
*/
|
|
14
|
+
const createCodeMirrorTheme = ({ theme, settings = {}, styles = [], }) => {
|
|
15
|
+
const themeOptions = {
|
|
16
|
+
'.cm-gutters': {},
|
|
17
|
+
};
|
|
18
|
+
const baseStyle = {};
|
|
19
|
+
if (settings.background) {
|
|
20
|
+
baseStyle.backgroundColor = settings.background;
|
|
21
|
+
}
|
|
22
|
+
if (settings.backgroundImage) {
|
|
23
|
+
baseStyle.backgroundImage = settings.backgroundImage;
|
|
24
|
+
}
|
|
25
|
+
if (settings.foreground) {
|
|
26
|
+
baseStyle.color = settings.foreground;
|
|
27
|
+
}
|
|
28
|
+
if (settings.fontSize) {
|
|
29
|
+
baseStyle.fontSize = settings.fontSize;
|
|
30
|
+
}
|
|
31
|
+
if (settings.background || settings.foreground) {
|
|
32
|
+
themeOptions['&'] = baseStyle;
|
|
33
|
+
}
|
|
34
|
+
if (settings.fontFamily) {
|
|
35
|
+
themeOptions['&.cm-editor .cm-scroller'] = {
|
|
36
|
+
fontFamily: settings.fontFamily,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (settings.gutterBackground) {
|
|
40
|
+
themeOptions['.cm-gutters'].backgroundColor = settings.gutterBackground;
|
|
41
|
+
}
|
|
42
|
+
if (settings.gutterForeground) {
|
|
43
|
+
themeOptions['.cm-gutters'].color = settings.gutterForeground;
|
|
44
|
+
}
|
|
45
|
+
if (settings.gutterBorder) {
|
|
46
|
+
themeOptions['.cm-gutters'].borderRightColor = settings.gutterBorder;
|
|
47
|
+
}
|
|
48
|
+
if (settings.caret) {
|
|
49
|
+
themeOptions['.cm-content'] = {
|
|
50
|
+
caretColor: settings.caret,
|
|
51
|
+
};
|
|
52
|
+
themeOptions['.cm-cursor, .cm-dropCursor'] = {
|
|
53
|
+
borderLeftColor: settings.caret,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const activeLineGutterStyle = {};
|
|
57
|
+
if (settings.gutterActiveForeground) {
|
|
58
|
+
activeLineGutterStyle.color = settings.gutterActiveForeground;
|
|
59
|
+
}
|
|
60
|
+
if (settings.lineHighlight) {
|
|
61
|
+
themeOptions['.cm-activeLine'] = {
|
|
62
|
+
backgroundColor: settings.lineHighlight,
|
|
63
|
+
};
|
|
64
|
+
activeLineGutterStyle.backgroundColor = settings.lineHighlight;
|
|
65
|
+
}
|
|
66
|
+
themeOptions['.cm-activeLineGutter'] = activeLineGutterStyle;
|
|
67
|
+
if (settings.selection) {
|
|
68
|
+
themeOptions['&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection'] = {
|
|
69
|
+
background: settings.selection + ' !important',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (settings.selectionMatch) {
|
|
73
|
+
themeOptions['& .cm-selectionMatch'] = {
|
|
74
|
+
backgroundColor: settings.selectionMatch,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const themeExtension = EditorView.theme(themeOptions, {
|
|
78
|
+
dark: theme === 'dark',
|
|
79
|
+
});
|
|
80
|
+
const highlightStyle = HighlightStyle.define(styles);
|
|
81
|
+
const extension = [themeExtension, syntaxHighlighting(highlightStyle)];
|
|
82
|
+
return extension;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { createCodeMirrorTheme };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/themes/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/themes/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,uCAqFtB,CAAA"}
|
package/dist/themes/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tags } from '@lezer/highlight';
|
|
2
|
-
import {
|
|
2
|
+
import { createCodeMirrorTheme } from './createCodeMirrorTheme.js';
|
|
3
3
|
|
|
4
|
-
const customTheme =
|
|
4
|
+
const customTheme = createCodeMirrorTheme({
|
|
5
5
|
theme: 'light',
|
|
6
6
|
settings: {
|
|
7
7
|
background: 'var(--scalar-background-2)',
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"vue",
|
|
17
17
|
"vue3"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.11.
|
|
19
|
+
"version": "0.11.59",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"@lezer/highlight": "^1.2.1",
|
|
65
65
|
"@lezer/lr": "^1.4.2",
|
|
66
66
|
"@replit/codemirror-css-color-picker": "^6.3.0",
|
|
67
|
-
"@uiw/codemirror-themes": "^4.23.7",
|
|
68
67
|
"codemirror": "^6.0.0",
|
|
68
|
+
"style-mod": "^4.1.2",
|
|
69
69
|
"vue": "^3.5.12",
|
|
70
|
-
"@scalar/components": "0.13.
|
|
70
|
+
"@scalar/components": "0.13.14"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
@@ -77,7 +77,8 @@
|
|
|
77
77
|
"vue": "^3.5.12",
|
|
78
78
|
"y-codemirror.next": "^0.3.2",
|
|
79
79
|
"yjs": "^13.6.0",
|
|
80
|
-
"@scalar/build-tooling": "0.1.12"
|
|
80
|
+
"@scalar/build-tooling": "0.1.12",
|
|
81
|
+
"@scalar/themes": "0.9.60"
|
|
81
82
|
},
|
|
82
83
|
"scripts": {
|
|
83
84
|
"build": "scalar-build-rollup",
|