@uiw/react-codemirror 4.23.12 → 4.23.14

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.
@@ -1956,8 +1956,8 @@ service.
1956
1956
  const indentService = /*@__PURE__*/state_.Facet.define();
1957
1957
  /**
1958
1958
  Facet for overriding the unit by which indentation happens. Should
1959
- be a string consisting either entirely of the same whitespace
1960
- character. When not set, this defaults to 2 spaces.
1959
+ be a string consisting entirely of the same whitespace character.
1960
+ When not set, this defaults to 2 spaces.
1961
1961
  */
1962
1962
  const indentUnit = /*@__PURE__*/state_.Facet.define({
1963
1963
  combine: values => {
@@ -2151,7 +2151,8 @@ function syntaxIndentation(cx, ast, pos) {
2151
2151
  let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos);
2152
2152
  if (inner != stack.node) {
2153
2153
  let add = [];
2154
- for (let cur = inner; cur && !(cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
2154
+ for (let cur = inner; cur && !(cur.from < stack.node.from || cur.to > stack.node.to ||
2155
+ cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
2155
2156
  add.push(cur);
2156
2157
  for (let i = add.length - 1; i >= 0; i--)
2157
2158
  stack = { node: add[i], next: stack };
@@ -2732,7 +2733,7 @@ fold status indicator before foldable lines (which can be clicked
2732
2733
  to fold or unfold the line).
2733
2734
  */
2734
2735
  function foldGutter(config = {}) {
2735
- let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);
2736
+ let fullConfig = { ...foldGutterDefaults, ...config };
2736
2737
  let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);
2737
2738
  let markers = view_.ViewPlugin.fromClass(class {
2738
2739
  constructor(view) {
@@ -2767,7 +2768,9 @@ function foldGutter(config = {}) {
2767
2768
  initialSpacer() {
2768
2769
  return new FoldMarker(fullConfig, false);
2769
2770
  },
2770
- domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {
2771
+ domEventHandlers: {
2772
+ ...domEventHandlers,
2773
+ click: (view, line, event) => {
2771
2774
  if (domEventHandlers.click && domEventHandlers.click(view, line, event))
2772
2775
  return true;
2773
2776
  let folded = findFold(view.state, line.from, line.to);
@@ -2781,7 +2784,8 @@ function foldGutter(config = {}) {
2781
2784
  return true;
2782
2785
  }
2783
2786
  return false;
2784
- } })
2787
+ }
2788
+ }
2785
2789
  }),
2786
2790
  codeFolding()
2787
2791
  ];
@@ -6004,6 +6008,242 @@ function enterFragments(mounts, ranges) {
6004
6008
 
6005
6009
 
6006
6010
 
6011
+ /***/ }),
6012
+
6013
+ /***/ 236:
6014
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6015
+
6016
+
6017
+ // EXPORTS
6018
+ __webpack_require__.d(__webpack_exports__, {
6019
+ A: () => (/* binding */ toPropertyKey)
6020
+ });
6021
+
6022
+ ;// ../node_modules/@babel/runtime/helpers/esm/typeof.js
6023
+ function _typeof(o) {
6024
+ "@babel/helpers - typeof";
6025
+
6026
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6027
+ return typeof o;
6028
+ } : function (o) {
6029
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6030
+ }, _typeof(o);
6031
+ }
6032
+
6033
+ ;// ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
6034
+
6035
+ function toPrimitive(t, r) {
6036
+ if ("object" != _typeof(t) || !t) return t;
6037
+ var e = t[Symbol.toPrimitive];
6038
+ if (void 0 !== e) {
6039
+ var i = e.call(t, r || "default");
6040
+ if ("object" != _typeof(i)) return i;
6041
+ throw new TypeError("@@toPrimitive must return a primitive value.");
6042
+ }
6043
+ return ("string" === r ? String : Number)(t);
6044
+ }
6045
+
6046
+ ;// ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
6047
+
6048
+
6049
+ function toPropertyKey(t) {
6050
+ var i = toPrimitive(t, "string");
6051
+ return "symbol" == _typeof(i) ? i : i + "";
6052
+ }
6053
+
6054
+
6055
+ /***/ }),
6056
+
6057
+ /***/ 289:
6058
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6059
+
6060
+
6061
+ // EXPORTS
6062
+ __webpack_require__.d(__webpack_exports__, {
6063
+ A: () => (/* binding */ _objectSpread2)
6064
+ });
6065
+
6066
+ // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js + 2 modules
6067
+ var toPropertyKey = __webpack_require__(236);
6068
+ ;// ../node_modules/@babel/runtime/helpers/esm/defineProperty.js
6069
+
6070
+ function _defineProperty(e, r, t) {
6071
+ return (r = (0,toPropertyKey/* default */.A)(r)) in e ? Object.defineProperty(e, r, {
6072
+ value: t,
6073
+ enumerable: !0,
6074
+ configurable: !0,
6075
+ writable: !0
6076
+ }) : e[r] = t, e;
6077
+ }
6078
+
6079
+ ;// ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js
6080
+
6081
+ function ownKeys(e, r) {
6082
+ var t = Object.keys(e);
6083
+ if (Object.getOwnPropertySymbols) {
6084
+ var o = Object.getOwnPropertySymbols(e);
6085
+ r && (o = o.filter(function (r) {
6086
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
6087
+ })), t.push.apply(t, o);
6088
+ }
6089
+ return t;
6090
+ }
6091
+ function _objectSpread2(e) {
6092
+ for (var r = 1; r < arguments.length; r++) {
6093
+ var t = null != arguments[r] ? arguments[r] : {};
6094
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
6095
+ _defineProperty(e, r, t[r]);
6096
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
6097
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6098
+ });
6099
+ }
6100
+ return e;
6101
+ }
6102
+
6103
+
6104
+ /***/ }),
6105
+
6106
+ /***/ 341:
6107
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6108
+
6109
+
6110
+ // EXPORTS
6111
+ __webpack_require__.d(__webpack_exports__, {
6112
+ q: () => (/* binding */ useCodeMirror)
6113
+ });
6114
+
6115
+ ;// ../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
6116
+ function _arrayLikeToArray(r, a) {
6117
+ (null == a || a > r.length) && (a = r.length);
6118
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
6119
+ return n;
6120
+ }
6121
+
6122
+ ;// ../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
6123
+
6124
+ function _arrayWithoutHoles(r) {
6125
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
6126
+ }
6127
+
6128
+ ;// ../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
6129
+ function _iterableToArray(r) {
6130
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
6131
+ }
6132
+
6133
+ ;// ../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
6134
+
6135
+ function _unsupportedIterableToArray(r, a) {
6136
+ if (r) {
6137
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
6138
+ var t = {}.toString.call(r).slice(8, -1);
6139
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
6140
+ }
6141
+ }
6142
+
6143
+ ;// ../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
6144
+ function _nonIterableSpread() {
6145
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6146
+ }
6147
+
6148
+ ;// ../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
6149
+
6150
+
6151
+
6152
+
6153
+ function _toConsumableArray(r) {
6154
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
6155
+ }
6156
+
6157
+ ;// ../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
6158
+ function _arrayWithHoles(r) {
6159
+ if (Array.isArray(r)) return r;
6160
+ }
6161
+
6162
+ ;// ../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
6163
+ function _iterableToArrayLimit(r, l) {
6164
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
6165
+ if (null != t) {
6166
+ var e,
6167
+ n,
6168
+ i,
6169
+ u,
6170
+ a = [],
6171
+ f = !0,
6172
+ o = !1;
6173
+ try {
6174
+ if (i = (t = t.call(r)).next, 0 === l) {
6175
+ if (Object(t) !== t) return;
6176
+ f = !1;
6177
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6178
+ } catch (r) {
6179
+ o = !0, n = r;
6180
+ } finally {
6181
+ try {
6182
+ if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
6183
+ } finally {
6184
+ if (o) throw n;
6185
+ }
6186
+ }
6187
+ return a;
6188
+ }
6189
+ }
6190
+
6191
+ ;// ../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
6192
+ function _nonIterableRest() {
6193
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6194
+ }
6195
+
6196
+ ;// ../node_modules/@babel/runtime/helpers/esm/slicedToArray.js
6197
+
6198
+
6199
+
6200
+
6201
+ function _slicedToArray(r, e) {
6202
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
6203
+ }
6204
+
6205
+ // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
6206
+ var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__(442);
6207
+ // EXTERNAL MODULE: external {"root":["CM","@codemirror/state"],"commonjs":"@codemirror/state","commonjs2":"@codemirror/state"}
6208
+ var state_ = __webpack_require__(60);
6209
+ // EXTERNAL MODULE: external {"root":["CM","@codemirror/view"],"commonjs":"@codemirror/view","commonjs2":"@codemirror/view"}
6210
+ var view_ = __webpack_require__(730);
6211
+ // EXTERNAL MODULE: ./src/getDefaultExtensions.ts
6212
+ var getDefaultExtensions = __webpack_require__(89);
6213
+ // EXTERNAL MODULE: ./src/utils.ts
6214
+ var utils = __webpack_require__(369);
6215
+ ;// ../node_modules/@babel/runtime/helpers/esm/classCallCheck.js
6216
+ function _classCallCheck(a, n) {
6217
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
6218
+ }
6219
+
6220
+ // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js + 2 modules
6221
+ var toPropertyKey = __webpack_require__(236);
6222
+ ;// ../node_modules/@babel/runtime/helpers/esm/createClass.js
6223
+
6224
+ function _defineProperties(e, r) {
6225
+ for (var t = 0; t < r.length; t++) {
6226
+ var o = r[t];
6227
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, (0,toPropertyKey/* default */.A)(o.key), o);
6228
+ }
6229
+ }
6230
+ function _createClass(e, r, t) {
6231
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
6232
+ writable: !1
6233
+ }), e;
6234
+ }
6235
+
6236
+ ;// ./src/timeoutLatch.ts
6237
+ // Setting / Unsetting timeouts for every keystroke was a significant overhead
6238
+ // Inspired from https://github.com/iostreamer-X/timeout-latch
6239
+ var TimeoutLatch=/*#__PURE__*/function(){function TimeoutLatch(callback,timeoutMS){_classCallCheck(this,TimeoutLatch);this.timeLeftMS=void 0;this.timeoutMS=void 0;this.isCancelled=false;this.isTimeExhausted=false;this.callbacks=[];this.timeLeftMS=timeoutMS;this.timeoutMS=timeoutMS;this.callbacks.push(callback);}return _createClass(TimeoutLatch,[{key:"tick",value:function tick(){if(!this.isCancelled&&!this.isTimeExhausted){this.timeLeftMS--;if(this.timeLeftMS<=0){this.isTimeExhausted=true;var callbacks=this.callbacks.slice();this.callbacks.length=0;callbacks.forEach(function(callback){try{callback();}catch(error){console.error('TimeoutLatch callback error:',error);}});}}}},{key:"cancel",value:function cancel(){this.isCancelled=true;this.callbacks.length=0;}},{key:"reset",value:function reset(){this.timeLeftMS=this.timeoutMS;this.isCancelled=false;this.isTimeExhausted=false;}},{key:"isDone",get:function get(){return this.isCancelled||this.isTimeExhausted;}}]);}();var Scheduler=/*#__PURE__*/function(){function Scheduler(){_classCallCheck(this,Scheduler);this.interval=null;this.latches=new Set();}return _createClass(Scheduler,[{key:"add",value:function add(latch){this.latches.add(latch);this.start();}},{key:"remove",value:function remove(latch){this.latches["delete"](latch);if(this.latches.size===0){this.stop();}}},{key:"start",value:function start(){var _this=this;if(this.interval===null){this.interval=setInterval(function(){_this.latches.forEach(function(latch){latch.tick();if(latch.isDone){_this.remove(latch);}});},1);}}},{key:"stop",value:function stop(){if(this.interval!==null){clearInterval(this.interval);this.interval=null;}}}]);}();var globalScheduler=null;var getScheduler=function getScheduler(){if(typeof window==='undefined'){return new Scheduler();}if(!globalScheduler){globalScheduler=new Scheduler();}return globalScheduler;};
6240
+ ;// ./src/useCodeMirror.ts
6241
+ var External=state_.Annotation.define();var TYPING_TIMOUT=200;// ms
6242
+ var emptyExtensions=[];function useCodeMirror(props){var value=props.value,selection=props.selection,onChange=props.onChange,onStatistics=props.onStatistics,onCreateEditor=props.onCreateEditor,onUpdate=props.onUpdate,_props$extensions=props.extensions,extensions=_props$extensions===void 0?emptyExtensions:_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?null:_props$height,_props$minHeight=props.minHeight,minHeight=_props$minHeight===void 0?null:_props$minHeight,_props$maxHeight=props.maxHeight,maxHeight=_props$maxHeight===void 0?null:_props$maxHeight,_props$width=props.width,width=_props$width===void 0?null:_props$width,_props$minWidth=props.minWidth,minWidth=_props$minWidth===void 0?null:_props$minWidth,_props$maxWidth=props.maxWidth,maxWidth=_props$maxWidth===void 0?null:_props$maxWidth,_props$placeholder=props.placeholder,placeholderStr=_props$placeholder===void 0?'':_props$placeholder,_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,initialState=props.initialState;var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_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 typingLatch=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(function(){return{current:null};})[0];var pendingUpdate=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(function(){return{current:null};})[0];var defaultThemeOption=view_.EditorView.theme({'&':{height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth},'& .cm-scroller':{height:'100% !important'}});var updateListener=view_.EditorView.updateListener.of(function(vu){if(vu.docChanged&&typeof onChange==='function'&&// Fix echoing of the remote changes:
6243
+ // If transaction is market as remote we don't have to call `onChange` handler again
6244
+ !vu.transactions.some(function(tr){return tr.annotation(External);})){if(typingLatch.current){typingLatch.current.reset();}else{typingLatch.current=new TimeoutLatch(function(){if(pendingUpdate.current){var forceUpdate=pendingUpdate.current;pendingUpdate.current=null;forceUpdate();}typingLatch.current=null;},TYPING_TIMOUT);getScheduler().add(typingLatch.current);}var doc=vu.state.doc;var _value=doc.toString();onChange(_value,vu);}onStatistics&&onStatistics((0,utils/* getStatistics */.m)(vu));});var defaultExtensions=(0,getDefaultExtensions.getDefaultExtensions)({theme:theme,editable:editable,readOnly:readOnly,placeholder:placeholderStr,indentWithTab:defaultIndentWithTab,basicSetup:defaultBasicSetup});var getExtensions=[updateListener,defaultThemeOption].concat(_toConsumableArray(defaultExtensions));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_.useLayoutEffect)(function(){if(container&&!state){var config={doc:value,selection:selection,extensions:getExtensions};var stateCurrent=initialState?state_.EditorState.fromJSON(initialState.json,config,initialState.fields):state_.EditorState.create(config);setState(stateCurrent);if(!view){var viewCurrent=new view_.EditorView({state:stateCurrent,parent:container,root:root});setView(viewCurrent);onCreateEditor&&onCreateEditor(viewCurrent,stateCurrent);}}return function(){if(view){setState(undefined);setView(undefined);}};},[container,state]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(props.container){setContainer(props.container);}},[props.container]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){return function(){if(view){view.destroy();setView(undefined);}if(typingLatch.current){typingLatch.current.cancel();typingLatch.current=null;}};},[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(){if(view){view.dispatch({effects:state_.StateEffect.reconfigure.of(getExtensions)});}// eslint-disable-next-line react-hooks/exhaustive-deps
6245
+ },[theme,extensions,height,minHeight,maxHeight,width,minWidth,maxWidth,placeholderStr,editable,readOnly,defaultIndentWithTab,defaultBasicSetup,onChange,onUpdate]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(value===undefined){return;}var currentValue=view?view.state.doc.toString():'';if(view&&value!==currentValue){var isTyping=typingLatch.current&&!typingLatch.current.isDone;var forceUpdate=function forceUpdate(){if(view&&value!==view.state.doc.toString()){view.dispatch({changes:{from:0,to:view.state.doc.toString().length,insert:value||''},annotations:[External.of(true)]});}};if(!isTyping){forceUpdate();}else{pendingUpdate.current=forceUpdate;}}},[value,view]);return{state:state,setState:setState,view:view,setView:setView,container:container,setContainer:setContainer};}
6246
+
6007
6247
  /***/ }),
