@uiw/react-codemirror 4.8.0 → 4.9.1

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.
@@ -32,8 +32,11 @@
32
32
  "setView",
33
33
  "state",
34
34
  "setState",
35
- "defaultThemeOption",
35
+ "defaultLightThemeOption",
36
36
  "EditorView",
37
+ "backgroundColor",
38
+ "dark",
39
+ "defaultThemeOption",
37
40
  "updateListener",
38
41
  "of",
39
42
  "vu",
@@ -44,7 +47,6 @@
44
47
  "unshift",
45
48
  "keymap",
46
49
  "push",
47
- "defaultLightThemeOption",
48
50
  "oneDark",
49
51
  "EditorState",
50
52
  "concat",
@@ -71,7 +73,7 @@
71
73
  "../src/useCodeMirror.ts"
72
74
  ],
73
75
  "sourcesContent": [
74
- "import { useEffect, useState } from 'react';\nimport { basicSetup } from 'codemirror';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { ReactCodeMirrorProps } from './';\nimport { defaultLightThemeOption } from './theme/light';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n readOnly = false,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n getExtensions.unshift(basicSetup);\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n if (readOnly) {\n getExtensions.push(EditorState.readOnly.of(true));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n return () => {\n if (view) {\n setView(undefined);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => {\n if (autoFocus && view) {\n view.focus();\n }\n }, [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
76
+ "import { useEffect, useState } from 'react';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { basicSetup } from './basicSetup';\nimport { ReactCodeMirrorProps } from '.';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n readOnly = false,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultLightThemeOption = EditorView.theme(\n {\n '&': {\n backgroundColor: '#fff',\n },\n },\n {\n dark: false,\n },\n );\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n if (typeof defaultBasicSetup === 'boolean') {\n getExtensions.unshift(basicSetup());\n } else {\n getExtensions.unshift(basicSetup(defaultBasicSetup));\n }\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n if (readOnly) {\n getExtensions.push(EditorState.readOnly.of(true));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n return () => {\n if (view) {\n setView(undefined);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => {\n if (autoFocus && view) {\n view.focus();\n }\n }, [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
75
77
  ],
76
- "mappings": ";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAMO,SAASA,aAAT,CAAuBC,KAAvB,EAA6C;EAClD,IACEC,KADF,GAoBID,KApBJ,CACEC,KADF;EAAA,IAEEC,SAFF,GAoBIF,KApBJ,CAEEE,SAFF;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CC,MAAM,EAAE7D,KAAK,IAAI;QAArD;MADG,CAAd;IAGD;EACF,CAPD,EAOG,CAACA,KAAD,EAAQyB,IAAR,CAPH;EASA,IAAAsB,gBAAA,EAAU,YAAM;IACd,IAAItB,IAAJ,EAAU;MACRA,IAAI,CAAC+B,QAAL,CAAc;QAAEM,OAAO,EAAEC,kBAAA,CAAYC,WAAZ,CAAwB7B,EAAxB,CAA2BK,aAA3B;MAAX,CAAd;IACD,CAHa,CAId;;EACD,CALD,EAKG,CACDlC,KADC,EAEDF,UAFC,EAGDG,MAHC,EAIDC,SAJC,EAKDC,SALC,EAMDG,KANC,EAODD,cAPC,EAQDE,QARC,EASDC,QATC,EAUDC,QAVC,EAWDG,oBAXC,EAYDE,iBAZC,CALH;EAoBA,OAAO;IAAEO,KAAK,EAALA,KAAF;IAASC,QAAQ,EAARA,QAAT;IAAmBH,IAAI,EAAJA,IAAnB;IAAyBC,OAAO,EAAPA,OAAzB;IAAkCH,SAAS,EAATA,SAAlC;IAA6CC,YAAY,EAAZA;EAA7C,CAAP;AACD"
77
79
  }
@@ -12,7 +12,7 @@ return /******/ (() => { // webpackBootstrap
12
12
  /******/ "use strict";
13
13
  /******/ var __webpack_modules__ = ({
14
14
 
15
- /***/ 638:
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
- /***/ 724:
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__(638);
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: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
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: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js
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: ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
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: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
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: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
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: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
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: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
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: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
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: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
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: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
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
- ;// CONCATENATED MODULE: ./node_modules/@lezer/common/dist/index.js
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: ./node_modules/@lezer/highlight/dist/index.js
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: ./node_modules/style-mod/src/style-mod.js
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: ./node_modules/@codemirror/language/dist/index.js
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: ./node_modules/@codemirror/commands/dist/index.js
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
- ;// CONCATENATED MODULE: ./node_modules/crelt/index.es.js
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: ./node_modules/@codemirror/search/dist/index.js
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: ./node_modules/@codemirror/autocomplete/dist/index.js
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: ./node_modules/@codemirror/lint/dist/index.js
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: ./node_modules/codemirror/dist/index.js
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,66 +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);
10515
- ;// CONCATENATED MODULE: ./src/theme/light.ts
10516
- var defaultLightThemeOption=view_.EditorView.theme({'&':{backgroundColor:'#fff'}},{dark:false});
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);};
10517
10492
  ;// CONCATENATED MODULE: ./src/useCodeMirror.ts
10518
- 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 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
10519
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
10520
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};}
10521
- // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
10522
- var jsx_runtime = __webpack_require__(724);
10496
+ // EXTERNAL MODULE: ../node_modules/react/jsx-runtime.js
10497
+ var jsx_runtime = __webpack_require__(605);
10523
10498
  ;// CONCATENATED MODULE: ./src/index.tsx
10524
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
10525
10500
  },[]);// check type of value