@uiw/react-codemirror 4.23.13 → 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.
- package/cjs/timeoutLatch.d.ts +22 -0
- package/cjs/timeoutLatch.js +118 -0
- package/cjs/useCodeMirror.js +48 -8
- package/dist/codemirror.js +238 -198
- package/dist/codemirror.min.js +1 -1
- package/esm/timeoutLatch.d.ts +22 -0
- package/esm/timeoutLatch.js +88 -0
- package/esm/useCodeMirror.js +44 -8
- package/package.json +2 -2
- package/src/timeoutLatch.ts +98 -0
- package/src/useCodeMirror.ts +38 -4
package/dist/codemirror.js
CHANGED
|
@@ -6008,6 +6008,242 @@ function enterFragments(mounts, ranges) {
|
|
|
6008
6008
|
|
|
6009
6009
|
|
|
6010
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
|
+
|
|
6011
6247
|
/***/ }),
|
|
6012
6248
|
|
|
6013
6249
|
/***/ 369:
|
|
@@ -10472,123 +10708,6 @@ var minimalSetup = function minimalSetup(options) {
|
|
|
10472
10708
|
|
|
10473
10709
|
/***/ }),
|
|
10474
10710
|
|
|
10475
|
-
/***/ 695:
|
|
10476
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
// EXPORTS
|
|
10480
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
10481
|
-
q: () => (/* binding */ useCodeMirror)
|
|
10482
|
-
});
|
|
10483
|
-
|
|
10484
|
-
;// ../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
10485
|
-
function _arrayLikeToArray(r, a) {
|
|
10486
|
-
(null == a || a > r.length) && (a = r.length);
|
|
10487
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
10488
|
-
return n;
|
|
10489
|
-
}
|
|
10490
|
-
|
|
10491
|
-
;// ../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
|
|
10492
|
-
|
|
10493
|
-
function _arrayWithoutHoles(r) {
|
|
10494
|
-
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
10495
|
-
}
|
|
10496
|
-
|
|
10497
|
-
;// ../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
|
|
10498
|
-
function _iterableToArray(r) {
|
|
10499
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
10500
|
-
}
|
|
10501
|
-
|
|
10502
|
-
;// ../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
10503
|
-
|
|
10504
|
-
function _unsupportedIterableToArray(r, a) {
|
|
10505
|
-
if (r) {
|
|
10506
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
10507
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
10508
|
-
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;
|
|
10509
|
-
}
|
|
10510
|
-
}
|
|
10511
|
-
|
|
10512
|
-
;// ../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
|
|
10513
|
-
function _nonIterableSpread() {
|
|
10514
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
10515
|
-
}
|
|
10516
|
-
|
|
10517
|
-
;// ../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
function _toConsumableArray(r) {
|
|
10523
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
10524
|
-
}
|
|
10525
|
-
|
|
10526
|
-
;// ../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
10527
|
-
function _arrayWithHoles(r) {
|
|
10528
|
-
if (Array.isArray(r)) return r;
|
|
10529
|
-
}
|
|
10530
|
-
|
|
10531
|
-
;// ../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
10532
|
-
function _iterableToArrayLimit(r, l) {
|
|
10533
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
10534
|
-
if (null != t) {
|
|
10535
|
-
var e,
|
|
10536
|
-
n,
|
|
10537
|
-
i,
|
|
10538
|
-
u,
|
|
10539
|
-
a = [],
|
|
10540
|
-
f = !0,
|
|
10541
|
-
o = !1;
|
|
10542
|
-
try {
|
|
10543
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
10544
|
-
if (Object(t) !== t) return;
|
|
10545
|
-
f = !1;
|
|
10546
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
10547
|
-
} catch (r) {
|
|
10548
|
-
o = !0, n = r;
|
|
10549
|
-
} finally {
|
|
10550
|
-
try {
|
|
10551
|
-
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
10552
|
-
} finally {
|
|
10553
|
-
if (o) throw n;
|
|
10554
|
-
}
|
|
10555
|
-
}
|
|
10556
|
-
return a;
|
|
10557
|
-
}
|
|
10558
|
-
}
|
|
10559
|
-
|
|
10560
|
-
;// ../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
|
10561
|
-
function _nonIterableRest() {
|
|
10562
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
10563
|
-
}
|
|
10564
|
-
|
|
10565
|
-
;// ../node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
function _slicedToArray(r, e) {
|
|
10571
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
10572
|
-
}
|
|
10573
|
-
|
|
10574
|
-
// EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
|
|
10575
|
-
var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__(442);
|
|
10576
|
-
// EXTERNAL MODULE: external {"root":["CM","@codemirror/state"],"commonjs":"@codemirror/state","commonjs2":"@codemirror/state"}
|
|
10577
|
-
var state_ = __webpack_require__(60);
|
|
10578
|
-
// EXTERNAL MODULE: external {"root":["CM","@codemirror/view"],"commonjs":"@codemirror/view","commonjs2":"@codemirror/view"}
|
|
10579
|
-
var view_ = __webpack_require__(730);
|
|
10580
|
-
// EXTERNAL MODULE: ./src/getDefaultExtensions.ts
|
|
10581
|
-
var getDefaultExtensions = __webpack_require__(89);
|
|
10582
|
-
// EXTERNAL MODULE: ./src/utils.ts
|
|
10583
|
-
var utils = __webpack_require__(369);
|
|
10584
|
-
;// ./src/useCodeMirror.ts
|
|
10585
|
-
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:
|
|
10586
|
-
// If transaction is market as remote we don't have to call `onChange` handler again
|
|
10587
|
-
!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
|
|
10588
|
-
},[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};}
|
|
10589
|
-
|
|
10590
|
-
/***/ }),
|
|
10591
|
-
|
|
10592
10711
|
/***/ 708:
|
|
10593
10712
|
/***/ ((module) => {
|
|
10594
10713
|
|
|
@@ -12379,85 +12498,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__742__;
|
|
|
12379
12498
|
/* harmony import */ var _codemirror_view__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_codemirror_view__WEBPACK_IMPORTED_MODULE_0__);
|
|
12380
12499
|
var defaultLightThemeOption=_codemirror_view__WEBPACK_IMPORTED_MODULE_0__.EditorView.theme({'&':{backgroundColor:'#fff'}},{dark:false});
|
|
12381
12500
|
|
|
12382
|
-
/***/ }),
|
|
12383
|
-
|
|
12384
|
-
/***/ 957:
|
|
12385
|
-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
12386
|
-
|
|
12387
|
-
|
|
12388
|
-
// EXPORTS
|
|
12389
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
12390
|
-
A: () => (/* binding */ _objectSpread2)
|
|
12391
|
-
});
|
|
12392
|
-
|
|
12393
|
-
;// ../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
12394
|
-
function _typeof(o) {
|
|
12395
|
-
"@babel/helpers - typeof";
|
|
12396
|
-
|
|
12397
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
12398
|
-
return typeof o;
|
|
12399
|
-
} : function (o) {
|
|
12400
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
12401
|
-
}, _typeof(o);
|
|
12402
|
-
}
|
|
12403
|
-
|
|
12404
|
-
;// ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
12405
|
-
|
|
12406
|
-
function toPrimitive(t, r) {
|
|
12407
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
12408
|
-
var e = t[Symbol.toPrimitive];
|
|
12409
|
-
if (void 0 !== e) {
|
|
12410
|
-
var i = e.call(t, r || "default");
|
|
12411
|
-
if ("object" != _typeof(i)) return i;
|
|
12412
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
12413
|
-
}
|
|
12414
|
-
return ("string" === r ? String : Number)(t);
|
|
12415
|
-
}
|
|
12416
|
-
|
|
12417
|
-
;// ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
function toPropertyKey(t) {
|
|
12421
|
-
var i = toPrimitive(t, "string");
|
|
12422
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
12423
|
-
}
|
|
12424
|
-
|
|
12425
|
-
;// ../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
12426
|
-
|
|
12427
|
-
function _defineProperty(e, r, t) {
|
|
12428
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
12429
|
-
value: t,
|
|
12430
|
-
enumerable: !0,
|
|
12431
|
-
configurable: !0,
|
|
12432
|
-
writable: !0
|
|
12433
|
-
}) : e[r] = t, e;
|
|
12434
|
-
}
|
|
12435
|
-
|
|
12436
|
-
;// ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js
|
|
12437
|
-
|
|
12438
|
-
function ownKeys(e, r) {
|
|
12439
|
-
var t = Object.keys(e);
|
|
12440
|
-
if (Object.getOwnPropertySymbols) {
|
|
12441
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
12442
|
-
r && (o = o.filter(function (r) {
|
|
12443
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
12444
|
-
})), t.push.apply(t, o);
|
|
12445
|
-
}
|
|
12446
|
-
return t;
|
|
12447
|
-
}
|
|
12448
|
-
function _objectSpread2(e) {
|
|
12449
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
12450
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
12451
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
12452
|
-
_defineProperty(e, r, t[r]);
|
|
12453
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
12454
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
12455
|
-
});
|
|
12456
|
-
}
|
|
12457
|
-
return e;
|
|
12458
|
-
}
|
|
12459
|
-
|
|
12460
|
-
|
|
12461
12501
|
/***/ })
|
|
12462
12502
|
|
|
12463
12503
|
/******/ });
|
|
@@ -12537,11 +12577,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12537
12577
|
/* harmony export */ minimalSetup: () => (/* reexport safe */ _uiw_codemirror_extensions_basic_setup__WEBPACK_IMPORTED_MODULE_5__.V),
|
|
12538
12578
|
/* harmony export */ useCodeMirror: () => (/* reexport safe */ _useCodeMirror__WEBPACK_IMPORTED_MODULE_1__.q)
|
|
12539
12579
|
/* harmony export */ });
|
|
12540
|
-
/* harmony import */ var _home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(
|
|
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);
|
|
12541
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);
|
|
12542
12582
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(442);
|
|
12543
12583
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
12544
|
-
/* harmony import */ var _useCodeMirror__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
12584
|
+
/* harmony import */ var _useCodeMirror__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(341);
|
|
12545
12585
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(742);
|
|
12546
12586
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__);
|
|
12547
12587
|
/* harmony import */ var _codemirror_view__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(730);
|