@skbkontur/markdown 2.6.3 → 2.7.0-alpha.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 (61) hide show
  1. package/package.json +2 -2
  2. package/src/Markdown/Emoji/Emoji.logic.js +4 -4
  3. package/src/Markdown/Emoji/Emoji.styled.js +14 -21
  4. package/src/Markdown/Emoji/EmojiDropdown.js +6 -11
  5. package/src/Markdown/Emoji/helpers.js +4 -4
  6. package/src/Markdown/Files/Files.logic.js +46 -108
  7. package/src/Markdown/Markdown.creevey.js +73 -221
  8. package/src/Markdown/Markdown.js +62 -86
  9. package/src/Markdown/Markdown.styled.js +251 -90
  10. package/src/Markdown/MarkdownActions/AIActionsDropdown/AIActionsDropdown.js +45 -111
  11. package/src/Markdown/MarkdownActions/AIActionsDropdown/AIActionsDropdown.styled.js +16 -8
  12. package/src/Markdown/MarkdownActions/AIActionsDropdown/constants.js +2 -2
  13. package/src/Markdown/MarkdownActions/MarkdownActions.js +24 -37
  14. package/src/Markdown/MarkdownActions/MarkdownDropdown/MarkdownDropdown.js +3 -7
  15. package/src/Markdown/MarkdownActions/MarkdownDropdown/MarkdownDropdown.styled.js +8 -6
  16. package/src/Markdown/MarkdownEditor.js +6 -28
  17. package/src/Markdown/MarkdownHelpItems.js +61 -63
  18. package/src/Markdown/MarkdownHelpers/EmptyPreview.js +1 -1
  19. package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.js +6 -7
  20. package/src/Markdown/MarkdownHelpers/constants.js +2 -2
  21. package/src/Markdown/MarkdownHelpers/markdownHelpers.d.ts +1 -0
  22. package/src/Markdown/MarkdownHelpers/markdownHelpers.js +50 -47
  23. package/src/Markdown/MarkdownHelpers/markdownListEnterHelpers.d.ts +2 -0
  24. package/src/Markdown/MarkdownHelpers/markdownListEnterHelpers.js +45 -0
  25. package/src/Markdown/MarkdownHelpers/markdownMentionHelpers.js +12 -12
  26. package/src/Markdown/MarkdownHelpers/markdownTextareaHelpers.js +34 -36
  27. package/src/Markdown/MarkdownMention.js +18 -64
  28. package/src/Markdown/constants.js +6 -6
  29. package/src/Markdown/utils/guid.js +13 -18
  30. package/src/Markdown/utils/htmlToMd.js +2 -2
  31. package/src/Markdown/utils/onInsertText.d.ts +1 -0
  32. package/src/Markdown/utils/onInsertText.js +3 -0
  33. package/src/Markdown/utils/saveFile.js +4 -4
  34. package/src/MarkdownCombination/MarkdownCombination.js +8 -9
  35. package/src/MarkdownCombination/MarkdownCombination.styled.js +7 -6
  36. package/src/MarkdownIcons/AttachLink.js +2 -2
  37. package/src/MarkdownIcons/AttachPaperclip.js +2 -2
  38. package/src/MarkdownIcons/CheckboxCheckedIcon.js +2 -2
  39. package/src/MarkdownIcons/CheckboxUncheckedIcon.js +2 -2
  40. package/src/MarkdownIcons/CheckedList.js +2 -2
  41. package/src/MarkdownIcons/Collapse.js +2 -2
  42. package/src/MarkdownIcons/Copy.js +1 -1
  43. package/src/MarkdownIcons/DocIcon.js +2 -2
  44. package/src/MarkdownIcons/EmojiFace.js +2 -2
  45. package/src/MarkdownIcons/EmptyPrviewArrow.js +1 -1
  46. package/src/MarkdownIcons/Expand.js +2 -2
  47. package/src/MarkdownIcons/EyeOpen.js +2 -2
  48. package/src/MarkdownIcons/List.js +2 -2
  49. package/src/MarkdownIcons/MarkdownIcons.styled.js +3 -6
  50. package/src/MarkdownIcons/NatureFxSparkleA2.js +1 -1
  51. package/src/MarkdownIcons/NumberedList.js +2 -2
  52. package/src/MarkdownIcons/SplitView.js +1 -1
  53. package/src/MarkdownIcons/Table.js +2 -2
  54. package/src/MarkdownIcons/ToolPencil.js +2 -2
  55. package/src/MarkdownViewer/Helpers/MarkdownImage.js +1 -2
  56. package/src/MarkdownViewer/Helpers/MarkdownLink.js +1 -4
  57. package/src/MarkdownViewer/Helpers/MarkdownTable.js +1 -2
  58. package/src/MarkdownViewer/MarkdownViewer.js +18 -26
  59. package/src/MarkdownViewer/MarkdownViewer.styles.js +163 -19
  60. package/src/styles/styled-components.js +1 -1
  61. package/src/styles/theme.js +5 -5
@@ -1,25 +1,3 @@
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
1
  import { SidePage, ThemeContext, useResponsiveLayout } from '@skbkontur/react-ui';
24
2
  import { HideBodyVerticalScroll } from '@skbkontur/react-ui/internal/HideBodyVerticalScroll';
25
3
  import React, { useEffect, useLayoutEffect, useRef, useState, } from 'react';
