@uiw/react-codemirror 4.25.10 → 4.25.12
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/README.md +0 -2
- package/cjs/theme/dimensionTheme.d.ts +3 -0
- package/cjs/theme/dimensionTheme.js +43 -0
- package/cjs/useCodeMirror.js +3 -14
- package/dist/codemirror.js +148 -85
- package/dist/codemirror.min.js +1 -1
- package/esm/theme/dimensionTheme.d.ts +3 -0
- package/esm/theme/dimensionTheme.js +36 -0
- package/esm/useCodeMirror.js +3 -14
- package/package.json +2 -2
- package/src/theme/dimensionTheme.ts +42 -0
- package/src/useCodeMirror.ts +8 -14
package/README.md
CHANGED
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6476400184" title="Resume Revise for macOS"><img alt="Resume Revise" height="52" src="https://wangchujiang.com/appicon/resume-revise.png"></a>
|
|
52
52
|
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6472593276" title="Palette Genius for macOS"><img alt="Palette Genius" height="52" src="https://wangchujiang.com/appicon/palette-genius.png"></a>
|
|
53
53
|
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6470879005" title="Symbol Scribe for macOS"><img alt="Symbol Scribe" height="52" src="https://wangchujiang.com/appicon/symbol-scribe.png"></a>
|
|
54
|
-
<br><br>
|
|
55
54
|
</div>
|
|
56
55
|
<hr>
|
|
57
56
|
|
|
@@ -133,7 +132,6 @@ npm install @uiw/react-codemirror --save
|
|
|
133
132
|
| [`@uiw/codemirror-theme-github`](https://uiwjs.github.io/react-codemirror/#/theme/data/github) | [](https://www.npmjs.com/package/@uiw/codemirror-theme-github) [](https://www.npmjs.com/package/@uiw/codemirror-theme-github) |
|
|
134
133
|
| [`@uiw/codemirror-theme-gruvbox-dark`](https://uiwjs.github.io/react-codemirror/#/theme/data/gruvbox/dark) | [](https://www.npmjs.com/package/@uiw/codemirror-theme-gruvbox-dark) [](https://www.npmjs.com/package/@uiw/codemirror-theme-gruvbox-dark) |
|
|
135
134
|
| [`@uiw/codemirror-theme-kimbie`](https://uiwjs.github.io/react-codemirror/#/theme/data/kimbie/dark) | [](https://www.npmjs.com/package/@uiw/codemirror-theme-kimbie) [](https://www.npmjs.com/package/@uiw/codemirror-theme-kimbie) |
|
|
136
|
-
| [`@uiw/codemirror-theme-kimbie`](https://uiwjs.github.io/react-codemirror/#/theme/data/kimbie/dark) | [](https://www.npmjs.com/package/@uiw/codemirror-theme-kimbie) [](https://www.npmjs.com/package/@uiw/codemirror-theme-kimbie) |
|
|
137
135
|
| [`@uiw/codemirror-theme-material`](https://uiwjs.github.io/react-codemirror/#/theme/data/material/dark) | [](https://www.npmjs.com/package/@uiw/codemirror-theme-material) [](https://www.npmjs.com/package/@uiw/codemirror-theme-material) |
|
|
138
136
|
| [`@uiw/codemirror-theme-monokai`](https://uiwjs.github.io/react-codemirror/#/theme/data/monokai) | [](https://www.npmjs.com/package/@uiw/codemirror-theme-monokai) [](https://www.npmjs.com/package/@uiw/codemirror-theme-monokai) |
|
|
139
137
|
| [`@uiw/codemirror-theme-monokai-dimmed`](https://uiwjs.github.io/react-codemirror/#/theme/data/monokai) | [](https://www.npmjs.com/package/@uiw/codemirror-theme-monokai-dimmed) [](https://www.npmjs.com/package/@uiw/codemirror-theme-monokai-dimmed) |
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Extension } from '@codemirror/state';
|
|
2
|
+
export declare const scrollerTheme: Extension;
|
|
3
|
+
export declare function getDimensionTheme(height: string | null, minHeight: string | null, maxHeight: string | null, width: string | null, minWidth: string | null, maxWidth: string | null): Extension | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDimensionTheme = getDimensionTheme;
|
|
7
|
+
exports.scrollerTheme = void 0;
|
|
8
|
+
var _view = require("@codemirror/view");
|
|
9
|
+
var scrollerTheme = exports.scrollerTheme = _view.EditorView.theme({
|
|
10
|
+
'& .cm-scroller': {
|
|
11
|
+
height: '100% !important'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var lastDimensionKey = null;
|
|
15
|
+
var lastDimensionTheme = null;
|
|
16
|
+
function getDimensionTheme(height, minHeight, maxHeight, width, minWidth, maxWidth) {
|
|
17
|
+
if (!height && !minHeight && !maxHeight && !width && !minWidth && !maxWidth) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var cacheKey = JSON.stringify({
|
|
21
|
+
height: height,
|
|
22
|
+
minHeight: minHeight,
|
|
23
|
+
maxHeight: maxHeight,
|
|
24
|
+
width: width,
|
|
25
|
+
minWidth: minWidth,
|
|
26
|
+
maxWidth: maxWidth
|
|
27
|
+
});
|
|
28
|
+
if (cacheKey === lastDimensionKey) {
|
|
29
|
+
return lastDimensionTheme;
|
|
30
|
+
}
|
|
31
|
+
lastDimensionKey = cacheKey;
|
|
32
|
+
lastDimensionTheme = _view.EditorView.theme({
|
|
33
|
+
'&': {
|
|
34
|
+
height: height,
|
|
35
|
+
minHeight: minHeight,
|
|
36
|
+
maxHeight: maxHeight,
|
|
37
|
+
width: width,
|
|
38
|
+
minWidth: minWidth,
|
|
39
|
+
maxWidth: maxWidth
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return lastDimensionTheme;
|
|
43
|
+
}
|
package/cjs/useCodeMirror.js
CHANGED
|
@@ -14,6 +14,7 @@ var _view = require("@codemirror/view");
|
|
|
14
14
|
var _getDefaultExtensions = require("./getDefaultExtensions");
|
|
15
15
|
var _utils = require("./utils");
|
|
16
16
|
var _timeoutLatch = require("./timeoutLatch");
|
|
17
|
+
var _dimensionTheme = require("./theme/dimensionTheme");
|
|
17
18
|
var ExternalChange = exports.ExternalChange = _state.Annotation.define();
|
|
18
19
|
var TYPING_TIMOUT = 200; // ms
|
|
19
20
|
|
|
@@ -76,19 +77,7 @@ function useCodeMirror(props) {
|
|
|
76
77
|
current: null
|
|
77
78
|
};
|
|
78
79
|
})[0];
|
|
79
|
-
var defaultThemeOption =
|
|
80
|
-
'&': {
|
|
81
|
-
height: height,
|
|
82
|
-
minHeight: minHeight,
|
|
83
|
-
maxHeight: maxHeight,
|
|
84
|
-
width: width,
|
|
85
|
-
minWidth: minWidth,
|
|
86
|
-
maxWidth: maxWidth
|
|
87
|
-
},
|
|
88
|
-
'& .cm-scroller': {
|
|
89
|
-
height: '100% !important'
|
|
90
|
-
}
|
|
91
|
-
});
|
|
80
|
+
var defaultThemeOption = (0, _dimensionTheme.getDimensionTheme)(height, minHeight, maxHeight, width, minWidth, maxWidth);
|
|
92
81
|
var updateListener = _view.EditorView.updateListener.of(function (vu) {
|
|
93
82
|
if (vu.docChanged && typeof onChange === 'function' &&
|
|
94
83
|
// Fix echoing of the remote changes:
|
|
@@ -123,7 +112,7 @@ function useCodeMirror(props) {
|
|
|
123
112
|
indentWithTab: defaultIndentWithTab,
|
|
124
113
|
basicSetup: defaultBasicSetup
|
|
125
114
|
});
|
|
126
|
-
var getExtensions = [updateListener, defaultThemeOption].
|
|
115
|
+
var getExtensions = [updateListener].concat((0, _toConsumableArray2["default"])(defaultThemeOption ? [defaultThemeOption] : []), [_dimensionTheme.scrollerTheme], (0, _toConsumableArray2["default"])(defaultExtensions));
|
|
127
116
|
if (onUpdate && typeof onUpdate === 'function') {
|
|
128
117
|
getExtensions.push(_view.EditorView.updateListener.of(onUpdate));
|
|
129
118
|
}
|