@skbkontur/markdown 1.5.0 → 1.6.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.
Files changed (87) hide show
  1. package/index.d.ts +7 -0
  2. package/index.js +6 -0
  3. package/package.json +1 -1
  4. package/src/Markdown/Files/Files.logic.d.ts +13 -0
  5. package/src/Markdown/Files/Files.logic.js +123 -0
  6. package/src/Markdown/Markdown.creevey.d.ts +1 -0
  7. package/src/Markdown/Markdown.creevey.js +169 -0
  8. package/src/Markdown/Markdown.d.ts +24 -0
  9. package/src/Markdown/Markdown.js +148 -0
  10. package/src/Markdown/Markdown.styled.d.ts +1271 -0
  11. package/src/Markdown/Markdown.styled.js +76 -0
  12. package/src/Markdown/MarkdownActions.d.ts +20 -0
  13. package/src/Markdown/MarkdownActions.js +64 -0
  14. package/src/Markdown/MarkdownEditor.d.ts +16 -0
  15. package/src/Markdown/MarkdownEditor.js +42 -0
  16. package/src/Markdown/MarkdownFormat.d.ts +18 -0
  17. package/src/Markdown/MarkdownFormat.js +19 -0
  18. package/src/Markdown/MarkdownHelpItems.d.ts +30 -0
  19. package/src/Markdown/MarkdownHelpItems.js +243 -0
  20. package/src/Markdown/MarkdownHelpers/MarkdownButton.d.ts +10 -0
  21. package/src/Markdown/MarkdownHelpers/MarkdownButton.js +10 -0
  22. package/src/Markdown/MarkdownHelpers/MarkdownCombination.d.ts +8 -0
  23. package/src/Markdown/MarkdownHelpers/MarkdownCombination.js +15 -0
  24. package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.d.ts +8 -0
  25. package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.js +11 -0
  26. package/src/Markdown/MarkdownHelpers/markdownHelpers.d.ts +10 -0
  27. package/src/Markdown/MarkdownHelpers/markdownHelpers.js +107 -0
  28. package/src/Markdown/MarkdownHelpers/markdownMentionHelpers.d.ts +7 -0
  29. package/src/Markdown/MarkdownHelpers/markdownMentionHelpers.js +44 -0
  30. package/src/Markdown/MarkdownHelpers/markdownTextareaHelpers.d.ts +11 -0
  31. package/src/Markdown/MarkdownHelpers/markdownTextareaHelpers.js +98 -0
  32. package/src/Markdown/MarkdownMention.d.ts +11 -0
  33. package/src/Markdown/MarkdownMention.js +88 -0
  34. package/src/Markdown/constants.d.ts +3 -0
  35. package/src/Markdown/constants.js +3 -0
  36. package/src/Markdown/types.d.ts +39 -0
  37. package/src/Markdown/types.js +5 -0
  38. package/src/Markdown/utils/guid.d.ts +6 -0
  39. package/src/Markdown/utils/guid.js +23 -0
  40. package/src/Markdown/utils/htmlToMd.d.ts +2 -0
  41. package/src/Markdown/utils/htmlToMd.js +5 -0
  42. package/src/Markdown/utils/isMacintosh.d.ts +1 -0
  43. package/src/Markdown/utils/isMacintosh.js +3 -0
  44. package/src/Markdown/utils/requestStatus.d.ts +6 -0
  45. package/src/Markdown/utils/requestStatus.js +7 -0
  46. package/src/Markdown/utils/saveFile.d.ts +1 -0
  47. package/src/Markdown/utils/saveFile.js +9 -0
  48. package/src/MarkdownIcons/AttachLink.d.ts +2 -0
  49. package/src/MarkdownIcons/AttachLink.js +5 -0
  50. package/src/MarkdownIcons/AttachPaperclip.d.ts +2 -0
  51. package/src/MarkdownIcons/AttachPaperclip.js +3 -0
  52. package/src/MarkdownIcons/CheckedList.d.ts +2 -0
  53. package/src/MarkdownIcons/CheckedList.js +8 -0
  54. package/src/MarkdownIcons/Collapse.d.ts +2 -0
  55. package/src/MarkdownIcons/Collapse.js +4 -0
  56. package/src/MarkdownIcons/Expand.d.ts +2 -0
  57. package/src/MarkdownIcons/Expand.js +4 -0
  58. package/src/MarkdownIcons/EyeOpen.d.ts +2 -0
  59. package/src/MarkdownIcons/EyeOpen.js +4 -0
  60. package/src/MarkdownIcons/List.d.ts +2 -0
  61. package/src/MarkdownIcons/List.js +8 -0
  62. package/src/MarkdownIcons/MarkdownIcons.styled.d.ts +1 -0
  63. package/src/MarkdownIcons/MarkdownIcons.styled.js +7 -0
  64. package/src/MarkdownIcons/NumberedList.d.ts +2 -0
  65. package/src/MarkdownIcons/NumberedList.js +6 -0
  66. package/src/MarkdownIcons/Table.d.ts +2 -0
  67. package/src/MarkdownIcons/Table.js +3 -0
  68. package/src/MarkdownIcons/ToolPencil.d.ts +2 -0
  69. package/src/MarkdownIcons/ToolPencil.js +3 -0
  70. package/src/MarkdownViewer/Helpers/MarkdownImage.d.ts +6 -0
  71. package/src/MarkdownViewer/Helpers/MarkdownImage.js +7 -0
  72. package/src/MarkdownViewer/Helpers/MarkdownLink.d.ts +3 -0
  73. package/src/MarkdownViewer/Helpers/MarkdownLink.js +5 -0
  74. package/src/MarkdownViewer/MarkdownViewer.d.ts +12 -0
  75. package/src/MarkdownViewer/MarkdownViewer.js +70 -0
  76. package/src/MarkdownViewer/MarkdownViewer.styles.d.ts +9 -0
  77. package/src/MarkdownViewer/MarkdownViewer.styles.js +16 -0
  78. package/src/MarkdownViewer/index.d.ts +1 -0
  79. package/src/MarkdownViewer/index.js +1 -0
  80. package/src/MarkdownViewer/types.d.ts +7 -0
  81. package/src/MarkdownViewer/types.js +1 -0
  82. package/src/styles/styled-components.d.ts +5 -0
  83. package/src/styles/styled-components.js +4 -0
  84. package/src/styles/theme.d.ts +15 -0
  85. package/src/styles/theme.js +17 -0
  86. package/src/styles/types.d.ts +9 -0
  87. package/src/styles/types.js +1 -0
