@uiw/react-codemirror 4.25.9 → 4.25.11
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 +50 -34
- 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 +230 -132
- package/dist/codemirror.min.js +1 -1
- package/esm/getDefaultExtensions.js +13 -8
- package/esm/index.js +43 -43
- package/esm/theme/dimensionTheme.d.ts +3 -0
- package/esm/theme/dimensionTheme.js +36 -0
- package/esm/useCodeMirror.js +47 -41
- package/package.json +2 -2
- package/src/theme/dimensionTheme.ts +42 -0
- package/src/useCodeMirror.ts +8 -14
package/README.md
CHANGED
|
@@ -1,39 +1,56 @@
|
|
|
1
|
+
<div align="center" markdown="1">
|
|
2
|
+
<sup>Special thanks to:</sup>
|
|
3
|
+
<br>
|
|
4
|
+
<br>
|
|
5
|
+
|
|
6
|
+
<a href="https://apps.apple.com/app/apple-store/id6757860829?pt=80185800&ct=jay&mt=8">
|
|
7
|
+
<img alt="SubList" width="400" src="https://jaywcjlove.github.io/sponsor/SubList.jpg">
|
|
8
|
+
</a>
|
|
9
|
+
<br>
|
|
10
|
+
<a href="https://apps.apple.com/app/apple-store/id6757860829?pt=80185800&ct=jay&mt=8">
|
|
11
|
+
SubList - Bill Reminder & Renewal Alerts
|
|
12
|
+
</a>
|
|
13
|
+
<br><br>
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
<hr>
|
|
17
|
+
|
|
1
18
|
<div markdown="1">
|
|
2
19
|
<sup>Using <a href="https://wangchujiang.com/#/app" target="_blank">my app</a> is also a way to <a href="https://wangchujiang.com/#/sponsor" target="_blank">support</a> me:</sup>
|
|
3
20
|
<br>
|
|
4
|
-
<a target="_blank" href="https://
|
|
5
|
-
<a target="_blank" href="https://
|
|
6
|
-
<a target="_blank" href="https://
|
|
7
|
-
<a target="_blank" href="https://
|
|
8
|
-
<a target="_blank" href="https://github.
|
|
9
|
-
<a target="_blank" href="https://
|
|
10
|
-
<a target="_blank" href="https://
|
|
11
|
-
<a target="_blank" href="https://
|
|
12
|
-
<a target="_blank" href="https://
|
|
13
|
-
<a target="_blank" href="https://
|
|
14
|
-
<a target="_blank" href="https://
|
|
15
|
-
<a target="_blank" href="https://
|
|
16
|
-
<a target="_blank" href="https://
|
|
17
|
-
<a target="_blank" href="https://
|
|
18
|
-
<a target="_blank" href="https://
|
|
19
|
-
<a target="_blank" href="https://
|
|
20
|
-
<a target="_blank" href="https://
|
|
21
|
-
<a target="_blank" href="https://
|
|
22
|
-
<a target="_blank" href="https://
|
|
23
|
-
<a target="_blank" href="https://
|
|
24
|
-
<a target="_blank" href="https://
|
|
25
|
-
<a target="_blank" href="https://
|
|
26
|
-
<a target="_blank" href="https://
|
|
27
|
-
<a target="_blank" href="https://
|
|
28
|
-
<a target="_blank" href="https://
|
|
29
|
-
<a target="_blank" href="https://
|
|
30
|
-
<a target="_blank" href="https://
|
|
31
|
-
<a target="_blank" href="https://
|
|
32
|
-
<a target="_blank" href="https://
|
|
33
|
-
<a target="_blank" href="https://
|
|
34
|
-
<a target="_blank" href="https://
|
|
35
|
-
<a target="_blank" href="https://
|
|
36
|
-
<
|
|
21
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6766860898" title="Zipora: Zip/RAR/7Z Unarchiver"><img alt="Zipora: Zip/RAR/7Z Unarchiver" height="52" src="https://wangchujiang.com/appicon/zipora.png"></a>
|
|
22
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6758053530" title="Scap: Screenshot & Markup Edit for macOS"><img alt="Scap: Screenshot & Markup Edit" height="52" src="https://wangchujiang.com/appicon/scap.png"></a>
|
|
23
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6757317079" title="Screen Test for macOS"><img alt="Screen Test" height="52" src="https://wangchujiang.com/appicon/screen-test.png"></a>
|
|
24
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6755948110" title="Deskmark for macOS"><img alt="Deskmark" height="52" src="https://wangchujiang.com/appicon/deskmark.png"></a>
|
|
25
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6500434773" title="Keyzer for macOS"><img alt="Keyzer" height="52" src="https://wangchujiang.com/appicon/keyzer.png"></a>
|
|
26
|
+
<a target="_blank" href="https://github.com/jaywcjlove/vidwall-hub" title="Vidwall Hub for macOS"><img alt="Vidwall Hub" height="52" src="https://wangchujiang.com/appicon/vidwall-hub.png"></a>
|
|
27
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6752624705" title="VidCrop for macOS"><img alt="VidCrop" height="52" src="https://wangchujiang.com/appicon/vidcrop.png"></a>
|
|
28
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6747587746" title="Vidwall for macOS"><img alt="Vidwall" height="52" src="https://wangchujiang.com/appicon/vidwall.png"></a>
|
|
29
|
+
<a target="_blank" href="https://wangchujiang.com/mousio-hint/" title="Mousio Hint for macOS"><img alt="Mousio Hint" height="52" src="https://wangchujiang.com/appicon/mousio-hint.png"></a>
|
|
30
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6746747327" title="Mousio for macOS"><img alt="Mousio" height="52" src="https://wangchujiang.com/appicon/mousio.png"></a>
|
|
31
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6745227444" title="Musicer for macOS"><img alt="Musicer" height="52" src="https://wangchujiang.com/appicon/musicer.png"></a>
|
|
32
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6743841447" title="Audioer for macOS"><img alt="Audioer" height="52" src="https://wangchujiang.com/appicon/audioer.png"></a>
|
|
33
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6744690194" title="FileSentinel for macOS"><img alt="FileSentinel" height="52" src="https://wangchujiang.com/appicon/file-sentinel.png"></a>
|
|
34
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6743495172" title="FocusCursor for macOS"><img alt="FocusCursor" height="52" src="https://wangchujiang.com/appicon/focus-cursor.png"></a>
|
|
35
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6742680573" title="Videoer for macOS"><img alt="Videoer" height="52" src="https://wangchujiang.com/appicon/videoer.png"></a>
|
|
36
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6740425504" title="KeyClicker for macOS"><img alt="KeyClicker" height="52" src="https://wangchujiang.com/appicon/key-clicker.png"></a>
|
|
37
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6739052447" title="DayBar for macOS"><img alt="DayBar" height="52" src="https://wangchujiang.com/appicon/daybar.png"></a>
|
|
38
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6739444407" title="Iconed for macOS"><img alt="Iconed" height="52" src="https://wangchujiang.com/appicon/iconed.png"></a>
|
|
39
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6737160756" title="Menuist for macOS"><img alt="Menuist" height="52" src="https://wangchujiang.com/appicon/rightmenu-master.png"></a>
|
|
40
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6723903021" title="Paste Quick for macOS"><img alt="Quick RSS" height="52" src="https://wangchujiang.com/appicon/paste-quick.png"></a>
|
|
41
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6670696072&platform=mac" title="Quick RSS for macOS/iOS"><img alt="Quick RSS" height="52" src="https://wangchujiang.com/appicon/quick-rss.png"></a>
|
|
42
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6670167443" title="Web Serve for macOS"><img alt="Web Serve" height="52" src="https://wangchujiang.com/appicon/web-serve.png"></a>
|
|
43
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6503953628&platform=mac" title="Copybook Generator for macOS/iOS"><img alt="Copybook Generator" height="52" src="https://wangchujiang.com/appicon/copybook-generator.png"></a>
|
|
44
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6471227008&platform=mac" title="DevTutor for macOS/iOS"><img alt="DevTutor for SwiftUI" height="52" src="https://wangchujiang.com/appicon/devtutor.png"></a>
|
|
45
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6479819388&platform=mac" title="RegexMate for macOS/iOS"><img alt="RegexMate" height="52" src="https://wangchujiang.com/appicon/regex-mate.png"></a>
|
|
46
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6479194014&platform=mac" title="Time Passage for macOS/iOS"><img alt="Time Passage" height="52" src="https://wangchujiang.com/appicon/time-passage.png"></a>
|
|
47
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6478772538" title="IconizeFolder for macOS"><img alt="Iconize Folder" height="52" src="https://wangchujiang.com/appicon/iconize-folder.png"></a>
|
|
48
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6478511402&platform=mac" title="Textsound Saver for macOS/iOS"><img alt="Textsound Saver" height="52" src="https://wangchujiang.com/appicon/textsound-saver.png"></a>
|
|
49
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6476924627" title="Create Custom Symbols for macOS"><img alt="Create Custom Symbols" height="52" src="https://wangchujiang.com/appicon/create-custom-symbols.png"></a>
|
|
50
|
+
<a target="_blank" href="https://jaywcjlove.github.io/maslink/?id=6476452351" title="DevHub for macOS"><img alt="DevHub" height="52" src="https://wangchujiang.com/appicon/devhub.png"></a>
|
|
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
|
+
<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
|
+
<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>
|
|
37
54
|
</div>
|
|
38
55
|
<hr>
|
|
39
56
|
|
|
@@ -115,7 +132,6 @@ npm install @uiw/react-codemirror --save
|
|
|
115
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) |
|
|
116
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) |
|
|
117
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) |
|
|
118
|
-
| [`@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) |
|
|
119
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) |
|
|
120
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) |
|
|
121
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
|
}
|