@@ -37,123 +15,122 @@ import { getCursorCoordinates, useFullscreenHorizontalPadding, useListenTextarea
37
15
  import { MarkdownMention } from './MarkdownMention';
38
16
  import { ViewMode } from './types';
39
17
  import { Guid } from './utils/guid';
18
+ import { onInsertText } from './utils/onInsertText';
40
19
  import { RequestStatus } from './utils/requestStatus';
41
20
  import { MarkdownViewer } from '../MarkdownViewer';
42
21
  import { ThemeProvider } from '../styles/styled-components';
43
22
  import { DEFAULT_MARKDOWN_THEME, MarkdownThemeConsumer } from '../styles/theme';
44
- export var Markdown = function (props) {
45
- var _a;
46
- var panelHorizontalPadding = props.panelHorizontalPadding, onClick = props.onClick, onChange = props.onChange, onSelect = props.onSelect, markdownViewer = props.markdownViewer, renderFilesValidation = props.renderFilesValidation, fileApiUrl = props.fileApiUrl, profileUrl = props.profileUrl, api = props.api, borderless = props.borderless, showActionHints = props.showActionHints, showShortKeys = props.showShortKeys, _b = props.showShotKeys, showShotKeys = _b === void 0 ? true : _b, hideActionsOptions = props.hideActionsOptions, onChangeViewMode = props.onChangeViewMode, textareaProps = __rest(props, ["panelHorizontalPadding", "onClick", "onChange", "onSelect", "markdownViewer", "renderFilesValidation", "fileApiUrl", "profileUrl", "api", "borderless", "showActionHints", "showShortKeys", "showShotKeys", "hideActionsOptions", "onChangeViewMode"]);
47
- var _c = useState(), mention = _c[0], setMention = _c[1];
48
- var _d = useState(ViewMode.Edit), viewMode = _d[0], setViewMode = _d[1];
49
- var _e = useState(false), fullscreen = _e[0], setFullScreen = _e[1];
50
- var _f = useState(0), initialWidth = _f[0], setInitialWidth = _f[1];
51
- var _g = useState(), selectionStart = _g[0], setSelectionStart = _g[1];
52
- var _h = useState(), selectionEnd = _h[0], setSelectionEnd = _h[1];
53
- var guid = useRef(new Guid().generate()).current;
54
- var textareaRef = useRef(null);
55
- var textareaNode = getTextareaNode();
56
- var isEditMode = viewMode !== ViewMode.Preview;
57
- var width = fullscreen || !textareaProps.width ? '100%' : textareaProps.width;
58
- var _j = useResponsiveLayout({
23
+ export const Markdown = props => {
24
+ const { panelHorizontalPadding, onClick, onChange, onSelect, markdownViewer, renderFilesValidation, fileApiUrl, profileUrl, api, borderless, showActionHints, showShortKeys, showShotKeys = true, hideActionsOptions, onChangeViewMode, ...textareaProps } = props;
25
+ const [mention, setMention] = useState();
26
+ const [viewMode, setViewMode] = useState(ViewMode.Edit);
27
+ const [fullscreen, setFullScreen] = useState(false);
28
+ const [initialWidth, setInitialWidth] = useState(0);
29
+ const [selectionStart, setSelectionStart] = useState();
30
+ const [selectionEnd, setSelectionEnd] = useState();
31
+ const guid = useRef(new Guid().generate()).current;
32
+ const textareaRef = useRef(null);
33
+ const textareaNode = getTextareaNode();
34
+ const isEditMode = viewMode !== ViewMode.Preview;
35
+ const width = fullscreen || !textareaProps.width ? '100%' : textareaProps.width;
36
+ const { isSplitViewAvailable, isMobile } = useResponsiveLayout({
59
37
  customMediaQueries: {
60
- isSplitViewAvailable: "(width >= ".concat(SPLIT_VIEW_THRESHOLD, ")"),
38
+ isSplitViewAvailable: `(width >= ${SPLIT_VIEW_THRESHOLD})`,
61
39
  },
62
- }), isSplitViewAvailable = _j.isSplitViewAvailable, isMobile = _j.isMobile;
63
- var _k = useFileLogic(api === null || api === void 0 ? void 0 : api.fileUploadApi, api === null || api === void 0 ? void 0 : api.fileDownloadApi, fileApiUrl, textareaRef.current, selectionStart, !isEditMode), getRootProps = _k.getRootProps, getInputProps = _k.getInputProps, isDragActive = _k.isDragActive, requestStatus = _k.requestStatus, open = _k.open, error = _k.error, onResetError = _k.onResetError;
64
- var onSelectEmoji = useEmojiLogic(textareaRef.current).onSelectEmoji;
65
- usePasteFromClipboard(textareaRef.current, api === null || api === void 0 ? void 0 : api.fileUploadApi, api === null || api === void 0 ? void 0 : api.fileDownloadApi, fileApiUrl);
40
+ });
41
+ const { getRootProps, getInputProps, isDragActive, requestStatus, open, error, onResetError } = useFileLogic(api?.fileUploadApi, api?.fileDownloadApi, fileApiUrl, textareaRef.current, selectionStart, !isEditMode);
42
+ const { onSelectEmoji } = useEmojiLogic(textareaRef.current);
43
+ usePasteFromClipboard(textareaRef.current, api?.fileUploadApi, api?.fileDownloadApi, fileApiUrl);
66
44
  useListenTextareaScroll(resetMention, textareaRef.current);
67
- var fullscreenTextareaPadding = useFullscreenHorizontalPadding(fullscreen, viewMode, initialWidth);
68
- useLayoutEffect(function () {
69
- var textareaNode = getTextareaNode();
45
+ const fullscreenTextareaPadding = useFullscreenHorizontalPadding(fullscreen, viewMode, initialWidth);
46
+ useLayoutEffect(() => {
47
+ const textareaNode = getTextareaNode();
70
48
  if (textareaNode)
71
49
  setInitialWidth(textareaNode.clientWidth);
72
50
  }, []);
73
- useEffect(function () {
51
+ useEffect(() => {
74
52
  if (fullscreen && isSplitViewAvailable)
75
53
  setViewMode(ViewMode.Split);
76
54
  else
77
- setViewMode(function (prevMode) { return (prevMode === ViewMode.Split ? ViewMode.Edit : prevMode); });
55
+ setViewMode(prevMode => (prevMode === ViewMode.Split ? ViewMode.Edit : prevMode));
78
56
  }, [fullscreen, isSplitViewAvailable]);
79
- useEffect(function () {
57
+ useEffect(() => {
80
58
  if (isMobile)
81
59
  setFullScreen(false);
82
60
  }, [isMobile]);
83
- useEffect(function () {
61
+ useEffect(() => {
84
62
  if (fullscreen && isEditMode && textareaRef) {
85
- var textareaNode_1 = getTextareaNode();
86
- if (textareaNode_1 && !textareaNode_1.selectionStart && !textareaNode_1.selectionEnd) {
87
- textareaNode_1.focus();
88
- textareaNode_1.selectionStart = selectionStart !== null && selectionStart !== void 0 ? selectionStart : 0;
89
- textareaNode_1.selectionEnd = selectionEnd !== null && selectionEnd !== void 0 ? selectionEnd : 0;
63
+ const textareaNode = getTextareaNode();
64
+ if (textareaNode && !textareaNode.selectionStart && !textareaNode.selectionEnd) {
65
+ textareaNode.focus();
66
+ textareaNode.selectionStart = selectionStart ?? 0;
67
+ textareaNode.selectionEnd = selectionEnd ?? 0;
90
68
  }
91
69
  }
92
70
  }, [fullscreen, isEditMode, selectionEnd, selectionStart, textareaRef]);
93
- useEffect(function () {
94
- var handleSelectionChange = function () {
95
- var textareaNode = getTextareaNode();
96
- setSelectionStart(textareaNode === null || textareaNode === void 0 ? void 0 : textareaNode.selectionStart);
97
- setSelectionEnd(textareaNode === null || textareaNode === void 0 ? void 0 : textareaNode.selectionEnd);
71
+ useEffect(() => {
72
+ const handleSelectionChange = () => {
73
+ const textareaNode = getTextareaNode();
74
+ setSelectionStart(textareaNode?.selectionStart);
75
+ setSelectionEnd(textareaNode?.selectionEnd);
98
76
  };
99
77
  document.addEventListener('selectionchange', handleSelectionChange);
100
- return function () { return document.removeEventListener('selectionchange', handleSelectionChange); };
78
+ return () => document.removeEventListener('selectionchange', handleSelectionChange);
101
79
  }, []);
102
- var horizontalPaddings = {
80
+ const horizontalPaddings = {
103
81
  panelPadding: panelHorizontalPadding,
104
82
  fullscreenPadding: fullscreenTextareaPadding,
105
83
  };
106
- var content = (React.createElement(Foco, { component: "div", onClickOutside: resetStates },
107
- React.createElement(Wrapper, __assign({}, getRootProps()),
108
- React.createElement("input", __assign({}, getInputProps())),
109
- !(hideActionsOptions === null || hideActionsOptions === void 0 ? void 0 : hideActionsOptions.allActions) && (React.createElement(MarkdownActions, { showActionHints: showActionHints !== undefined ? showActionHints : showShotKeys, showShortKeys: showShortKeys !== undefined ? showShortKeys : showShotKeys, textAreaRef: textareaRef, width: width, viewMode: viewMode, loadingFile: requestStatus === RequestStatus.isFetching, fullscreen: fullscreen, selectionStart: selectionStart, selectionEnd: selectionEnd, horizontalPaddings: horizontalPaddings, hideOptions: hideActionsOptions, hasFilesApi: !!(api === null || api === void 0 ? void 0 : api.fileDownloadApi) && !!(api === null || api === void 0 ? void 0 : api.fileUploadApi), isSplitViewAvailable: isSplitViewAvailable, disableFullscreen: isMobile, AIApi: api === null || api === void 0 ? void 0 : api.AIApi, onOpenFileDialog: open, onChangeViewMode: handleChangeViewMode, onClickFullscreen: handleClickFullscreen, onSelectEmoji: onSelectEmoji })),
110
- isEditMode && error && (api === null || api === void 0 ? void 0 : api.getUsersApi) && (renderFilesValidation === null || renderFilesValidation === void 0 ? void 0 : renderFilesValidation(horizontalPaddings, onResetError)),
84
+ const content = (React.createElement(Foco, { component: "div", onClickOutside: resetStates },
85
+ React.createElement(Wrapper, { ...getRootProps() },
86
+ React.createElement("input", { ...getInputProps() }),
87
+ !hideActionsOptions?.allActions && (React.createElement(MarkdownActions, { showActionHints: showActionHints !== undefined ? showActionHints : showShotKeys, showShortKeys: showShortKeys !== undefined ? showShortKeys : showShotKeys, textAreaRef: textareaRef, width: width, viewMode: viewMode, loadingFile: requestStatus === RequestStatus.isFetching, fullscreen: fullscreen, selectionStart: selectionStart, selectionEnd: selectionEnd, horizontalPaddings: horizontalPaddings, hideOptions: hideActionsOptions, hasFilesApi: !!api?.fileDownloadApi && !!api?.fileUploadApi, isSplitViewAvailable: isSplitViewAvailable, disableFullscreen: isMobile, AIApi: api?.AIApi, onOpenFileDialog: open, onChangeViewMode: handleChangeViewMode, onClickFullscreen: handleClickFullscreen, onSelectEmoji: onSelectEmoji })),
88
+ isEditMode && error && api?.getUsersApi && renderFilesValidation?.(horizontalPaddings, onResetError),
111
89
  fullscreen && viewMode === ViewMode.Split && !fullscreenTextareaPadding && (React.createElement(SplitViewContainer, null,
112
90
  React.createElement(SplitViewEditContainer, null, renderEditContainer()),
113
- React.createElement(SplitViewPreviewContainer, { textareaWidth: ((_a = textareaProps.width) === null || _a === void 0 ? void 0 : _a.toString().includes('%')) ? initialWidth : textareaProps.width }, renderPreview()))),
91
+ React.createElement(SplitViewPreviewContainer, { textareaWidth: textareaProps.width?.toString().includes('%') ? initialWidth : textareaProps.width }, renderPreview()))),
114
92
  viewMode === ViewMode.Edit && renderEditContainer(),
115
93
  viewMode === ViewMode.Preview && renderPreview(),
116
- isDragActive && isEditMode && React.createElement(DroppablePlaceholder, __assign({}, horizontalPaddings)))));
117
- return (React.createElement(MarkdownThemeConsumer, null, function (theme) {
118
- var defaultTheme = theme !== null && theme !== void 0 ? theme : DEFAULT_MARKDOWN_THEME;
119
- var reactUiTheme = getMarkdownReactUiTheme(defaultTheme, viewMode, theme === null || theme === void 0 ? void 0 : theme.reactUiTheme, panelHorizontalPadding, fullscreenTextareaPadding, borderless, fullscreen);
94
+ isDragActive && isEditMode && React.createElement(DroppablePlaceholder, { ...horizontalPaddings }))));
95
+ return (React.createElement(MarkdownThemeConsumer, null, theme => {
96
+ const defaultTheme = theme ?? DEFAULT_MARKDOWN_THEME;
97
+ const reactUiTheme = getMarkdownReactUiTheme(defaultTheme, viewMode, theme?.reactUiTheme, panelHorizontalPadding, fullscreenTextareaPadding, borderless, fullscreen);
120
98
  return (React.createElement(ThemeProvider, { theme: defaultTheme },
121
99
  React.createElement(ThemeContext.Provider, { value: reactUiTheme }, fullscreen ? renderFullScreen() : content)));
122
100
  }));
123
101
  function renderFullScreen() {
124
- return (React.createElement(SidePage, { disableAnimations: true, width: "100vw", onClose: function () { return setFullScreen(false); } },
102
+ return (React.createElement(SidePage, { disableAnimations: true, width: "100vw", onClose: () => setFullScreen(false) },
125
103
  React.createElement(HideBodyVerticalScroll, null),
126
104
  React.createElement(SidePage.Body, null,
127
105
  React.createElement(SidePage.Container, null, viewMode === ViewMode.Split ? (React.createElement(FlexCenter, null,
128
106
  React.createElement(SplitViewMaxWidth, null, content))) : (content)))));
129
107
  }
130
108
  function renderEditContainer() {
131
- var showMention = !!mention && !!getMentionValue(mention);
109
+ const showMention = !!mention && !!getMentionValue(mention);
132
110
  return (React.createElement(MarkdownEditorBlock, null,
133
- React.createElement(MentionWrapper, { id: "".concat(guid).concat(MENTION_WRAPPER_ID_POSTFIX) }),
111
+ React.createElement(MentionWrapper, { id: `${guid}${MENTION_WRAPPER_ID_POSTFIX}` }),
134
112
  showMention && renderMentions(),
135
- React.createElement(MarkdownEditor, __assign({}, textareaProps, { maxRows: fullscreen ? undefined : textareaProps.maxRows, width: width, textareaRef: textareaRef, onChange: listenChange, onSelect: listenSelect, onClick: listenClick }))));
113
+ React.createElement(MarkdownEditor, { ...textareaProps, maxRows: fullscreen ? undefined : textareaProps.maxRows, width: width, textareaRef: textareaRef, onChange: listenChange, onSelect: listenSelect, onClick: listenClick })));
136
114
  }
137
115
  function renderPreview() {
138
- var _a;
139
116
  if (!props.value && viewMode === ViewMode.Split)
140
117
  return React.createElement(EmptyPreview, null);
141
- return (React.createElement(MarkdownPreview, __assign({}, horizontalPaddings, { viewMode: viewMode, width: width }), (markdownViewer === null || markdownViewer === void 0 ? void 0 : markdownViewer(props.value)) || (React.createElement(MarkdownViewer, { source: (_a = props.value) !== null && _a !== void 0 ? _a : '', downloadFileApi: api === null || api === void 0 ? void 0 : api.fileDownloadApi, fileApiUrl: fileApiUrl, profileUrl: profileUrl }))));
118
+ return (React.createElement(MarkdownPreview, { ...horizontalPaddings, viewMode: viewMode, width: width }, markdownViewer?.(props.value) || (React.createElement(MarkdownViewer, { source: props.value ?? '', downloadFileApi: api?.fileDownloadApi, fileApiUrl: fileApiUrl, profileUrl: profileUrl }))));
142
119
  }
143
120
  function renderMentions() {
144
- if (textareaNode && mention && (api === null || api === void 0 ? void 0 : api.getUsersApi)) {
145
- var position = getCursorCoordinates(textareaNode, guid);
121
+ if (textareaNode && mention && api?.getUsersApi) {
122
+ const position = getCursorCoordinates(textareaNode, guid);
146
123
  return (React.createElement(MarkdownMention, { value: getMentionValue(mention), getUsersApi: api.getUsersApi, y: position.y, x: position.x, onSelectUser: handleSelectUser }));
147
124
  }
148
125
  }
149
126
  function handleChangeViewMode(mode) {
150
127
  setViewMode(mode);
151
- onChangeViewMode === null || onChangeViewMode === void 0 ? void 0 : onChangeViewMode(mode);
128
+ onChangeViewMode?.(mode);
152
129
  }
153
130
  function handleSelectUser(login, name) {
154
131
  if (textareaNode && mention) {
155
132
  textareaNode.setSelectionRange(mention.positions[0] ? mention.positions[0] - 1 : 0, mention.positions[1]);
156
- document.execCommand('insertText', false, "[".concat(name, "](@").concat(login, ")"));
133
+ onInsertText(`[${name}](@${login})`);
157
134
  resetMention();
158
135
  }
159
136
  }
@@ -170,24 +147,23 @@ export var Markdown = function (props) {
170
147
  checkMention(event);
171
148
  }
172
149
  function checkMention(event) {
173
- if (api === null || api === void 0 ? void 0 : api.getUsersApi)
150
+ if (api?.getUsersApi)
174
151
  mentionActions(event, setMention);
175
152
  }
176
153
  function resetStates() {
177
154
  resetMention();
178
155
  setSelectionStart(undefined);
179
156
  setSelectionEnd(undefined);
180
- textareaNode === null || textareaNode === void 0 ? void 0 : textareaNode.setSelectionRange(0, 0);
157
+ textareaNode?.setSelectionRange(0, 0);
181
158
  }
182
159
  function resetMention() {
183
160
  setMention(undefined);
184
161
  }
185
162
  function handleClickFullscreen() {
186
- setViewMode(function (prevState) { return (prevState !== ViewMode.Split && isSplitViewAvailable ? ViewMode.Split : ViewMode.Edit); });
163
+ setViewMode(prevState => (prevState !== ViewMode.Split && isSplitViewAvailable ? ViewMode.Split : ViewMode.Edit));
187
164
  setFullScreen(!fullscreen);
188
165
  }
189
166
  function getTextareaNode() {
190
- var _a;
191
- return (_a = textareaRef === null || textareaRef === void 0 ? void 0 : textareaRef.current) === null || _a === void 0 ? void 0 : _a.node;
167
+ return textareaRef?.current?.node;
192
168
  }
193
169
  };
@@ -1,118 +1,279 @@
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
1
  import { Button, MenuItem, ThemeFactory } from '@skbkontur/react-ui';
17
2
  import { FULLSCREEN_HEIGHT } from './constants';
18
3
  import { ViewMode } from './types';
19
4
  import styled, { css } from '../styles/styled-components';
20
- var panelStyle = function (_a) {
21
- var panelPadding = _a.panelPadding, theme = _a.theme;
22
- 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);
23
- };
5
+ const panelStyle = ({ panelPadding, theme }) => css `
6
+ padding: 6px ${panelPadding ?? 0}px;
7
+ background-color: ${theme.colors.panelBg};
8
+ margin-bottom: 12px;
9
+ `;
24
10
  function getAllowedCssValue(value) {
25
11
  return typeof value === 'number' ? value + 'px' : value;
26
12
  }
27
13
  function getMarkdownActionsPadding(isPadding, padding) {
28
14
  return isPadding ? getAllowedCssValue(padding) : 0;
29
15
  }
30
- 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; });
31
- var scrollbarStyle = css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: ", ";\n overflow-y: auto;\n"], ["\n height: ", ";\n overflow-y: auto;\n"])), FULLSCREEN_HEIGHT);
32
- export var FlexCenter = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n"], ["\n display: flex;\n justify-content: center;\n"])));
33
- export var SplitViewMaxWidth = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n max-width: 1580px;\n width: 100%;\n"], ["\n max-width: 1580px;\n width: 100%;\n"])));
34
- export var SplitViewContainer = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: flex;\n gap: 32px;\n\n @media (width >= 1980px) {\n gap: 48px;\n }\n"], ["\n display: flex;\n gap: 32px;\n\n @media (width >= 1980px) {\n gap: 48px;\n }\n"])));
35
- export var SplitViewPreviewContainer = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", ";\n\n width: ", ";\n ", ";\n"], ["\n ", ";\n\n width: ", ";\n ", ";\n"])), scrollbarStyle, function (p) { return (p.textareaWidth ? getAllowedCssValue(p.textareaWidth) : undefined); }, function (p) { return !p.textareaWidth && 'flex: 1 0 0'; });
36
- export var SplitViewEditContainer = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n width: 100%;\n min-width: 420px;\n flex: 1 0 0;\n"], ["\n width: 100%;\n min-width: 420px;\n flex: 1 0 0;\n"])));
37
- export var Avatar = styled.img.attrs({ alt: '' })(templateObject_9 || (templateObject_9 = __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; });
38
- export var UserWrapper = styled.div(templateObject_10 || (templateObject_10 = __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"])));
39
- export var DroppablePlaceholder = styled.div(templateObject_11 || (templateObject_11 = __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 : ''; });
40
- export var MentionWrapper = styled.div(templateObject_12 || (templateObject_12 = __makeTemplateObject([""], [""])));
41
- export var MarkdownPreview = styled.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n padding: 6px\n ", "px;\n ", "\n box-sizing: border-box;\n"], ["\n padding: 6px\n ", "px;\n ", "\n box-sizing: border-box;\n"])), function (_a) {
42
- var _b;
43
- var panelPadding = _a.panelPadding, fullscreenPadding = _a.fullscreenPadding, viewMode = _a.viewMode;
16
+ export const Wrapper = styled.div `
17
+ position: relative;
18
+
19
+ &:focus-visible {
20
+ outline: 1px solid ${p => p.theme.colors.brand};
21
+ }
22
+ `;
23
+ const scrollbarStyle = css `
24
+ height: ${FULLSCREEN_HEIGHT};
25
+ overflow-y: auto;
26
+ `;
27
+ export const FlexCenter = styled.div `
28
+ display: flex;
29
+ justify-content: center;
30
+ `;
31
+ export const SplitViewMaxWidth = styled.div `
32
+ max-width: 1580px;
33
+ width: 100%;
34
+ `;
35
+ export const SplitViewContainer = styled.div `
36
+ display: flex;
37
+ gap: 32px;
38
+
39
+ @media (width >= 1980px) {
40
+ gap: 48px;
41
+ }
42
+ `;
43
+ export const SplitViewPreviewContainer = styled.div `
44
+ ${scrollbarStyle};
45
+
46
+ width: ${p => (p.textareaWidth ? getAllowedCssValue(p.textareaWidth) : undefined)};
47
+ ${p => !p.textareaWidth && 'flex: 1 0 0'};
48
+ `;
49
+ export const SplitViewEditContainer = styled.div `
50
+ width: 100%;
51
+ min-width: 420px;
52
+ flex: 1 0 0;
53
+ `;
54
+ export const Avatar = styled.img.attrs({ alt: '' }) `
55
+ flex-shrink: 0;
56
+ box-sizing: border-box;
57
+ border: 1px solid ${props => props.theme.colors.grayDefault};
58
+ border-radius: 50%;
59
+ object-fit: cover;
60
+ `;
61
+ export const UserWrapper = styled.div `
62
+ width: 244px;
63
+ display: flex;
64
+ align-items: center;
65
+ gap: 12px;
66
+ `;
67
+ export const DroppablePlaceholder = styled.div `
68
+ position: absolute;
69
+ top: ${p => (p.panelPadding || p.fullscreenPadding ? 0 : -8)}px;
70
+ left: ${p => (p.panelPadding || p.fullscreenPadding ? 0 : -8)}px;
71
+ width: 100%;
72
+ height: 100%;
73
+ padding: ${p => (p.panelPadding || p.fullscreenPadding ? 0 : 8)}px;
74
+ border-radius: 8px;
75
+ z-index: 100;
76
+ background: linear-gradient(0deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.04)),
77
+ rgba(255, 255, 255, ${p => (p.theme.themeMode === 'dark' ? 0.1 : 0.7)});
78
+ background-image: ${p => p.theme?.droppablePlaceholderBgImage ?? ''};
79
+ `;
80
+ export const MentionWrapper = styled.div ``;
81
+ export const MarkdownPreview = styled.div `
82
+ padding: 6px
83
+ ${({ panelPadding, fullscreenPadding, viewMode }) => {
44
84
  if (viewMode === ViewMode.Split)
45
85
  return 0;
46
- return (_b = fullscreenPadding !== null && fullscreenPadding !== void 0 ? fullscreenPadding : panelPadding) !== null && _b !== void 0 ? _b : 8;
47
- }, function (p) { return p.width && "width: ".concat(getAllowedCssValue(p.width), ";"); });
48
- export var MarkdownActionsWrapper = styled.div(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n padding: ", "\n ", " 0;\n margin-bottom: ", "px;\n box-sizing: border-box;\n ", "\n ", "\n \n a {\n border: none !important;\n text-decoration: none !important;\n }\n"], ["\n padding: ", "\n ", " 0;\n margin-bottom: ", "px;\n box-sizing: border-box;\n ", "\n ", "\n \n a {\n border: none !important;\n text-decoration: none !important;\n }\n"])), function (p) { return getMarkdownActionsPadding(!!p.fullscreenPadding, '16px'); }, function (p) { return getMarkdownActionsPadding(!!p.fullscreenPadding, p.fullscreenPadding); }, function (p) { return (p.fullscreen ? 12 : 4); }, function (p) { return p.width && "width: ".concat(getAllowedCssValue(p.width), ";"); }, function (_a) {
49
- var theme = _a.theme, panelPadding = _a.panelPadding, fullscreen = _a.fullscreen;
86
+ return fullscreenPadding ?? panelPadding ?? 8;
87
+ }}px;
88
+ ${p => p.width && `width: ${getAllowedCssValue(p.width)};`}
89
+ box-sizing: border-box;
90
+ `;
91
+ export const MarkdownActionsWrapper = styled.div `
92
+ padding: ${p => getMarkdownActionsPadding(!!p.fullscreenPadding, '16px')}
93
+ ${p => getMarkdownActionsPadding(!!p.fullscreenPadding, p.fullscreenPadding)} 0;
94
+ margin-bottom: ${p => (p.fullscreen ? 12 : 4)}px;
95
+ box-sizing: border-box;
96
+ ${p => p.width && `width: ${getAllowedCssValue(p.width)};`}
97
+ ${({ theme, panelPadding, fullscreen }) => {
50
98
  if (panelPadding && !fullscreen)
51
- return panelStyle({ theme: theme, panelPadding: panelPadding });
52
- });
53
- export var ButtonsWrapper = styled.div(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n display: flex;\n justify-content: space-between;\n border-bottom: ", ";\n"], ["\n display: flex;\n justify-content: space-between;\n border-bottom: ", ";\n"])), function (p) { return (p.fullscreen ? "1px solid ".concat(p.theme.colors.grayDefault) : 'none'); });
54
- export var ViewModeButtonsWrapper = styled.div(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
55
- export var ActionsRightWrapper = styled.div(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
56
- export var ActionsLeftWrapper = styled(ActionsRightWrapper)(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n flex-wrap: wrap;\n"], ["\n flex-wrap: wrap;\n"])));
57
- export var MarkdownButtonWrapper = styled(Button)(templateObject_19 || (templateObject_19 = __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"])));
58
- export var MarkdownButtonContentWrapper = styled.div(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n display: flex;\n gap: 4px;\n align-items: center;\n"], ["\n display: flex;\n gap: 4px;\n align-items: center;\n"])));
59
- export var MarkdownButtonIcon = styled.div(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n height: 22px;\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n"], ["\n height: 22px;\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n"])));
60
- export var MarkdownSymbolWrapper = styled.span(templateObject_22 || (templateObject_22 = __makeTemplateObject(["\n color: ", ";\n font-weight: 700;\n"], ["\n color: ", ";\n font-weight: 700;\n"])), function (p) { return p.theme.colors.brand; });
61
- export var MarkdownMenuItem = styled(MenuItem)(templateObject_23 || (templateObject_23 = __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.text; });
62
- export var MarkdownEditorBlock = styled.div(templateObject_24 || (templateObject_24 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
63
- export var getMarkdownMentionStyle = function (x, y) { return ({
99
+ return panelStyle({ theme, panelPadding });
100
+ }}
101
+
102
+ a {
103
+ border: none !important;
104
+ text-decoration: none !important;
105
+ }
106
+ `;
107
+ export const ButtonsWrapper = styled.div `
108
+ display: flex;
109
+ justify-content: space-between;
110
+ border-bottom: ${p => (p.fullscreen ? `1px solid ${p.theme.colors.grayDefault}` : 'none')};
111
+ `;
112
+ export const ViewModeButtonsWrapper = styled.div `
113
+ display: flex;
114
+ `;
115
+ export const ActionsRightWrapper = styled.div `
116
+ display: flex;
117
+ `;
118
+ export const ActionsLeftWrapper = styled(ActionsRightWrapper) `
119
+ flex-wrap: wrap;
120
+ `;
121
+ export const MarkdownButtonWrapper = styled(Button) `
122
+ button {
123
+ padding: 4px;
124
+ border: none;
125
+ box-sizing: border-box;
126
+ }
127
+ `;
128
+ export const MarkdownButtonContentWrapper = styled.div `
129
+ display: flex;
130
+ gap: 4px;
131
+ align-items: center;
132
+ `;
133
+ export const MarkdownButtonIcon = styled.div `
134
+ height: 22px;
135
+ display: flex;
136
+ width: 100%;
137
+ align-items: center;
138
+ justify-content: center;
139
+ `;
140
+ export const MarkdownSymbolWrapper = styled.span `
141
+ color: ${p => p.theme.colors.brand};
142
+ font-weight: 700;
143
+ `;
144
+ export const MarkdownMenuItem = styled(MenuItem) `
145
+ padding-left: 8px;
146
+ padding-right: 8px;
147
+ color: ${p => p.theme.colors.text};
148
+ `;
149
+ export const MarkdownEditorBlock = styled.div `
150
+ position: relative;
151
+ `;
152
+ export const getMarkdownMentionStyle = (x, y) => ({
64
153
  position: 'absolute',
65
154
  top: y,
66
155
  left: x,
67
- }); };
68
- export var UserDescriptions = styled.div(templateObject_25 || (templateObject_25 = __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"])));
69
- export var MentionMenuItem = styled(MenuItem)(templateObject_26 || (templateObject_26 = __makeTemplateObject(["\n padding: 4px 28px;\n"], ["\n padding: 4px 28px;\n"])));
70
- export var VisuallyHidden = styled.span(templateObject_27 || (templateObject_27 = __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"])));
71
- export var EmptyPreviewContainer = styled.div(templateObject_28 || (templateObject_28 = __makeTemplateObject(["\n display: flex;\n width: 407px;\n flex-direction: column;\n"], ["\n display: flex;\n width: 407px;\n flex-direction: column;\n"])));
72
- export var EmptyPreviewText = styled.span(templateObject_29 || (templateObject_29 = __makeTemplateObject(["\n font-weight: 700;\n font-size: 40px;\n line-height: 48px;\n color: #d6d6d6;\n"], ["\n font-weight: 700;\n font-size: 40px;\n line-height: 48px;\n color: #d6d6d6;\n"])));
73
- export var EmptyPreviewIconWrapper = styled.div(templateObject_30 || (templateObject_30 = __makeTemplateObject(["\n margin-top: 16px;\n margin-bottom: 32px;\n"], ["\n margin-top: 16px;\n margin-bottom: 32px;\n"])));
74
- var extendThemeConfigWithSized = function (config) {
75
- var finalConfig = {};
76
- var configKeys = Object.keys(config);
77
- configKeys.forEach(function (key) {
156
+ });
157
+ export const UserDescriptions = styled.div `
158
+ white-space: pre-line;
159
+ overflow-wrap: break-word;
160
+ word-wrap: break-word;
161
+ word-break: break-word;
162
+ overflow: hidden;
163
+ margin-top: 4px;
164
+ `;
165
+ export const MentionMenuItem = styled(MenuItem) `
166
+ padding: 4px 28px;
167
+ `;
168
+ export const VisuallyHidden = styled.span `
169
+ position: absolute;
170
+ width: 1px;
171
+ height: 1px;
172
+ padding: 0;
173
+ margin: -1px;
174
+ overflow: hidden;
175
+ clip: rect(0, 0, 0, 0);
176
+ border: 0;
177
+ `;
178
+ export const EmptyPreviewContainer = styled.div `
179
+ display: flex;
180
+ width: 407px;
181
+ flex-direction: column;
182
+ `;
183
+ export const EmptyPreviewText = styled.span `
184
+ font-weight: 700;
185
+ font-size: 40px;
186
+ line-height: 48px;
187
+ color: #d6d6d6;
188
+ `;
189
+ export const EmptyPreviewIconWrapper = styled.div `
190
+ margin-top: 16px;
191
+ margin-bottom: 32px;
192
+ `;
193
+ const extendThemeConfigWithSized = (config) => {
194
+ const finalConfig = {};
195
+ const configKeys = Object.keys(config);
196
+ configKeys.forEach(key => {
78
197
  if (key !== 'prototype') {
79
- finalConfig["".concat(key, "Small")] = config[key];
80
- finalConfig["".concat(key, "Medium")] = config[key];
81
- finalConfig["".concat(key, "Large")] = config[key];
198
+ finalConfig[`${key}Small`] = config[key];
199
+ finalConfig[`${key}Medium`] = config[key];
200
+ finalConfig[`${key}Large`] = config[key];
82
201
  }
83
202
  });
84
203
  return finalConfig;
85
204
  };
86
- var borderlessTextareaVariables = {
205
+ const borderlessTextareaVariables = {
87
206
  textareaBorderColor: 'transparent',
88
207
  textareaBorderColorFocus: 'transparent',
89
208
  textareaBorderTopColor: 'transparent',
90
209
  textareaBorderColorHover: 'transparent',
91
210
  textareaShadow: 'none',
92
211
  };
93
- export var getMarkdownReactUiTheme = function (theme, viewMode, reactUiTheme, panelHorizontalPadding, fullScreenTextareaPadding, borderless, isFullscreen) {
94
- var elementsFontSize = theme.elementsFontSize, elementsLineHeight = theme.elementsLineHeight, themeMode = theme.themeMode, colors = theme.colors;
95
- var isSplitMode = viewMode === ViewMode.Split;
96
- var sidePagePaddingX = isSplitMode ? '56px' : '0';
97
- var isFullscreenNotSplitMode = isFullscreen && !isSplitMode;
98
- return ThemeFactory.create(__assign(__assign(__assign(__assign(__assign({}, extendThemeConfigWithSized({
99
- tabFontSize: elementsFontSize,
100
- tabPaddingY: '0',
101
- tabPaddingX: '6px',
102
- tabLineHeight: elementsLineHeight,
103
- checkboxPaddingY: '0',
104
- checkboxBoxSize: elementsFontSize,
105
- menuItemFontSize: elementsFontSize,
106
- menuItemPaddingY: '4px',
107
- menuItemPaddingX: '28px',
108
- })), { dropdownPaddingXSmall: '4px', dropdownPaddingYSmall: '4px', tabColorHover: 'transparent', tabColorFocus: 'transparent', 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, 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, hintFontSize: elementsFontSize, hintColor: colors.textInverse, selectPaddingXSmall: '8px', selectLineHeightSmall: '24px', dropdownBorderWidth: '0' }), (panelHorizontalPadding &&
109
- !isSplitMode &&
110
- extendThemeConfigWithSized({
111
- textareaPaddingX: "".concat(panelHorizontalPadding, "px"),
112
- }))), ((borderless || (isFullscreen && viewMode === ViewMode.Edit)) && borderlessTextareaVariables)), (isFullscreen &&
113
- __assign({ sidePagePaddingLeft: sidePagePaddingX, sidePagePaddingRight: sidePagePaddingX, textareaBorderColorError: 'transparent', textareaBorderColorWarning: 'transparent', textareaShadow: 'none' }, extendThemeConfigWithSized(__assign({ textareaMinHeight: FULLSCREEN_HEIGHT }, (isFullscreenNotSplitMode && {
114
- textareaPaddingX: "".concat(fullScreenTextareaPadding, "px"),
115
- textareaPaddingY: '0',
116
- })))))), reactUiTheme);
212
+ export const getMarkdownReactUiTheme = (theme, viewMode, reactUiTheme, panelHorizontalPadding, fullScreenTextareaPadding, borderless, isFullscreen) => {
213
+ const { elementsFontSize, elementsLineHeight, themeMode, colors } = theme;
214
+ const isSplitMode = viewMode === ViewMode.Split;
215
+ const sidePagePaddingX = isSplitMode ? '56px' : '0';
216
+ const isFullscreenNotSplitMode = isFullscreen && !isSplitMode;
217
+ return ThemeFactory.create({
218
+ ...extendThemeConfigWithSized({
219
+ tabFontSize: elementsFontSize,
220
+ tabPaddingY: '0',
221
+ tabPaddingX: '6px',
222
+ tabLineHeight: elementsLineHeight,
223
+ checkboxPaddingY: '0',
224
+ checkboxBoxSize: elementsFontSize,
225
+ menuItemFontSize: elementsFontSize,
226
+ menuItemPaddingY: '4px',
227
+ menuItemPaddingX: '28px',
228
+ }),
229
+ dropdownPaddingXSmall: '4px',
230
+ dropdownPaddingYSmall: '4px',
231
+ tabColorHover: 'transparent',
232
+ tabColorFocus: 'transparent',
233
+ tabBorderWidth: '0',
234
+ selectBorderWidth: '0',
235
+ btnDefaultBg: 'transparent',
236
+ btnDefaultActiveBorderColor: 'transparent',
237
+ btnDisabledBg: 'transparent',
238
+ btnDisabledBorderColor: 'transparent',
239
+ btnDisabledTextColor: colors.disabledButton,
240
+ btnDefaultHoverBg: themeMode === 'light' ? reactUiTheme?.btnDefaultHoverBg : reactUiTheme?.btnDisabledBg,
241
+ btnFontSizeSmall: elementsFontSize,
242
+ checkboxBg: 'transparent',
243
+ checkboxHoverBg: 'transparent',
244
+ checkboxCheckedBg: 'transparent',
245
+ checkboxShadow: `0 0 0 1px ${colors.grayDefault}`,
246
+ checkboxShadowHover: `0 0 0 1px ${colors.grayDefault}`,
247
+ checkboxCheckedHoverShadow: `0 0 0 1px ${colors.grayDefault}`,
248
+ checkboxCheckedShadow: `0 0 0 1px ${colors.grayDefault}`,
249
+ checkboxCheckedActiveShadow: `0 0 0 1px ${colors.grayDefault}`,
250
+ checkboxShadowActive: `0 0 0 1px ${colors.grayDefault}`,
251
+ checkboxCheckedColor: colors.grayDefault,
252
+ hintFontSize: elementsFontSize,
253
+ hintColor: colors.textInverse,
254
+ selectPaddingXSmall: '8px',
255
+ selectLineHeightSmall: '24px',
256
+ dropdownBorderWidth: '0',
257
+ ...(panelHorizontalPadding &&
258
+ !isSplitMode &&
259
+ extendThemeConfigWithSized({
260
+ textareaPaddingX: `${panelHorizontalPadding}px`,
261
+ })),
262
+ ...((borderless || (isFullscreen && viewMode === ViewMode.Edit)) && borderlessTextareaVariables),
263
+ ...(isFullscreen &&
264
+ {
265
+ sidePagePaddingLeft: sidePagePaddingX,
266
+ sidePagePaddingRight: sidePagePaddingX,
267
+ textareaBorderColorError: 'transparent',
268
+ textareaBorderColorWarning: 'transparent',
269
+ textareaShadow: 'none',
270
+ ...extendThemeConfigWithSized({
271
+ textareaMinHeight: FULLSCREEN_HEIGHT,
272
+ ...(isFullscreenNotSplitMode && {
273
+ textareaPaddingX: `${fullScreenTextareaPadding}px`,
274
+ textareaPaddingY: '0',
275
+ }),
276
+ }),
277
+ }),
278
+ }, reactUiTheme);
117
279
  };
118
- 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, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30;