@uiw/react-codemirror 4.8.1 → 4.9.2
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 +73 -5
- package/cjs/basicSetup.d.ts +65 -0
- package/cjs/basicSetup.js +119 -0
- package/cjs/basicSetup.js.map +49 -0
- package/cjs/index.d.ts +7 -1
- package/cjs/index.js +21 -8
- package/cjs/index.js.map +2 -2
- package/cjs/useCodeMirror.d.ts +1 -2
- package/cjs/useCodeMirror.js +11 -7
- package/cjs/useCodeMirror.js.map +2 -2
- package/dist/{codemirror.js → mdeditor.js} +66 -89
- package/dist/mdeditor.min.js +2 -0
- package/dist/{codemirror.min.js.LICENSE.txt → mdeditor.min.js.LICENSE.txt} +0 -0
- package/esm/basicSetup.d.ts +65 -0
- package/esm/basicSetup.js +103 -0
- package/esm/basicSetup.js.map +49 -0
- package/esm/index.d.ts +7 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +2 -2
- package/esm/useCodeMirror.d.ts +1 -2
- package/esm/useCodeMirror.js +6 -2
- package/esm/useCodeMirror.js.map +3 -3
- package/package.json +23 -87
- package/src/basicSetup.ts +136 -0
- package/src/index.tsx +7 -1
- package/src/useCodeMirror.ts +8 -3
- package/LICENSE +0 -21
- package/dist/codemirror.min.js +0 -2
- package/src/tsconfig.json +0 -7
|
@@ -12,7 +12,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
12
12
|
/******/ "use strict";
|
|
13
13
|
/******/ var __webpack_modules__ = ({
|
|
14
14
|
|
|
15
|
-
/***/
|
|
15
|
+
/***/ 298:
|
|
16
16
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
17
17
|
|
|
18
18
|
var __webpack_unused_export__;
|
|
@@ -31,13 +31,13 @@ function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&
|
|
|
31
31
|
|
|
32
32
|
/***/ }),
|
|
33
33
|
|
|
34
|
-
/***/
|
|
34
|
+
/***/ 605:
|
|
35
35
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
if (true) {
|
|
40
|
-
module.exports = __webpack_require__(
|
|
40
|
+
module.exports = __webpack_require__(298);
|
|
41
41
|
} else {}
|
|
42
42
|
|
|
43
43
|
|
|
@@ -147,11 +147,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
147
147
|
|
|
148
148
|
// EXPORTS
|
|
149
149
|
__webpack_require__.d(__webpack_exports__, {
|
|
150
|
+
"basicSetup": () => (/* reexport */ basicSetup),
|
|
150
151
|
"default": () => (/* binding */ src),
|
|
151
152
|
"useCodeMirror": () => (/* reexport */ useCodeMirror)
|
|
152
153
|
});
|
|
153
154
|
|
|
154
|
-
;// CONCATENATED MODULE:
|
|
155
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
155
156
|
function _defineProperty(obj, key, value) {
|
|
156
157
|
if (key in obj) {
|
|
157
158
|
Object.defineProperty(obj, key, {
|
|
@@ -166,7 +167,7 @@ function _defineProperty(obj, key, value) {
|
|
|
166
167
|
|
|
167
168
|
return obj;
|
|
168
169
|
}
|
|
169
|
-
;// CONCATENATED MODULE:
|
|
170
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js
|
|
170
171
|
|
|
171
172
|
|
|
172
173
|
function ownKeys(object, enumerableOnly) {
|
|
@@ -194,7 +195,7 @@ function _objectSpread2(target) {
|
|
|
194
195
|
|
|
195
196
|
return target;
|
|
196
197
|
}
|
|
197
|
-
;// CONCATENATED MODULE:
|
|
198
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
|
|
198
199
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
199
200
|
if (source == null) return {};
|
|
200
201
|
var target = {};
|
|
@@ -209,7 +210,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
209
210
|
|
|
210
211
|
return target;
|
|
211
212
|
}
|
|
212
|
-
;// CONCATENATED MODULE:
|
|
213
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
|
|
213
214
|
|
|
214
215
|
function _objectWithoutProperties(source, excluded) {
|
|
215
216
|
if (source == null) return {};
|
|
@@ -232,11 +233,11 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
232
233
|
// EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
|
|
233
234
|
var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__(787);
|
|
234
235
|
var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__PURE__*/__webpack_require__.n(external_root_React_commonjs2_react_commonjs_react_amd_react_);
|
|
235
|
-
;// CONCATENATED MODULE:
|
|
236
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
236
237
|
function _arrayWithHoles(arr) {
|
|
237
238
|
if (Array.isArray(arr)) return arr;
|
|
238
239
|
}
|
|
239
|
-
;// CONCATENATED MODULE:
|
|
240
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
240
241
|
function _iterableToArrayLimit(arr, i) {
|
|
241
242
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
242
243
|
|
|
@@ -266,7 +267,7 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
266
267
|
|
|
267
268
|
return _arr;
|
|
268
269
|
}
|
|
269
|
-
;// CONCATENATED MODULE:
|
|
270
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
270
271
|
function _arrayLikeToArray(arr, len) {
|
|
271
272
|
if (len == null || len > arr.length) len = arr.length;
|
|
272
273
|
|
|
@@ -276,7 +277,7 @@ function _arrayLikeToArray(arr, len) {
|
|
|
276
277
|
|
|
277
278
|
return arr2;
|
|
278
279
|
}
|
|
279
|
-
;// CONCATENATED MODULE:
|
|
280
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
280
281
|
|
|
281
282
|
function _unsupportedIterableToArray(o, minLen) {
|
|
282
283
|
if (!o) return;
|
|
@@ -286,11 +287,11 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
286
287
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
287
288
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
288
289
|
}
|
|
289
|
-
;// CONCATENATED MODULE:
|
|
290
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
|
290
291
|
function _nonIterableRest() {
|
|
291
292
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
292
293
|
}
|
|
293
|
-
;// CONCATENATED MODULE:
|
|
294
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
|
294
295
|
|
|
295
296
|
|
|
296
297
|
|
|
@@ -298,11 +299,11 @@ function _nonIterableRest() {
|
|
|
298
299
|
function _slicedToArray(arr, i) {
|
|
299
300
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
300
301
|
}
|
|
301
|
-
// EXTERNAL MODULE: external {"root":["CM","@codemirror/view"],"commonjs":"@codemirror/view","commonjs2":"@codemirror/view"}
|
|
302
|
-
var view_ = __webpack_require__(105);
|
|
303
302
|
// EXTERNAL MODULE: external {"root":["CM","@codemirror/state"],"commonjs":"@codemirror/state","commonjs2":"@codemirror/state"}
|
|
304
303
|
var state_ = __webpack_require__(242);
|
|
305
|
-
|
|
304
|
+
// EXTERNAL MODULE: external {"root":["CM","@codemirror/view"],"commonjs":"@codemirror/view","commonjs2":"@codemirror/view"}
|
|
305
|
+
var view_ = __webpack_require__(105);
|
|
306
|
+
;// CONCATENATED MODULE: ../node_modules/@lezer/common/dist/index.js
|
|
306
307
|
// FIXME profile adding a per-Tree TreeNode cache, validating it by
|
|
307
308
|
// parent pointer
|
|
308
309
|
/// The default maximum length of a `TreeBuffer` node.
|
|
@@ -2119,7 +2120,7 @@ function enterFragments(mounts, ranges) {
|
|
|
2119
2120
|
|
|
2120
2121
|
|
|
2121
2122
|
|
|
2122
|
-
;// CONCATENATED MODULE:
|
|
2123
|
+
;// CONCATENATED MODULE: ../node_modules/@lezer/highlight/dist/index.js
|
|
2123
2124
|
|
|
2124
2125
|
|
|
2125
2126
|
let nextTagID = 0;
|
|
@@ -2770,7 +2771,7 @@ const classHighlighter = tagHighlighter([
|
|
|
2770
2771
|
|
|
2771
2772
|
|
|
2772
2773
|
|
|
2773
|
-
;// CONCATENATED MODULE:
|
|
2774
|
+
;// CONCATENATED MODULE: ../node_modules/style-mod/src/style-mod.js
|
|
2774
2775
|
const C = "\u037c"
|
|
2775
2776
|
const COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C)
|
|
2776
2777
|
const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet")
|
|
@@ -2930,7 +2931,7 @@ class StyleSet {
|
|
|
2930
2931
|
// example to create a media query you can do `{"@media screen and
|
|
2931
2932
|
// (min-width: 400px)": {...}}`.
|
|
2932
2933
|
|
|
2933
|
-
;// CONCATENATED MODULE:
|
|
2934
|
+
;// CONCATENATED MODULE: ../node_modules/@codemirror/language/dist/index.js
|
|
2934
2935
|
|
|
2935
2936
|
|
|
2936
2937
|
|
|
@@ -5242,7 +5243,7 @@ function docID(data) {
|
|
|
5242
5243
|
|
|
5243
5244
|
|
|
5244
5245
|
|
|
5245
|
-
;// CONCATENATED MODULE:
|
|
5246
|
+
;// CONCATENATED MODULE: ../node_modules/@codemirror/commands/dist/index.js
|
|
5246
5247
|
|
|
5247
5248
|
|
|
5248
5249
|
|
|
@@ -6778,7 +6779,30 @@ const indentWithTab = { key: "Tab", run: indentMore, shift: indentLess };
|
|
|
6778
6779
|
|
|
6779
6780
|
|
|
6780
6781
|
|
|
6781
|
-
|
|
6782
|
+
// EXTERNAL MODULE: external {"root":["CM","@codemirror/theme-one-dark"],"commonjs":"@codemirror/theme-one-dark","commonjs2":"@codemirror/theme-one-dark"}
|
|
6783
|
+
var theme_one_dark_ = __webpack_require__(362);
|
|
6784
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
|
|
6785
|
+
|
|
6786
|
+
function _arrayWithoutHoles(arr) {
|
|
6787
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
6788
|
+
}
|
|
6789
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
|
|
6790
|
+
function _iterableToArray(iter) {
|
|
6791
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
6792
|
+
}
|
|
6793
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
|
|
6794
|
+
function _nonIterableSpread() {
|
|
6795
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6796
|
+
}
|
|
6797
|
+
;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
|
|
6798
|
+
|
|
6799
|
+
|
|
6800
|
+
|
|
6801
|
+
|
|
6802
|
+
function _toConsumableArray(arr) {
|
|
6803
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
6804
|
+
}
|
|
6805
|
+
;// CONCATENATED MODULE: ../node_modules/crelt/index.es.js
|
|
6782
6806
|
function crelt() {
|
|
6783
6807
|
var elt = arguments[0]
|
|
6784
6808
|
if (typeof elt == "string") elt = document.createElement(elt)
|
|
@@ -6808,7 +6832,7 @@ function add(elt, child) {
|
|
|
6808
6832
|
}
|
|
6809
6833
|
}
|
|
6810
6834
|
|
|
6811
|
-
;// CONCATENATED MODULE:
|
|
6835
|
+
;// CONCATENATED MODULE: ../node_modules/@codemirror/search/dist/index.js
|
|
6812
6836
|
|
|
6813
6837
|
|
|
6814
6838
|
|
|
@@ -7935,7 +7959,7 @@ const searchExtensions = [
|
|
|
7935
7959
|
|
|
7936
7960
|
|
|
7937
7961
|
|
|
7938
|
-
;// CONCATENATED MODULE:
|
|
7962
|
+
;// CONCATENATED MODULE: ../node_modules/@codemirror/autocomplete/dist/index.js
|
|
7939
7963
|
|
|
7940
7964
|
|
|
7941
7965
|
|
|
@@ -9115,6 +9139,14 @@ class Snippet {
|
|
|
9115
9139
|
positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
|
|
9116
9140
|
line = line.slice(0, m.index) + name + line.slice(m.index + m[0].length);
|
|
9117
9141
|
}
|
|
9142
|
+
for (let esc; esc = /([$#])\\{/.exec(line);) {
|
|
9143
|
+
line = line.slice(0, esc.index) + esc[1] + "{" + line.slice(esc.index + esc[0].length);
|
|
9144
|
+
for (let pos of positions)
|
|
9145
|
+
if (pos.line == lines.length && pos.from > esc.index) {
|
|
9146
|
+
pos.from--;
|
|
9147
|
+
pos.to--;
|
|
9148
|
+
}
|
|
9149
|
+
}
|
|
9118
9150
|
lines.push(line);
|
|
9119
9151
|
}
|
|
9120
9152
|
return new Snippet(lines, positions);
|
|
@@ -9198,6 +9230,11 @@ cursor out of the current field deactivates the fields.
|
|
|
9198
9230
|
The order of fields defaults to textual order, but you can add
|
|
9199
9231
|
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
|
9200
9232
|
a custom order.
|
|
9233
|
+
|
|
9234
|
+
To include a literal `${` or `#{` in your template, put a
|
|
9235
|
+
backslash after the dollar or hash and before the brace (`$\\{`).
|
|
9236
|
+
This will be removed and the sequence will not be interpreted as a
|
|
9237
|
+
placeholder.
|
|
9201
9238
|
*/
|
|
9202
9239
|
function snippet(template) {
|
|
9203
9240
|
let snippet = Snippet.parse(template);
|
|
@@ -9680,7 +9717,7 @@ function setSelectedCompletion(index) {
|
|
|
9680
9717
|
|
|
9681
9718
|
|
|
9682
9719
|
|
|
9683
|
-
;// CONCATENATED MODULE:
|
|
9720
|
+
;// CONCATENATED MODULE: ../node_modules/@codemirror/lint/dist/index.js
|
|
9684
9721
|
|
|
9685
9722
|
|
|
9686
9723
|
|
|
@@ -10414,16 +10451,7 @@ function lintGutter(config = {}) {
|
|
|
10414
10451
|
|
|
10415
10452
|
|
|
10416
10453
|
|
|
10417
|
-
;// CONCATENATED MODULE: ./
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10454
|
+
;// CONCATENATED MODULE: ./src/basicSetup.ts
|
|
10427
10455
|
/**
|
|
10428
10456
|
This is an extension value that just pulls together a number of
|
|
10429
10457
|
extensions that you might want in a basic editor. It is meant as a
|
|
@@ -10460,64 +10488,13 @@ once you decide you want to configure your editor more precisely,
|
|
|
10460
10488
|
you take this package's source (which is just a bunch of imports
|
|
10461
10489
|
and an array literal), copy it into your own code, and adjust it
|
|
10462
10490
|
as desired.
|
|
10463
|
-
*/
|
|
10464
|
-
const basicSetup = [
|
|
10465
|
-
/*@__PURE__*/(0,view_.lineNumbers)(),
|
|
10466
|
-
/*@__PURE__*/(0,view_.highlightActiveLineGutter)(),
|
|
10467
|
-
/*@__PURE__*/(0,view_.highlightSpecialChars)(),
|
|
10468
|
-
/*@__PURE__*/dist_history(),
|
|
10469
|
-
/*@__PURE__*/foldGutter(),
|
|
10470
|
-
/*@__PURE__*/(0,view_.drawSelection)(),
|
|
10471
|
-
/*@__PURE__*/(0,view_.dropCursor)(),
|
|
10472
|
-
/*@__PURE__*/state_.EditorState.allowMultipleSelections.of(true),
|
|
10473
|
-
/*@__PURE__*/indentOnInput(),
|
|
10474
|
-
/*@__PURE__*/syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
10475
|
-
/*@__PURE__*/bracketMatching(),
|
|
10476
|
-
/*@__PURE__*/closeBrackets(),
|
|
10477
|
-
/*@__PURE__*/autocompletion(),
|
|
10478
|
-
/*@__PURE__*/(0,view_.rectangularSelection)(),
|
|
10479
|
-
/*@__PURE__*/(0,view_.crosshairCursor)(),
|
|
10480
|
-
/*@__PURE__*/(0,view_.highlightActiveLine)(),
|
|
10481
|
-
/*@__PURE__*/highlightSelectionMatches(),
|
|
10482
|
-
/*@__PURE__*/view_.keymap.of([
|
|
10483
|
-
...closeBracketsKeymap,
|
|
10484
|
-
...defaultKeymap,
|
|
10485
|
-
...searchKeymap,
|
|
10486
|
-
...historyKeymap,
|
|
10487
|
-
...foldKeymap,
|
|
10488
|
-
...completionKeymap,
|
|
10489
|
-
...lintKeymap
|
|
10490
|
-
])
|
|
10491
|
-
];
|
|
10492
|
-
/**
|
|
10493
|
-
A minimal set of extensions to create a functional editor. Only
|
|
10494
|
-
includes [the default keymap](https://codemirror.net/6/docs/ref/#commands.defaultKeymap), [undo
|
|
10495
|
-
history](https://codemirror.net/6/docs/ref/#commands.history), [special character
|
|
10496
|
-
highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars), [custom selection
|
|
10497
|
-
drawing](https://codemirror.net/6/docs/ref/#view.drawSelection), and [default highlight
|
|
10498
|
-
style](https://codemirror.net/6/docs/ref/#language.defaultHighlightStyle).
|
|
10499
|
-
*/
|
|
10500
|
-
const minimalSetup = [
|
|
10501
|
-
/*@__PURE__*/(0,view_.highlightSpecialChars)(),
|
|
10502
|
-
/*@__PURE__*/dist_history(),
|
|
10503
|
-
/*@__PURE__*/(0,view_.drawSelection)(),
|
|
10504
|
-
/*@__PURE__*/syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
10505
|
-
/*@__PURE__*/view_.keymap.of([
|
|
10506
|
-
...defaultKeymap,
|
|
10507
|
-
...historyKeymap,
|
|
10508
|
-
])
|
|
10509
|
-
];
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
// EXTERNAL MODULE: external {"root":["CM","@codemirror/theme-one-dark"],"commonjs":"@codemirror/theme-one-dark","commonjs2":"@codemirror/theme-one-dark"}
|
|
10514
|
-
var theme_one_dark_ = __webpack_require__(362);
|
|
10491
|
+
*/var basicSetup=function basicSetup(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var keymaps=[];if(options.closeBracketsKeymap!==false){keymaps.push(_toConsumableArray(closeBracketsKeymap));}if(options.defaultKeymap!==false){keymaps.push(_toConsumableArray(defaultKeymap));}if(options.searchKeymap!==false){keymaps.push(_toConsumableArray(searchKeymap));}if(options.historyKeymap!==false){keymaps.push(_toConsumableArray(historyKeymap));}if(options.foldKeymap!==false){keymaps.push(_toConsumableArray(foldKeymap));}if(options.completionKeymap!==false){keymaps.push(_toConsumableArray(completionKeymap));}if(options.lintKeymap!==false){keymaps.push(_toConsumableArray(lintKeymap));}var extensions=[];if(options.lineNumbers!==false)extensions.push((0,view_.lineNumbers)());if(options.highlightActiveLineGutter!==false)extensions.push((0,view_.highlightActiveLineGutter)());if(options.highlightSpecialChars!==false)extensions.push((0,view_.highlightSpecialChars)());if(options.history!==false)extensions.push(dist_history());if(options.foldGutter!==false)extensions.push(foldGutter());if(options.drawSelection!==false)extensions.push((0,view_.drawSelection)());if(options.dropCursor!==false)extensions.push((0,view_.dropCursor)());if(options.allowMultipleSelections!==false)extensions.push(state_.EditorState.allowMultipleSelections.of(true));if(options.indentOnInput!==false)extensions.push(indentOnInput());if(options.syntaxHighlighting!==false)extensions.push(syntaxHighlighting(defaultHighlightStyle,{fallback:true}));if(options.bracketMatching!==false)extensions.push(bracketMatching());if(options.closeBrackets!==false)extensions.push(closeBrackets());if(options.autocompletion!==false)extensions.push(autocompletion());if(options.rectangularSelection!==false)extensions.push((0,view_.rectangularSelection)());if(options.crosshairCursor!==false)extensions.push((0,view_.crosshairCursor)());if(options.highlightActiveLine!==false)extensions.push((0,view_.highlightActiveLine)());if(options.highlightSelectionMatches!==false)extensions.push(highlightSelectionMatches());return[].concat(extensions,[view_.keymap.of(keymaps.flat())]).filter(Boolean);};
|
|
10515
10492
|
;// CONCATENATED MODULE: ./src/useCodeMirror.ts
|
|
10516
|
-
function useCodeMirror(props){var value=props.value,selection=props.selection,onChange=props.onChange,onUpdate=props.onUpdate,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,_props$height=props.height,height=_props$height===void 0?'':_props$height,_props$minHeight=props.minHeight,minHeight=_props$minHeight===void 0?'':_props$minHeight,_props$maxHeight=props.maxHeight,maxHeight=_props$maxHeight===void 0?'':_props$maxHeight,_props$placeholder=props.placeholder,placeholderStr=_props$placeholder===void 0?'':_props$placeholder,_props$width=props.width,width=_props$width===void 0?'':_props$width,_props$minWidth=props.minWidth,minWidth=_props$minWidth===void 0?'':_props$minWidth,_props$maxWidth=props.maxWidth,maxWidth=_props$maxWidth===void 0?'':_props$maxWidth,_props$editable=props.editable,editable=_props$editable===void 0?true:_props$editable,_props$readOnly=props.readOnly,readOnly=_props$readOnly===void 0?false:_props$readOnly,_props$indentWithTab=props.indentWithTab,defaultIndentWithTab=_props$indentWithTab===void 0?true:_props$indentWithTab,_props$basicSetup=props.basicSetup,defaultBasicSetup=_props$basicSetup===void 0?true:_props$basicSetup,root=props.root;var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(props.container),_useState2=_slicedToArray(_useState,2),container=_useState2[0],setContainer=_useState2[1];var _useState3=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState4=_slicedToArray(_useState3,2),view=_useState4[0],setView=_useState4[1];var _useState5=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState6=_slicedToArray(_useState5,2),state=_useState6[0],setState=_useState6[1];var defaultLightThemeOption=view_.EditorView.theme({'&':{backgroundColor:'#fff'}},{dark:false});var defaultThemeOption=view_.EditorView.theme({'&':{height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth}});var updateListener=view_.EditorView.updateListener.of(function(vu){if(vu.docChanged&&typeof onChange==='function'){var doc=vu.state.doc;var _value=doc.toString();onChange(_value,vu);}});var getExtensions=[updateListener,defaultThemeOption];if(defaultIndentWithTab){getExtensions.unshift(view_.keymap.of([indentWithTab]));}if(defaultBasicSetup){getExtensions.unshift(basicSetup);}if(placeholderStr){getExtensions.unshift((0,view_.placeholder)(placeholderStr));}switch(theme){case'light':getExtensions.push(defaultLightThemeOption);break;case'dark':getExtensions.push(theme_one_dark_.oneDark);break;default:getExtensions.push(theme);break;}if(editable===false){getExtensions.push(view_.EditorView.editable.of(false));}if(readOnly){getExtensions.push(state_.EditorState.readOnly.of(true));}if(onUpdate&&typeof onUpdate==='function'){getExtensions.push(view_.EditorView.updateListener.of(onUpdate));}getExtensions=getExtensions.concat(extensions);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(container&&!state){var stateCurrent=state_.EditorState.create({doc:value,selection:selection,extensions:getExtensions});setState(stateCurrent);if(!view){var viewCurrent=new view_.EditorView({state:stateCurrent,parent:container,root:root});setView(viewCurrent);}}return function(){if(view){setView(undefined);}};// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10493
|
+
function useCodeMirror(props){var value=props.value,selection=props.selection,onChange=props.onChange,onUpdate=props.onUpdate,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,_props$height=props.height,height=_props$height===void 0?'':_props$height,_props$minHeight=props.minHeight,minHeight=_props$minHeight===void 0?'':_props$minHeight,_props$maxHeight=props.maxHeight,maxHeight=_props$maxHeight===void 0?'':_props$maxHeight,_props$placeholder=props.placeholder,placeholderStr=_props$placeholder===void 0?'':_props$placeholder,_props$width=props.width,width=_props$width===void 0?'':_props$width,_props$minWidth=props.minWidth,minWidth=_props$minWidth===void 0?'':_props$minWidth,_props$maxWidth=props.maxWidth,maxWidth=_props$maxWidth===void 0?'':_props$maxWidth,_props$editable=props.editable,editable=_props$editable===void 0?true:_props$editable,_props$readOnly=props.readOnly,readOnly=_props$readOnly===void 0?false:_props$readOnly,_props$indentWithTab=props.indentWithTab,defaultIndentWithTab=_props$indentWithTab===void 0?true:_props$indentWithTab,_props$basicSetup=props.basicSetup,defaultBasicSetup=_props$basicSetup===void 0?true:_props$basicSetup,root=props.root;var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(props.container),_useState2=_slicedToArray(_useState,2),container=_useState2[0],setContainer=_useState2[1];var _useState3=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState4=_slicedToArray(_useState3,2),view=_useState4[0],setView=_useState4[1];var _useState5=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState6=_slicedToArray(_useState5,2),state=_useState6[0],setState=_useState6[1];var defaultLightThemeOption=view_.EditorView.theme({'&':{backgroundColor:'#fff'}},{dark:false});var defaultThemeOption=view_.EditorView.theme({'&':{height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth}});var updateListener=view_.EditorView.updateListener.of(function(vu){if(vu.docChanged&&typeof onChange==='function'){var doc=vu.state.doc;var _value=doc.toString();onChange(_value,vu);}});var getExtensions=[updateListener,defaultThemeOption];if(defaultIndentWithTab){getExtensions.unshift(view_.keymap.of([indentWithTab]));}if(defaultBasicSetup){if(typeof defaultBasicSetup==='boolean'){getExtensions.unshift(basicSetup());}else{getExtensions.unshift(basicSetup(defaultBasicSetup));}}if(placeholderStr){getExtensions.unshift((0,view_.placeholder)(placeholderStr));}switch(theme){case'light':getExtensions.push(defaultLightThemeOption);break;case'dark':getExtensions.push(theme_one_dark_.oneDark);break;default:getExtensions.push(theme);break;}if(editable===false){getExtensions.push(view_.EditorView.editable.of(false));}if(readOnly){getExtensions.push(state_.EditorState.readOnly.of(true));}if(onUpdate&&typeof onUpdate==='function'){getExtensions.push(view_.EditorView.updateListener.of(onUpdate));}getExtensions=getExtensions.concat(extensions);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(container&&!state){var stateCurrent=state_.EditorState.create({doc:value,selection:selection,extensions:getExtensions});setState(stateCurrent);if(!view){var viewCurrent=new view_.EditorView({state:stateCurrent,parent:container,root:root});setView(viewCurrent);}}return function(){if(view){setView(undefined);}};// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10517
10494
|
},[container,state]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){return function(){if(view){view.destroy();setView(undefined);}};},[view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(autoFocus&&view){view.focus();}},[autoFocus,view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var currentValue=view?view.state.doc.toString():'';if(view&&value!==currentValue){view.dispatch({changes:{from:0,to:currentValue.length,insert:value||''}});}},[value,view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(view){view.dispatch({effects:state_.StateEffect.reconfigure.of(getExtensions)});}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10518
10495
|
},[theme,extensions,height,minHeight,maxHeight,width,placeholderStr,minWidth,maxWidth,editable,defaultIndentWithTab,defaultBasicSetup]);return{state:state,setState:setState,view:view,setView:setView,container:container,setContainer:setContainer};}
|
|
10519
|
-
// EXTERNAL MODULE:
|
|
10520
|
-
var jsx_runtime = __webpack_require__(
|
|
10496
|
+
// EXTERNAL MODULE: ../node_modules/react/jsx-runtime.js
|
|
10497
|
+
var jsx_runtime = __webpack_require__(605);
|
|
10521
10498
|
;// CONCATENATED MODULE: ./src/index.tsx
|
|
10522
10499
|
var _excluded=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root"];var ReactCodeMirror=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef(function(props,ref){var className=props.className,_props$value=props.value,value=_props$value===void 0?'':_props$value,selection=props.selection,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,onChange=props.onChange,onUpdate=props.onUpdate,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,height=props.height,minHeight=props.minHeight,maxHeight=props.maxHeight,width=props.width,minWidth=props.minWidth,maxWidth=props.maxWidth,basicSetup=props.basicSetup,placeholder=props.placeholder,indentWithTab=props.indentWithTab,editable=props.editable,readOnly=props.readOnly,root=props.root,other=_objectWithoutProperties(props,_excluded);var editor=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var _useCodeMirror=useCodeMirror({container:editor.current,root:root,value:value,autoFocus:autoFocus,theme:theme,height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth,basicSetup:basicSetup,placeholder:placeholder,indentWithTab:indentWithTab,editable:editable,readOnly:readOnly,selection:selection,onChange:onChange,onUpdate:onUpdate,extensions:extensions}),state=_useCodeMirror.state,view=_useCodeMirror.view,container=_useCodeMirror.container,setContainer=_useCodeMirror.setContainer;(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return{editor:container,state:state,view:view};},[container,state,view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){setContainer(editor.current);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10523
10500
|
},[]);// check type of value
|