x-star-editor 0.6.8 → 0.6.9

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.
@@ -21,7 +21,8 @@ var stateReducer = function stateReducer(_ref, action) {
21
21
  switch (action.type) {
22
22
  case 'insert':
23
23
  {
24
- var text = action.payload.text.replace(/\r\n?/g, '\n');
24
+ var _action$payload, _action$payload$text;
25
+ var text = ((_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$text = _action$payload.text) === null || _action$payload$text === void 0 ? void 0 : _action$payload$text.replace(/\r\n?/g, '\n')) || '';
25
26
  return {
26
27
  sourceCode: "".concat(before).concat(text).concat(after),
27
28
  selection: createSelection(startOffset + text.length)
@@ -93,10 +94,10 @@ var stateReducer = function stateReducer(_ref, action) {
93
94
  }
94
95
  case 'code':
95
96
  {
96
- var _action$payload = action.payload,
97
- lang = _action$payload.lang,
98
- value = _action$payload.value,
99
- showLineNumbers = _action$payload.showLineNumbers;
97
+ var _action$payload2 = action.payload,
98
+ lang = _action$payload2.lang,
99
+ value = _action$payload2.value,
100
+ showLineNumbers = _action$payload2.showLineNumbers;
100
101
  var _startOffset = lineEndOffset + lang.length + (showLineNumbers ? 21 : 5);
101
102
  return {
102
103
  sourceCode: "".concat(sourceCode.slice(0, lineEndOffset), "\n```").concat(lang).concat(showLineNumbers ? ' showLineNumbers' : '', "\n").concat(value, "\n```\n").concat(lineAfter),
@@ -142,10 +143,10 @@ var stateReducer = function stateReducer(_ref, action) {
142
143
  case 'image':
143
144
  case 'link':
144
145
  {
145
- var _action$payload2 = action.payload,
146
- _type = _action$payload2.type,
147
- url = _action$payload2.url,
148
- description = _action$payload2.description;
146
+ var _action$payload3 = action.payload,
147
+ _type = _action$payload3.type,
148
+ url = _action$payload3.url,
149
+ description = _action$payload3.description;
149
150
  return {
150
151
  sourceCode: "".concat(before).concat(_type === 'image' ? '!' : '', "[").concat(description, "](").concat(url, ")").concat(after),
151
152
  selection: createSelection(startOffset + url.length + description.length + 4 + (_type === 'image' ? 1 : 0))
@@ -198,9 +199,9 @@ var stateReducer = function stateReducer(_ref, action) {
198
199
  }
199
200
  case 'set':
200
201
  {
201
- var _action$payload3 = action.payload,
202
- _sourceCode = _action$payload3.sourceCode,
203
- selection = _action$payload3.selection;
202
+ var _action$payload4 = action.payload,
203
+ _sourceCode = _action$payload4.sourceCode,
204
+ selection = _action$payload4.selection;
204
205
  return {
205
206
  sourceCode: _sourceCode.replace(/\r\n?/g, '\n'),
206
207
  selection: selection
@@ -255,16 +256,16 @@ var historyReducer = function historyReducer(_ref2, action) {
255
256
  }
256
257
  case 'batch':
257
258
  {
258
- var _action$payload$selec, _action$payload4, _action$payload$selec2, _action$payload5;
259
+ var _action$payload$selec, _action$payload5, _action$payload$selec2, _action$payload6;
259
260
  return {
260
261
  states: [].concat(_toConsumableArray(states.slice(0, index)), [_objectSpread(_objectSpread({}, states[index]), {}, {
261
- selection: (_action$payload$selec = (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : _action$payload4.selection) !== null && _action$payload$selec !== void 0 ? _action$payload$selec : states[index].selection,
262
+ selection: (_action$payload$selec = (_action$payload5 = action.payload) === null || _action$payload5 === void 0 ? void 0 : _action$payload5.selection) !== null && _action$payload$selec !== void 0 ? _action$payload$selec : states[index].selection,
262
263
  action: _objectSpread(_objectSpread({}, states[index].action), {}, {
263
264
  batch: false
264
265
  })
265
266
  })]),
266
267
  index: index,
267
- selection: (_action$payload$selec2 = (_action$payload5 = action.payload) === null || _action$payload5 === void 0 ? void 0 : _action$payload5.selection) !== null && _action$payload$selec2 !== void 0 ? _action$payload$selec2 : selection
268
+ selection: (_action$payload$selec2 = (_action$payload6 = action.payload) === null || _action$payload6 === void 0 ? void 0 : _action$payload6.selection) !== null && _action$payload$selec2 !== void 0 ? _action$payload$selec2 : selection
268
269
  };
269
270
  }
270
271
  case 'mutate':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-star-editor",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "An editor developed by turingstar",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",