@skbkontur/markdown 1.0.13 → 1.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skbkontur/markdown",
3
- "version": "1.0.13",
3
+ "version": "1.1.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -29,7 +29,7 @@ export var MarkdownPreview = styled.div(templateObject_7 || (templateObject_7 =
29
29
  var panelPadding = _a.panelPadding, fullscreenPadding = _a.fullscreenPadding;
30
30
  return (_b = fullscreenPadding !== null && fullscreenPadding !== void 0 ? fullscreenPadding : panelPadding) !== null && _b !== void 0 ? _b : 8;
31
31
  });
32
- export var MarkdownActionsWrapper = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding: 0 ", ";\n margin-bottom: 4px;\n\n ", ";\n"], ["\n padding: 0 ", ";\n margin-bottom: 4px;\n\n ", ";\n"])), function (p) { var _a; return "".concat((_a = p.fullscreenPadding) !== null && _a !== void 0 ? _a : 0, "px"); }, function (_a) {
32
+ export var MarkdownActionsWrapper = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding: ", " ", " 0;\n margin-bottom: 4px;\n\n ", ";\n"], ["\n padding: ", " ", " 0;\n margin-bottom: 4px;\n\n ", ";\n"])), function (p) { return "".concat(p.fullscreenPadding ? 16 : 0, "px"); }, function (p) { var _a; return "".concat((_a = p.fullscreenPadding) !== null && _a !== void 0 ? _a : 0, "px"); }, function (_a) {
33
33
  var theme = _a.theme, panelPadding = _a.panelPadding, fullscreenPadding = _a.fullscreenPadding;
34
34
  if (panelPadding && !fullscreenPadding)
35
35
  return panelStyle({ theme: theme, panelPadding: panelPadding });
@@ -51,15 +51,18 @@ export var markdownFormatToShortKey = (_a = {},
51
51
  _a[MarkdownFormat.quote] = 'Q',
52
52
  _a[MarkdownFormat.image] = 'P',
53
53
  _a);
54
+ function reverseString(text) {
55
+ return text.split('').reverse().join('');
56
+ }
54
57
  export function checkSpaceSymbol(text, checkedLength) {
55
58
  var latestSymbolPos = text.length - 1;
56
59
  var latestSymbol = text.charAt(latestSymbolPos);
57
60
  if (latestSymbol.match(spacesMatchRegexp) && checkedLength) {
58
- var substringText = text.split('').reverse().join('').split(spacesSplitRegexp);
61
+ var substringText = reverseString(text).split(spacesSplitRegexp);
59
62
  var spaces = substringText[1];
60
63
  var textWithoutSpaces = substringText[2];
61
- var reversed = textWithoutSpaces.split('').reverse().join('');
62
- return { value: reversed, spaces: spaces };
64
+ var reversed = reverseString(textWithoutSpaces);
65
+ return { value: reversed, spaces: reverseString(spaces) };
63
66
  }
64
67
  return { value: text, spaces: '' };
65
68
  }
@@ -14,7 +14,10 @@ export function setMarkdown(textareaNode, text, format, selectionStart, selectio
14
14
  var _b = checkSpaceSymbol(prevCommentPart, markdownHelpItem.checkLength), value = _b.value, spaces = _b.spaces;
15
15
  var nextCommentPart = markdownHelpItem.wrapContent(value) + spaces;
16
16
  document.execCommand('insertText', false, nextCommentPart);
17
- setTextareaCursor(format, prevCommentPart.length, nextCommentPart.length, textareaNode, Number(selectionEnd) + ((_a = markdownHelpItem === null || markdownHelpItem === void 0 ? void 0 : markdownHelpItem.checkLength) !== null && _a !== void 0 ? _a : 0));
17
+ console.log(spaces.length);
18
+ setTextareaCursor(format, prevCommentPart.length, nextCommentPart.length, textareaNode, nextCommentPart.length -
19
+ ((markdownHelpItem === null || markdownHelpItem === void 0 ? void 0 : markdownHelpItem.format) === MarkdownFormat.ref ? 4 : ((_a = markdownHelpItem === null || markdownHelpItem === void 0 ? void 0 : markdownHelpItem.checkLength) !== null && _a !== void 0 ? _a : 0) * 2) -
20
+ spaces.length);
18
21
  }
19
22
  }
20
23
  export function setMarkdownFiles(file, textarea, format, cursorPosition, fileApiUrl) {