6008
6248
 
6009
6249
  /***/ 369:
@@ -7065,14 +7305,16 @@ const replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {
7065
7305
  next = query.nextMatch(state, next.from, next.to);
7066
7306
  effects.push(view_.EditorView.announce.of(state.phrase("replaced match on line $", state.doc.lineAt(from).number) + "."));
7067
7307
  }
7308
+ let changeSet = view.state.changes(changes);
7068
7309
  if (next) {
7069
- let off = changes.length == 0 || changes[0].from >= match.to ? 0 : match.to - match.from - replacement.length;
7070
- selection = state_.EditorSelection.single(next.from - off, next.to - off);
7310
+ selection = state_.EditorSelection.single(next.from, next.to).map(changeSet);
7071
7311
  effects.push(announceMatch(view, next));
7072
7312
  effects.push(state.facet(searchConfigFacet).scrollToMatch(selection.main, view));
7073
7313
  }
7074
7314
  view.dispatch({
7075
- changes, selection, effects,
7315
+ changes: changeSet,
7316
+ selection,
7317
+ effects,
7076
7318
  userEvent: "input.replace"
7077
7319
  });
7078
7320
  return true;
@@ -10466,123 +10708,6 @@ var minimalSetup = function minimalSetup(options) {
10466
10708
 
10467
10709
  /***/ }),