@@ -0,0 +1,76 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ var __assign = (this && this.__assign) || function () {
6
+ __assign = Object.assign || function(t) {
7
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
8
+ s = arguments[i];
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
+ t[p] = s[p];
11
+ }
12
+ return t;
13
+ };
14
+ return __assign.apply(this, arguments);
15
+ };
16
+ import { Button, MenuItem, ThemeFactory } from '@skbkontur/react-ui';
17
+ import styled, { css } from '../styles/styled-components';
18
+ var panelStyle = function (_a) {
19
+ var panelPadding = _a.panelPadding, theme = _a.theme;
20
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 6px ", "px;\n background-color: ", ";\n margin-bottom: 12px;\n"], ["\n padding: 6px ", "px;\n background-color: ", ";\n margin-bottom: 12px;\n"])), panelPadding !== null && panelPadding !== void 0 ? panelPadding : 0, theme.colors.panelBg);
21
+ };
22
+ export var Wrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n\n &:focus-visible {\n outline: 1px solid ", ";\n }\n"], ["\n position: relative;\n\n &:focus-visible {\n outline: 1px solid ", ";\n }\n"])), function (p) { return p.theme.colors.brand; });
23
+ export var Avatar = styled.img.attrs({ alt: '' })(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n flex-shrink: 0;\n box-sizing: border-box;\n border: 1px solid ", ";\n border-radius: 50%;\n object-fit: cover;\n"], ["\n flex-shrink: 0;\n box-sizing: border-box;\n border: 1px solid ", ";\n border-radius: 50%;\n object-fit: cover;\n"])), function (props) { return props.theme.colors.grayDefault; });
24
+ export var UserWrapper = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 244px;\n display: flex;\n align-items: center;\n gap: 12px;\n"], ["\n width: 244px;\n display: flex;\n align-items: center;\n gap: 12px;\n"])));
25
+ export var DroppablePlaceholder = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n position: absolute;\n top: ", "px;\n left: ", "px;\n width: 100%;\n height: 100%;\n padding: ", "px;\n border-radius: 8px;\n z-index: 100;\n background: linear-gradient(0deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.04)),\n rgba(255, 255, 255, ", ");\n background-image: ", ";\n"], ["\n position: absolute;\n top: ", "px;\n left: ", "px;\n width: 100%;\n height: 100%;\n padding: ", "px;\n border-radius: 8px;\n z-index: 100;\n background: linear-gradient(0deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.04)),\n rgba(255, 255, 255, ", ");\n background-image: ", ";\n"])), function (p) { return (p.panelPadding || p.fullscreenPadding ? 0 : -8); }, function (p) { return (p.panelPadding || p.fullscreenPadding ? 0 : -8); }, function (p) { return (p.panelPadding || p.fullscreenPadding ? 0 : 8); }, function (p) { return (p.theme.themeMode === 'dark' ? 0.1 : 0.7); }, function (p) { var _a, _b; return (_b = (_a = p.theme) === null || _a === void 0 ? void 0 : _a.droppablePlaceholderBgImage) !== null && _b !== void 0 ? _b : ''; });
26
+ export var MentionWrapper = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject([""], [""])));
27
+ export var MarkdownPreview = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding: 6px ", "px;\n"], ["\n padding: 6px ", "px;\n"])), function (_a) {
28
+ var _b;
29
+ var panelPadding = _a.panelPadding, fullscreenPadding = _a.fullscreenPadding;
30
+ return (_b = fullscreenPadding !== null && fullscreenPadding !== void 0 ? fullscreenPadding : panelPadding) !== null && _b !== void 0 ? _b : 8;
31
+ });
32
+ export var MarkdownActionsWrapper = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding: ", " ", "px 0;\n margin-bottom: 4px;\n box-sizing: border-box;\n ", "\n\n ", "\n"], ["\n padding: ", " ", "px 0;\n margin-bottom: 4px;\n box-sizing: border-box;\n ", "\n\n ", "\n"])), function (p) { return (p.fullscreenPadding ? '16px' : 0); }, function (p) { var _a; return (_a = p.fullscreenPadding) !== null && _a !== void 0 ? _a : 0; }, function (p) { return p.width && "width: ".concat(typeof p.width === 'string' ? p.width : "".concat(p.width, "px"), ";"); }, function (_a) {
33
+ var theme = _a.theme, panelPadding = _a.panelPadding, fullscreenPadding = _a.fullscreenPadding;
34
+ if (panelPadding && !fullscreenPadding)
35
+ return panelStyle({ theme: theme, panelPadding: panelPadding });
36
+ });
37
+ export var ButtonsWrapper = styled.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex-wrap: wrap;\n margin: 0 -7px;\n"], ["\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex-wrap: wrap;\n margin: 0 -7px;\n"])));
38
+ export var ActionsWrapper = styled.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n"], ["\n display: flex;\n align-items: center;\n"])));
39
+ export var MarkdownButtonWrapper = styled(Button)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n button {\n padding: 4px;\n border: none;\n box-sizing: border-box;\n }\n"], ["\n button {\n padding: 4px;\n border: none;\n box-sizing: border-box;\n }\n"])));
40
+ export var MarkdownButtonIcon = styled.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n height: 24px;\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n"], ["\n height: 24px;\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n"])));
41
+ export var MarkdownDropdown = styled.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n button {\n font-size: ", ";\n }\n"], ["\n button {\n font-size: ", ";\n }\n"])), function (p) { return p.theme.elementsFontSize; });
42
+ export var MarkdownSymbolWrapper = styled.span(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n color: ", ";\n"], ["\n color: ", ";\n"])), function (p) { return p.theme.colors.brand; });
43
+ export var MarkdownMenuItem = styled(MenuItem)(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n padding-left: 8px;\n padding-right: 8px;\n color: ", ";\n"], ["\n padding-left: 8px;\n padding-right: 8px;\n color: ", ";\n"])), function (p) { return p.theme.colors.grayDefault; });
44
+ export var HintContentWrapper = styled.div(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n width: 100%;\n"], ["\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n width: 100%;\n"])));
45
+ export var MarkdownEditorBlock = styled.div(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
46
+ export var getMarkdownMentionStyle = function (x, y) { return ({
47
+ position: 'absolute',
48
+ top: y,
49
+ left: x,
50
+ }); };
51
+ export var UserDescriptions = styled.div(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n white-space: pre-line;\n overflow-wrap: break-word;\n word-wrap: break-word;\n word-break: break-word;\n overflow: hidden;\n margin-top: 4px;\n"], ["\n white-space: pre-line;\n overflow-wrap: break-word;\n word-wrap: break-word;\n word-break: break-word;\n overflow: hidden;\n margin-top: 4px;\n"])));
52
+ export var MentionMenuItem = styled(MenuItem)(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n padding: 4px 28px;\n"], ["\n padding: 4px 28px;\n"])));
53
+ export var VisuallyHidden = styled.span(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n"], ["\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n"])));
54
+ export var getMarkdownReactUiTheme = function (theme, reactUiTheme, panelHorizontalPadding, fullScreenTextareaPadding, borderless) {
55
+ var elementsFontSize = theme.elementsFontSize, elementsLineHeight = theme.elementsLineHeight, themeMode = theme.themeMode, colors = theme.colors;
56
+ return ThemeFactory.create(__assign(__assign(__assign({ tabFontSize: elementsFontSize, tabPaddingY: '0', tabPaddingX: '6px', tabColorHover: 'transparent', tabColorFocus: 'transparent', tabLineHeight: elementsLineHeight, tabBorderWidth: '0', selectBorderWidth: '0', btnDefaultBg: 'transparent', btnDefaultActiveBorderColor: 'transparent', btnDisabledBg: 'transparent', btnDisabledBorderColor: 'transparent', btnDisabledTextColor: colors.disabledButton, btnDefaultHoverBg: themeMode === 'light' ? reactUiTheme === null || reactUiTheme === void 0 ? void 0 : reactUiTheme.btnDefaultHoverBg : reactUiTheme === null || reactUiTheme === void 0 ? void 0 : reactUiTheme.btnDisabledBg, btnFontSizeSmall: elementsFontSize, checkboxPaddingY: '0', checkboxBg: 'transparent', checkboxHoverBg: 'transparent', checkboxCheckedBg: 'transparent', checkboxShadow: "0 0 0 1px ".concat(colors.grayDefault), checkboxShadowHover: "0 0 0 1px ".concat(colors.grayDefault), checkboxCheckedHoverShadow: "0 0 0 1px ".concat(colors.grayDefault), checkboxCheckedShadow: "0 0 0 1px ".concat(colors.grayDefault), checkboxCheckedActiveShadow: "0 0 0 1px ".concat(colors.grayDefault), checkboxShadowActive: "0 0 0 1px ".concat(colors.grayDefault), checkboxCheckedColor: colors.grayDefault, checkboxBoxSize: elementsFontSize, menuItemFontSize: elementsFontSize, menuItemPaddingY: '4px', menuItemPaddingX: '28px', hintFontSize: elementsFontSize, hintColor: themeMode === 'light' ? colors.white : colors.grayDefault, selectPaddingXSmall: '8px', selectLineHeightSmall: '24px', dropdownBorderWidth: '0' }, (panelHorizontalPadding &&
57
+ {
58
+ textareaPaddingX: "".concat(panelHorizontalPadding, "px"),
59
+ })), (borderless &&
60
+ {
61
+ textareaBorderColor: 'transparent',
62
+ textareaBorderColorFocus: 'transparent',
63
+ textareaBorderTopColor: 'transparent',
64
+ textareaShadow: 'none',
65
+ })), (fullScreenTextareaPadding &&
66
+ {
67
+ textareaMinHeight: '85vh',
68
+ textareaBorderColor: 'transparent',
69
+ textareaBorderColorFocus: 'transparent',
70
+ textareaBorderTopColor: 'transparent',
71
+ textareaShadow: 'none',
72
+ textareaPaddingX: "".concat(fullScreenTextareaPadding, "px"),
73
+ textareaPaddingY: "0",
74
+ })), reactUiTheme);
75
+ };
76
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20;
@@ -0,0 +1,20 @@
1
+ import { Textarea } from '@skbkontur/react-ui';
2
+ import { FC, RefObject } from 'react';
3
+ import { HorizontalPaddings, Nullable, ViewMode } from './types';
4
+ interface Props {
5
+ horizontalPaddings: HorizontalPaddings;
6
+ onChangeViewMode: (viewMode: ViewMode) => void;
7
+ onClickFullscreen: () => void;
8
+ onOpenFileDialog: () => void;
9
+ textAreaRef: RefObject<Textarea>;
10
+ viewMode: ViewMode;
11
+ fullscreen?: boolean;
12
+ hasFilesApi?: boolean;
13
+ hideHeadersSelect?: boolean;
14
+ loadingFile?: boolean;
15
+ selectionEnd?: Nullable<number>;
16
+ selectionStart?: Nullable<number>;
17
+ width?: Nullable<number | string>;
18
+ }
19
+ export declare const MarkdownActions: FC<Props>;
20
+ export {};
@@ -0,0 +1,64 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { Dropdown } from '@skbkontur/react-ui';
13
+ import React from 'react';
14
+ import { ActionsWrapper, ButtonsWrapper, MarkdownDropdown, MarkdownMenuItem, MarkdownActionsWrapper, } from './Markdown.styled';
15
+ import { MarkdownCombination } from './MarkdownHelpers/MarkdownCombination';
16
+ import { MarkdownFormatButton } from './MarkdownHelpers/MarkdownFormatButton';
17
+ import { setMarkdown } from './MarkdownHelpers/markdownHelpers';
18
+ import { markdownHelpHeaders, markdownHelpLists, markdownHelpOther, markdownHelpText } from './MarkdownHelpItems';
19
+ import { ViewMode } from './types';
20
+ import { AttachPaperclip } from '../MarkdownIcons/AttachPaperclip';
21
+ import { Collapse } from '../MarkdownIcons/Collapse';
22
+ import { Expand } from '../MarkdownIcons/Expand';
23
+ import { EyeOpen } from '../MarkdownIcons/EyeOpen';
24
+ import { ToolPencil } from '../MarkdownIcons/ToolPencil';
25
+ export var MarkdownActions = function (_a) {
26
+ var textAreaRef = _a.textAreaRef, selectionStart = _a.selectionStart, selectionEnd = _a.selectionEnd, loadingFile = _a.loadingFile, onOpenFileDialog = _a.onOpenFileDialog, onClickFullscreen = _a.onClickFullscreen, fullscreen = _a.fullscreen, viewMode = _a.viewMode, onChangeViewMode = _a.onChangeViewMode, horizontalPaddings = _a.horizontalPaddings, hasFilesApi = _a.hasFilesApi, hideHeadersSelect = _a.hideHeadersSelect, width = _a.width;
27
+ var isPreviewMode = viewMode === ViewMode.Preview;
28
+ return (React.createElement(MarkdownActionsWrapper, __assign({}, horizontalPaddings, { width: width }),
29
+ React.createElement(ButtonsWrapper, null,
30
+ React.createElement(ActionsWrapper, null,
31
+ hideHeadersSelect || (React.createElement(MarkdownDropdown, null,
32
+ React.createElement(Dropdown, { disablePortal: true, disabled: isPreviewMode, menuWidth: 280, caption: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A" }, markdownHelpHeaders.map(function (helper, idx) { return (React.createElement(MarkdownMenuItem, { key: idx, onClick: function (event) { return handleMarkdownItemClick(event, helper.format); } },
33
+ React.createElement(MarkdownCombination, { format: helper.format, text: helper.node }))); })))),
34
+ markdownHelpText.map(function (helper, idx) { return (React.createElement(MarkdownFormatButton, { key: idx, disabled: isPreviewMode, format: helper.format, hintText: helper.node, icon: helper.icon, text: helper.text, onClick: function (event) { return handleMarkdownItemClick(event, helper.format); } })); }),
35
+ markdownHelpLists.map(function (helper, idx) { return (React.createElement(MarkdownFormatButton, { key: idx, disabled: isPreviewMode, format: helper.format, hintText: helper.node, icon: helper.icon, text: helper.text, onClick: function (event) { return handleMarkdownItemClick(event, helper.format); } })); }),
36
+ markdownHelpOther.map(function (helper, idx) { return (React.createElement(MarkdownFormatButton, { key: idx, disabled: isPreviewMode, format: helper.format, hintText: helper.node, icon: helper.icon, text: helper.text, onClick: function (event) { return handleMarkdownItemClick(event, helper.format); } })); }),
37
+ hasFilesApi && (React.createElement(MarkdownFormatButton, { hintText: "\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B", disabled: isPreviewMode, isLoading: loadingFile, icon: React.createElement(AttachPaperclip, null), text: "\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B", onClick: onOpenFileDialog }))),
38
+ React.createElement(ActionsWrapper, null,
39
+ renderViewModeButton(),
40
+ React.createElement(MarkdownFormatButton, { hintText: fullscreen ? 'Свернуть' : 'Развернуть', icon: fullscreen ? React.createElement(Collapse, null) : React.createElement(Expand, null), text: fullscreen ? 'Свернуть' : 'Развернуть', onClick: onClickFullscreen })))));
41
+ function renderViewModeButton() {
42
+ var buttonProps = {
43
+ hintText: isPreviewMode ? 'Вернуться в редактор' : 'Превью',
44
+ icon: isPreviewMode ? React.createElement(ToolPencil, null) : React.createElement(EyeOpen, null),
45
+ onClick: function () { return onChangeViewMode(isPreviewMode ? ViewMode.Edit : ViewMode.Preview); },
46
+ text: isPreviewMode ? 'Вернуться в редактор' : 'Превью',
47
+ };
48
+ return React.createElement(MarkdownFormatButton, __assign({}, buttonProps));
49
+ }
50
+ function handleMarkdownItemClick(event, format) {
51
+ var _a;
52
+ if (!isNaN(Number(selectionStart)) && !isNaN(Number(selectionEnd))) {
53
+ event.stopPropagation();
54
+ event.preventDefault();
55
+ if (textAreaRef === null || textAreaRef === void 0 ? void 0 : textAreaRef.current) {
56
+ textAreaRef.current.focus();
57
+ var htmlTextArea = textAreaRef.current.node;
58
+ htmlTextArea.selectionStart = Number(selectionStart);
59
+ htmlTextArea.selectionEnd = Number(selectionEnd);
60
+ setMarkdown(htmlTextArea, (_a = htmlTextArea.value) !== null && _a !== void 0 ? _a : '', format, Number(selectionStart), selectionEnd);
61
+ }
62
+ }
63
+ }
64
+ };
@@ -0,0 +1,16 @@
1
+ import { Textarea, TextareaProps } from '@skbkontur/react-ui';
2
+ import { ValidationInfo, RenderErrorMessage } from '@skbkontur/react-ui-validations';
3
+ import { FC, RefObject } from 'react';
4
+ import { Nullable } from './types';
5
+ export interface MarkdownEditorProps extends Omit<TextareaProps, 'rows' | 'maxRows' | 'disableAnimations' | 'extraRow'> {
6
+ disableAnimations?: boolean;
7
+ extraRow?: boolean;
8
+ maxRows?: number;
9
+ /** Рендер сообщения валидации react-ui-validations */
10
+ renderMessage?: Nullable<RenderErrorMessage>;
11
+ rows?: number;
12
+ textareaRef?: RefObject<Textarea>;
13
+ /** Стандартная валидация из react-ui-validations */
14
+ validationInfo?: Nullable<ValidationInfo>;
15
+ }
16
+ export declare const MarkdownEditor: FC<MarkdownEditorProps>;
@@ -0,0 +1,42 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { Textarea } from '@skbkontur/react-ui';
24
+ import { ValidationWrapper } from '@skbkontur/react-ui-validations';
25
+ import React from 'react';
26
+ import { useDropzone } from 'react-dropzone';
27
+ import { createMarkdownHelpKeyDownHandler } from './MarkdownHelpers/markdownHelpers';
28
+ export var MarkdownEditor = function (props) {
29
+ var _a = props.resize, resize = _a === void 0 ? 'none' : _a, _b = props.width, width = _b === void 0 ? '100%' : _b, _c = props.autoResize, autoResize = _c === void 0 ? true : _c, _d = props.showLengthCounter, propsShowLengthCounter = _d === void 0 ? true : _d, textareaRef = props.textareaRef, validationInfo = props.validationInfo, renderMessage = props.renderMessage, rest = __rest(props, ["resize", "width", "autoResize", "showLengthCounter", "textareaRef", "validationInfo", "renderMessage"]);
30
+ var getInputProps = useDropzone().getInputProps;
31
+ return validationInfo ? (React.createElement(ValidationWrapper, { validationInfo: validationInfo, renderMessage: renderMessage }, renderTextarea())) : (renderTextarea());
32
+ function renderTextarea() {
33
+ return (React.createElement(Textarea, __assign({ ref: textareaRef, id: "MarkdownTextArea" }, rest, getInputProps, { resize: resize, width: width, showLengthCounter: showLengthCounter(), autoResize: autoResize, onKeyDown: createMarkdownHelpKeyDownHandler(props.value || '', textareaRef, props.onKeyDown) })));
34
+ }
35
+ function showLengthCounter() {
36
+ if (propsShowLengthCounter) {
37
+ var value = rest.value, maxLength = rest.maxLength;
38
+ return Number(maxLength) - Number(value === null || value === void 0 ? void 0 : value.length) <= 500;
39
+ }
40
+ return false;
41
+ }
42
+ };
@@ -0,0 +1,18 @@
1
+ export declare enum MarkdownFormat {
2
+ h2 = "h2",
3
+ h3 = "h3",
4
+ h4 = "h4",
5
+ bold = "bold",
6
+ italic = "italic",
7
+ crossed = "crossed",
8
+ ref = "ref",
9
+ quote = "quote",
10
+ codeBlock = "codeBlock",
11
+ code = "code",
12
+ list = "list",
13
+ checkedList = "checkedList",
14
+ numberedList = "numberedList",
15
+ table = "table",
16
+ file = "file",
17
+ image = "image"
18
+ }
@@ -0,0 +1,19 @@
1
+ export var MarkdownFormat;
2
+ (function (MarkdownFormat) {
3
+ MarkdownFormat["h2"] = "h2";
4
+ MarkdownFormat["h3"] = "h3";
5
+ MarkdownFormat["h4"] = "h4";
6
+ MarkdownFormat["bold"] = "bold";
7
+ MarkdownFormat["italic"] = "italic";
8
+ MarkdownFormat["crossed"] = "crossed";
9
+ MarkdownFormat["ref"] = "ref";
10
+ MarkdownFormat["quote"] = "quote";
11
+ MarkdownFormat["codeBlock"] = "codeBlock";
12
+ MarkdownFormat["code"] = "code";
13
+ MarkdownFormat["list"] = "list";
14
+ MarkdownFormat["checkedList"] = "checkedList";
15
+ MarkdownFormat["numberedList"] = "numberedList";
16
+ MarkdownFormat["table"] = "table";
17
+ MarkdownFormat["file"] = "file";
18
+ MarkdownFormat["image"] = "image";
19
+ })(MarkdownFormat || (MarkdownFormat = {}));
@@ -0,0 +1,30 @@
1
+ import { ReactNode } from 'react';
2
+ import { MarkdownFormat } from './MarkdownFormat';
3
+ import { RefItem } from './types';
4
+ export declare const eventKeyCodeToMarkdownFormat: {
5
+ [key: number]: MarkdownFormat;
6
+ };
7
+ export declare const markdownFormatToShortKey: Partial<{
8
+ [key in MarkdownFormat]: string;
9
+ }>;
10
+ export interface MarkdownHelpItem {
11
+ format: MarkdownFormat;
12
+ node: ReactNode;
13
+ text: string;
14
+ wrapContent: (content: string) => string;
15
+ checkLength?: number;
16
+ icon?: ReactNode;
17
+ }
18
+ export declare function checkSpaceSymbol(text: string, checkedLength?: number): {
19
+ value: string;
20
+ spaces: string;
21
+ };
22
+ export declare const markdownHelpHeaders: MarkdownHelpItem[];
23
+ export declare const markdownHelpText: MarkdownHelpItem[];
24
+ export declare const markdownHelpLists: MarkdownHelpItem[];
25
+ export declare const markdownHelpOther: MarkdownHelpItem[];
26
+ export interface MarkdownHelpFileItem extends Omit<MarkdownHelpItem, 'wrapContent'> {
27
+ wrapContent: (file: RefItem) => string;
28
+ }
29
+ export declare const markdownHelpFiles: (fileApiUrl?: string) => MarkdownHelpFileItem[];
30
+ export declare const markdownHelpItems: MarkdownHelpItem[];
@@ -0,0 +1,243 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ var _a;
11
+ import React from 'react';
12
+ import { MarkdownSymbolWrapper } from './Markdown.styled';
13
+ import { MarkdownFormat } from './MarkdownFormat';
14
+ import { AttachLink } from '../MarkdownIcons/AttachLink';
15
+ import { AttachPaperclip } from '../MarkdownIcons/AttachPaperclip';
16
+ import { CheckedList } from '../MarkdownIcons/CheckedList';
17
+ import { List } from '../MarkdownIcons/List';
18
+ import { I } from '../MarkdownIcons/MarkdownIcons.styled';
19
+ import { NumberedList } from '../MarkdownIcons/NumberedList';
20
+ import { Table } from '../MarkdownIcons/Table';
21
+ var newLinesRegexp = /([\n\r]+)/g;
22
+ var spacesMatchRegexp = /\s/gm;
23
+ var spacesSplitRegexp = /(\s+)/;
24
+ export var eventKeyCodeToMarkdownFormat = {
25
+ 50: MarkdownFormat.h2,
26
+ 51: MarkdownFormat.h3,
27
+ 52: MarkdownFormat.h4,
28
+ 66: MarkdownFormat.bold,
29
+ 73: MarkdownFormat.italic,
30
+ 82: MarkdownFormat.crossed,
31
+ 85: MarkdownFormat.ref,
32
+ 76: MarkdownFormat.list,
33
+ 68: MarkdownFormat.checkedList,
34
+ 78: MarkdownFormat.numberedList,
35
+ 69: MarkdownFormat.codeBlock,
36
+ 81: MarkdownFormat.quote,
37
+ 80: MarkdownFormat.image,
38
+ };
39
+ export var markdownFormatToShortKey = (_a = {},
40
+ _a[MarkdownFormat.h2] = '2',
41
+ _a[MarkdownFormat.h3] = '3',
42
+ _a[MarkdownFormat.h4] = '4',
43
+ _a[MarkdownFormat.bold] = 'B',
44
+ _a[MarkdownFormat.italic] = 'I',
45
+ _a[MarkdownFormat.crossed] = 'R',
46
+ _a[MarkdownFormat.ref] = 'U',
47
+ _a[MarkdownFormat.list] = 'L',
48
+ _a[MarkdownFormat.checkedList] = 'D',
49
+ _a[MarkdownFormat.numberedList] = 'N',
50
+ _a[MarkdownFormat.codeBlock] = 'E',
51
+ _a[MarkdownFormat.quote] = 'Q',
52
+ _a[MarkdownFormat.image] = 'P',
53
+ _a);
54
+ function reverseString(text) {
55
+ return text.split('').reverse().join('');
56
+ }
57
+ export function checkSpaceSymbol(text, checkedLength) {
58
+ var latestSymbolPos = text.length - 1;
59
+ var latestSymbol = text.charAt(latestSymbolPos);
60
+ if (latestSymbol.match(spacesMatchRegexp) && checkedLength) {
61
+ var substringText = reverseString(text).split(spacesSplitRegexp);
62
+ var spaces = substringText[1];
63
+ var remainingText = substringText.slice(2);
64
+ var textWithoutSpaces = remainingText.join('');
65
+ var reversed = reverseString(textWithoutSpaces);
66
+ return { value: reversed, spaces: reverseString(spaces) };
67
+ }
68
+ return { value: text, spaces: '' };
69
+ }
70
+ export var markdownHelpHeaders = [
71
+ {
72
+ format: MarkdownFormat.h2,
73
+ node: (React.createElement(React.Fragment, null,
74
+ React.createElement(MarkdownSymbolWrapper, null, "##"),
75
+ " \u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2")),
76
+ wrapContent: function (content) { return "## ".concat(content); },
77
+ text: 'Заголовок 2',
78
+ },
79
+ {
80
+ format: MarkdownFormat.h3,
81
+ node: (React.createElement(React.Fragment, null,
82
+ React.createElement(MarkdownSymbolWrapper, null, "###"),
83
+ " \u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 3")),
84
+ wrapContent: function (content) { return "### ".concat(content); },
85
+ text: 'Заголовок 3',
86
+ },
87
+ {
88
+ format: MarkdownFormat.h4,
89
+ node: (React.createElement(React.Fragment, null,
90
+ React.createElement(MarkdownSymbolWrapper, null, "####"),
91
+ " \u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 4")),
92
+ wrapContent: function (content) { return "#### ".concat(content); },
93
+ text: 'Заголовок 4',
94
+ },
95
+ ];
96
+ export var markdownHelpText = [
97
+ {
98
+ format: MarkdownFormat.bold,
99
+ node: (React.createElement(React.Fragment, null,
100
+ React.createElement(MarkdownSymbolWrapper, null, "**"),
101
+ "\u0416\u0438\u0440\u043D\u044B\u0439",
102
+ React.createElement(MarkdownSymbolWrapper, null, "**"))),
103
+ icon: React.createElement("strong", null, "B"),
104
+ wrapContent: function (content) { return "**".concat(content, "**"); },
105
+ text: 'Жирный',
106
+ checkLength: 2,
107
+ },
108
+ {
109
+ format: MarkdownFormat.italic,
110
+ node: (React.createElement(React.Fragment, null,
111
+ React.createElement(MarkdownSymbolWrapper, null, "*"),
112
+ "\u041A\u0443\u0440\u0441\u0438\u0432",
113
+ React.createElement(MarkdownSymbolWrapper, null, "*"))),
114
+ icon: React.createElement(I, null, "I"),
115
+ wrapContent: function (content) { return "*".concat(content, "*"); },
116
+ text: 'Курсив',
117
+ checkLength: 1,
118
+ },
119
+ {
120
+ format: MarkdownFormat.crossed,
121
+ node: (React.createElement(React.Fragment, null,
122
+ React.createElement(MarkdownSymbolWrapper, null, "~~"),
123
+ "\u0417\u0430\u0447\u0435\u0440\u043A\u043D\u0443\u0442\u044B\u0439",
124
+ React.createElement(MarkdownSymbolWrapper, null, "~~"))),
125
+ icon: (React.createElement("span", { style: {
126
+ textDecoration: 'line-through',
127
+ } }, "S")),
128
+ wrapContent: function (content) { return "~~".concat(content, "~~"); },
129
+ text: 'Зачеркнутый',
130
+ checkLength: 2,
131
+ },
132
+ {
133
+ format: MarkdownFormat.ref,
134
+ node: (React.createElement(React.Fragment, null,
135
+ React.createElement(MarkdownSymbolWrapper, null, "["),
136
+ "\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0441\u0441\u044B\u043B\u043A\u0438",
137
+ React.createElement(MarkdownSymbolWrapper, null, "]"),
138
+ React.createElement(MarkdownSymbolWrapper, null, "("),
139
+ "\u0421\u0441\u044B\u043B\u043A\u0430",
140
+ React.createElement(MarkdownSymbolWrapper, null, ")"))),
141
+ icon: React.createElement(AttachLink, null),
142
+ wrapContent: function (content) { return "[".concat(content, "]()"); },
143
+ text: 'Ссылка',
144
+ checkLength: 1,
145
+ },
146
+ ];
147
+ export var markdownHelpLists = [
148
+ {
149
+ format: MarkdownFormat.list,
150
+ node: (React.createElement(React.Fragment, null,
151
+ React.createElement(MarkdownSymbolWrapper, null, "*"),
152
+ " \u0421\u043F\u0438\u0441\u043E\u043A")),
153
+ icon: React.createElement(List, null),
154
+ wrapContent: function (content) { return getList(content, '*'); },
155
+ text: 'Список',
156
+ },
157
+ {
158
+ format: MarkdownFormat.checkedList,
159
+ node: (React.createElement(React.Fragment, null,
160
+ React.createElement(MarkdownSymbolWrapper, null, "* [x]"),
161
+ " \u0421\u043F\u0438\u0441\u043E\u043A - \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u043E")),
162
+ icon: React.createElement(CheckedList, null),
163
+ wrapContent: function (content) { return getList(content, '* [x]'); },
164
+ text: 'Список - выполнено',
165
+ },
166
+ {
167
+ format: MarkdownFormat.numberedList,
168
+ node: (React.createElement(React.Fragment, null,
169
+ React.createElement(MarkdownSymbolWrapper, null, "1. "),
170
+ " \u0421\u043F\u0438\u0441\u043E\u043A - \u043D\u0443\u043C\u0435\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439")),
171
+ icon: React.createElement(NumberedList, null),
172
+ wrapContent: function (content) { return getList(content, 1); },
173
+ text: 'Список - нумерованный',
174
+ },
175
+ ];
176
+ export var markdownHelpOther = [
177
+ {
178
+ format: MarkdownFormat.codeBlock,
179
+ node: (React.createElement(React.Fragment, null,
180
+ React.createElement(MarkdownSymbolWrapper, null, "`"),
181
+ "\u0411\u043B\u043E\u043A \u043A\u043E\u0434\u0430",
182
+ React.createElement(MarkdownSymbolWrapper, null, "`"))),
183
+ icon: React.createElement("span", null, '</>'),
184
+ wrapContent: function (content) { return "`".concat(content, "`"); },
185
+ text: 'Блок кода',
186
+ checkLength: 1,
187
+ },
188
+ {
189
+ format: MarkdownFormat.quote,
190
+ node: (React.createElement(React.Fragment, null,
191
+ React.createElement(MarkdownSymbolWrapper, null,
192
+ '>',
193
+ " "),
194
+ " \u0426\u0438\u0442\u0430\u0442\u0430")),
195
+ icon: '>',
196
+ wrapContent: function (content) { return "> ".concat(content); },
197
+ text: 'Цитата',
198
+ },
199
+ {
200
+ format: MarkdownFormat.table,
201
+ node: 'Таблица',
202
+ icon: React.createElement(Table, null),
203
+ wrapContent: function () { return "| \u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A | \u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A |\n| ------ | ------ |\n| \u042F\u0447\u0435\u0439\u043A\u0430 | \u042F\u0447\u0435\u0439\u043A\u0430 |\n| \u042F\u0447\u0435\u0439\u043A\u0430 | \u042F\u0447\u0435\u0439\u043A\u0430 |"; },
204
+ text: 'Таблица',
205
+ },
206
+ ];
207
+ export var markdownHelpFiles = function (fileApiUrl) {
208
+ if (!fileApiUrl)
209
+ return [];
210
+ return [
211
+ {
212
+ format: MarkdownFormat.image,
213
+ node: '',
214
+ icon: React.createElement("span", null),
215
+ wrapContent: function (file) { return "![img](".concat(fileApiUrl).concat(file.id, ")"); },
216
+ text: 'Картинка',
217
+ },
218
+ {
219
+ format: MarkdownFormat.file,
220
+ node: '',
221
+ icon: React.createElement(AttachPaperclip, null),
222
+ wrapContent: function (file) { return "[".concat(file.caption, "](").concat(fileApiUrl).concat(file.id, ")"); },
223
+ text: 'Файл',
224
+ },
225
+ ];
226
+ };
227
+ export var markdownHelpItems = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], markdownHelpHeaders, true), markdownHelpText, true), markdownHelpLists, true), markdownHelpOther, true);
228
+ function getList(value, symbol) {
229
+ var splitValueWithNewLines = value.split(newLinesRegexp);
230
+ var numberList = [];
231
+ return splitValueWithNewLines
232
+ .map(function (v, idx) {
233
+ if (!newLinesRegexp.test(v)) {
234
+ if (typeof symbol === 'number') {
235
+ numberList.push(idx);
236
+ return "".concat(numberList.length, ". ").concat(v);
237
+ }
238
+ return "".concat(symbol, " ").concat(v);
239
+ }
240
+ return v;
241
+ })
242
+ .join('');
243
+ }
@@ -0,0 +1,10 @@
1
+ import { FC, ReactNode, SyntheticEvent } from 'react';
2
+ export interface MarkdownButtonProps {
3
+ hintText: ReactNode;
4
+ icon: ReactNode;
5
+ onClick: (event: SyntheticEvent) => void;
6
+ text: string;
7
+ disabled?: boolean;
8
+ isLoading?: boolean;
9
+ }
10
+ export declare const MarkdownButton: FC<MarkdownButtonProps>;
@@ -0,0 +1,10 @@
1
+ import { Hint } from '@skbkontur/react-ui';
2
+ import React from 'react';
3
+ import { MarkdownButtonWrapper, VisuallyHidden } from '../Markdown.styled';
4
+ export var MarkdownButton = function (_a) {
5
+ var icon = _a.icon, hintText = _a.hintText, onClick = _a.onClick, isLoading = _a.isLoading, disabled = _a.disabled, text = _a.text;
6
+ return (React.createElement(Hint, { pos: "top center", manual: disabled, text: hintText, maxWidth: 300 },
7
+ React.createElement(MarkdownButtonWrapper, { borderless: true, loading: isLoading, disabled: disabled, onClick: onClick },
8
+ icon,
9
+ React.createElement(VisuallyHidden, null, text))));
10
+ };
@@ -0,0 +1,8 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { MarkdownFormat } from '../MarkdownFormat';
3
+ interface Props {
4
+ format: MarkdownFormat;
5
+ text: ReactNode;
6
+ }
7
+ export declare const MarkdownCombination: FC<Props>;
8
+ export {};
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { HintContentWrapper } from '../Markdown.styled';
3
+ import { markdownFormatToShortKey } from '../MarkdownHelpItems';
4
+ import { isMacintosh } from '../utils/isMacintosh';
5
+ export var MarkdownCombination = function (_a) {
6
+ var format = _a.format, text = _a.text;
7
+ var shortKey = markdownFormatToShortKey[format];
8
+ return (React.createElement(HintContentWrapper, null,
9
+ React.createElement("span", null, text),
10
+ !!shortKey && (React.createElement("span", null,
11
+ "CTRL+",
12
+ isMacintosh() ? '⌥' : 'ALT',
13
+ "+",
14
+ markdownFormatToShortKey[format]))));
15
+ };
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ import { MarkdownButtonProps } from './MarkdownButton';
3
+ import { MarkdownFormat } from '../MarkdownFormat';
4
+ interface Props extends MarkdownButtonProps {
5
+ format?: MarkdownFormat;
6
+ }
7
+ export declare const MarkdownFormatButton: FC<Props>;
8
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Hint } from '@skbkontur/react-ui';
2
+ import React from 'react';
3
+ import { MarkdownCombination } from './MarkdownCombination';
4
+ import { MarkdownButtonIcon, MarkdownButtonWrapper, VisuallyHidden } from '../Markdown.styled';
5
+ export var MarkdownFormatButton = function (_a) {
6
+ var icon = _a.icon, hintText = _a.hintText, onClick = _a.onClick, format = _a.format, disabled = _a.disabled, text = _a.text;
7
+ return (React.createElement(Hint, { manual: disabled, text: format ? React.createElement(MarkdownCombination, { format: format, text: hintText }) : hintText, pos: "top center", maxWidth: 340 },
8
+ React.createElement(MarkdownButtonWrapper, { borderless: true, disabled: disabled, onClick: onClick },
9
+ React.createElement(MarkdownButtonIcon, null, icon),
10
+ React.createElement(VisuallyHidden, null, text))));
11
+ };
@@ -0,0 +1,10 @@
1
+ import { Textarea } from '@skbkontur/react-ui';
2
+ import { KeyboardEvent as ReactKeyboardEvent, RefObject } from 'react';
3
+ import { MarkdownFormat } from '../MarkdownFormat';
4
+ import { Nullable, RefItem } from '../types';
5
+ export declare function setMarkdown(textareaNode: HTMLTextAreaElement, text: string, format: MarkdownFormat, selectionStart: number, selectionEnd?: number | null): void;
6
+ export declare function setMarkdownFiles(file: RefItem, textarea: Textarea, format: MarkdownFormat, cursorPosition?: number | null, fileApiUrl?: string): void;
7
+ export declare function setMarkdownPastedHtml(text: string, textareaNode: HTMLTextAreaElement): void;
8
+ export declare function setTextareaCursor(format: MarkdownFormat, prevCommentPartLength: number, nextCommentPartLength: number, textareaNode: HTMLTextAreaElement, selectionEnd: number): void;
9
+ export declare function createMarkdownHelpKeyDownHandler(text: string, ref?: RefObject<Textarea> | null, callback?: (event: ReactKeyboardEvent<HTMLTextAreaElement>) => void): (event: ReactKeyboardEvent<HTMLTextAreaElement>) => void;
10
+ export declare const usePasteFromClipboard: (textarea: Nullable<Textarea>, uploadFileApi?: ((file: File) => Promise<RefItem>) | undefined, downloadFileApi?: ((id: string) => Promise<File>) | undefined, fileApiUrl?: string) => void;