10468
10710
 
10469
- /***/ 695:
10470
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
10471
-
10472
-
10473
- // EXPORTS
10474
- __webpack_require__.d(__webpack_exports__, {
10475
- q: () => (/* binding */ useCodeMirror)
10476
- });
10477
-
10478
- ;// ../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
10479
- function _arrayLikeToArray(r, a) {
10480
- (null == a || a > r.length) && (a = r.length);
10481
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10482
- return n;
10483
- }
10484
-
10485
- ;// ../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
10486
-
10487
- function _arrayWithoutHoles(r) {
10488
- if (Array.isArray(r)) return _arrayLikeToArray(r);
10489
- }
10490
-
10491
- ;// ../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
10492
- function _iterableToArray(r) {
10493
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
10494
- }
10495
-
10496
- ;// ../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
10497
-
10498
- function _unsupportedIterableToArray(r, a) {
10499
- if (r) {
10500
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
10501
- var t = {}.toString.call(r).slice(8, -1);
10502
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
10503
- }
10504
- }
10505
-
10506
- ;// ../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
10507
- function _nonIterableSpread() {
10508
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10509
- }
10510
-
10511
- ;// ../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
10512
-
10513
-
10514
-
10515
-
10516
- function _toConsumableArray(r) {
10517
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
10518
- }
10519
-
10520
- ;// ../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
10521
- function _arrayWithHoles(r) {
10522
- if (Array.isArray(r)) return r;
10523
- }
10524
-
10525
- ;// ../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
10526
- function _iterableToArrayLimit(r, l) {
10527
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
10528
- if (null != t) {
10529
- var e,
10530
- n,
10531
- i,
10532
- u,
10533
- a = [],
10534
- f = !0,
10535
- o = !1;
10536
- try {
10537
- if (i = (t = t.call(r)).next, 0 === l) {
10538
- if (Object(t) !== t) return;
10539
- f = !1;
10540
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
10541
- } catch (r) {
10542
- o = !0, n = r;
10543
- } finally {
10544
- try {
10545
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
10546
- } finally {
10547
- if (o) throw n;
10548
- }
10549
- }
10550
- return a;
10551
- }
10552
- }
10553
-
10554
- ;// ../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
10555
- function _nonIterableRest() {
10556
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10557
- }
10558
-
10559
- ;// ../node_modules/@babel/runtime/helpers/esm/slicedToArray.js
10560
-
10561
-
10562
-
10563
-
10564
- function _slicedToArray(r, e) {
10565
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
10566
- }
10567
-
10568
- // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
10569
- var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__(442);
10570
- // EXTERNAL MODULE: external {"root":["CM","@codemirror/state"],"commonjs":"@codemirror/state","commonjs2":"@codemirror/state"}
10571
- var state_ = __webpack_require__(60);
10572
- // EXTERNAL MODULE: external {"root":["CM","@codemirror/view"],"commonjs":"@codemirror/view","commonjs2":"@codemirror/view"}
10573
- var view_ = __webpack_require__(730);
10574
- // EXTERNAL MODULE: ./src/getDefaultExtensions.ts
10575
- var getDefaultExtensions = __webpack_require__(89);
10576
- // EXTERNAL MODULE: ./src/utils.ts
10577
- var utils = __webpack_require__(369);
10578
- ;// ./src/useCodeMirror.ts
10579
- var External=state_.Annotation.define();var emptyExtensions=[];function useCodeMirror(props){var value=props.value,selection=props.selection,onChange=props.onChange,onStatistics=props.onStatistics,onCreateEditor=props.onCreateEditor,onUpdate=props.onUpdate,_props$extensions=props.extensions,extensions=_props$extensions===void 0?emptyExtensions:_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?null:_props$height,_props$minHeight=props.minHeight,minHeight=_props$minHeight===void 0?null:_props$minHeight,_props$maxHeight=props.maxHeight,maxHeight=_props$maxHeight===void 0?null:_props$maxHeight,_props$width=props.width,width=_props$width===void 0?null:_props$width,_props$minWidth=props.minWidth,minWidth=_props$minWidth===void 0?null:_props$minWidth,_props$maxWidth=props.maxWidth,maxWidth=_props$maxWidth===void 0?null:_props$maxWidth,_props$placeholder=props.placeholder,placeholderStr=_props$placeholder===void 0?'':_props$placeholder,_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,initialState=props.initialState;var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_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},'& .cm-scroller':{height:'100% !important'}});var updateListener=view_.EditorView.updateListener.of(function(vu){if(vu.docChanged&&typeof onChange==='function'&&// Fix echoing of the remote changes:
10580
- // If transaction is market as remote we don't have to call `onChange` handler again
10581
- !vu.transactions.some(function(tr){return tr.annotation(External);})){var doc=vu.state.doc;var _value=doc.toString();onChange(_value,vu);}onStatistics&&onStatistics((0,utils/* getStatistics */.m)(vu));});var defaultExtensions=(0,getDefaultExtensions.getDefaultExtensions)({theme:theme,editable:editable,readOnly:readOnly,placeholder:placeholderStr,indentWithTab:defaultIndentWithTab,basicSetup:defaultBasicSetup});var getExtensions=[updateListener,defaultThemeOption].concat(_toConsumableArray(defaultExtensions));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_.useLayoutEffect)(function(){if(container&&!state){var config={doc:value,selection:selection,extensions:getExtensions};var stateCurrent=initialState?state_.EditorState.fromJSON(initialState.json,config,initialState.fields):state_.EditorState.create(config);setState(stateCurrent);if(!view){var viewCurrent=new view_.EditorView({state:stateCurrent,parent:container,root:root});setView(viewCurrent);onCreateEditor&&onCreateEditor(viewCurrent,stateCurrent);}}return function(){if(view){setState(undefined);setView(undefined);}};},[container,state]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(props.container){setContainer(props.container);}},[props.container]);(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(){if(view){view.dispatch({effects:state_.StateEffect.reconfigure.of(getExtensions)});}// eslint-disable-next-line react-hooks/exhaustive-deps
10582
- },[theme,extensions,height,minHeight,maxHeight,width,minWidth,maxWidth,placeholderStr,editable,readOnly,defaultIndentWithTab,defaultBasicSetup,onChange,onUpdate]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(value===undefined){return;}var currentValue=view?view.state.doc.toString():'';if(view&&value!==currentValue){view.dispatch({changes:{from:0,to:currentValue.length,insert:value||''},annotations:[External.of(true)]});}},[value,view]);return{state:state,setState:setState,view:view,setView:setView,container:container,setContainer:setContainer};}
10583
-
10584
- /***/ }),
10585
-
10586
10711
  /***/ 708:
10587
10712
  /***/ ((module) => {
10588
10713
 
@@ -12373,85 +12498,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__742__;
12373
12498
  /* harmony import */ var _codemirror_view__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_codemirror_view__WEBPACK_IMPORTED_MODULE_0__);
12374
12499
  var defaultLightThemeOption=_codemirror_view__WEBPACK_IMPORTED_MODULE_0__.EditorView.theme({'&':{backgroundColor:'#fff'}},{dark:false});
12375
12500
 
12376
- /***/ }),
12377
-
12378
- /***/ 957:
12379
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12380
-
12381
-
12382
- // EXPORTS
12383
- __webpack_require__.d(__webpack_exports__, {
12384
- A: () => (/* binding */ _objectSpread2)
12385
- });
12386
-
12387
- ;// ../node_modules/@babel/runtime/helpers/esm/typeof.js
12388
- function _typeof(o) {
12389
- "@babel/helpers - typeof";
12390
-
12391
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
12392
- return typeof o;
12393
- } : function (o) {
12394
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
12395
- }, _typeof(o);
12396
- }
12397
-
12398
- ;// ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
12399
-
12400
- function toPrimitive(t, r) {
12401
- if ("object" != _typeof(t) || !t) return t;
12402
- var e = t[Symbol.toPrimitive];
12403
- if (void 0 !== e) {
12404
- var i = e.call(t, r || "default");
12405
- if ("object" != _typeof(i)) return i;
12406
- throw new TypeError("@@toPrimitive must return a primitive value.");
12407
- }
12408
- return ("string" === r ? String : Number)(t);
12409
- }
12410
-
12411
- ;// ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
12412
-
12413
-
12414
- function toPropertyKey(t) {
12415
- var i = toPrimitive(t, "string");
12416
- return "symbol" == _typeof(i) ? i : i + "";
12417
- }
12418
-
12419
- ;// ../node_modules/@babel/runtime/helpers/esm/defineProperty.js
12420
-
12421
- function _defineProperty(e, r, t) {
12422
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
12423
- value: t,
12424
- enumerable: !0,
12425
- configurable: !0,
12426
- writable: !0
12427
- }) : e[r] = t, e;
12428
- }
12429
-
12430
- ;// ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js
12431
-
12432
- function ownKeys(e, r) {
12433
- var t = Object.keys(e);
12434
- if (Object.getOwnPropertySymbols) {
12435
- var o = Object.getOwnPropertySymbols(e);
12436
- r && (o = o.filter(function (r) {
12437
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
12438
- })), t.push.apply(t, o);
12439
- }
12440
- return t;
12441
- }
12442
- function _objectSpread2(e) {
12443
- for (var r = 1; r < arguments.length; r++) {
12444
- var t = null != arguments[r] ? arguments[r] : {};
12445
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
12446
- _defineProperty(e, r, t[r]);
12447
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
12448
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
12449
- });
12450
- }
12451
- return e;
12452
- }
12453
-
12454
-
12455
12501
  /***/ })
12456
12502
 
12457
12503
  /******/ });
@@ -12531,11 +12577,11 @@ __webpack_require__.r(__webpack_exports__);
12531
12577
  /* harmony export */ minimalSetup: () => (/* reexport safe */ _uiw_codemirror_extensions_basic_setup__WEBPACK_IMPORTED_MODULE_5__.V),
12532
12578
  /* harmony export */ useCodeMirror: () => (/* reexport safe */ _useCodeMirror__WEBPACK_IMPORTED_MODULE_1__.q)
12533
12579
  /* harmony export */ });
12534
- /* harmony import */ var _home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(957);
12580
+ /* harmony import */ var _home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(289);
12535
12581
  /* harmony import */ var _home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(644);
12536
12582
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(442);
12537
12583
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
12538
- /* harmony import */ var _useCodeMirror__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(695);
12584
+ /* harmony import */ var _useCodeMirror__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(341);
12539
12585
  /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(742);
12540
12586
  /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__);
12541
12587
  /* harmony import */ var _codemirror_view__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(730);