@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.
- package/package.json +2 -2
- package/src/Markdown/Emoji/Emoji.logic.js +4 -4
- package/src/Markdown/Emoji/Emoji.styled.js +14 -21
- package/src/Markdown/Emoji/EmojiDropdown.js +6 -11
- package/src/Markdown/Emoji/helpers.js +4 -4
- package/src/Markdown/Files/Files.logic.js +46 -108
- package/src/Markdown/Markdown.creevey.js +73 -221
- package/src/Markdown/Markdown.js +62 -86
- package/src/Markdown/Markdown.styled.js +251 -90
- package/src/Markdown/MarkdownActions/AIActionsDropdown/AIActionsDropdown.js +45 -111
- package/src/Markdown/MarkdownActions/AIActionsDropdown/AIActionsDropdown.styled.js +16 -8
- package/src/Markdown/MarkdownActions/AIActionsDropdown/constants.js +2 -2
- package/src/Markdown/MarkdownActions/MarkdownActions.js +24 -37
- package/src/Markdown/MarkdownActions/MarkdownDropdown/MarkdownDropdown.js +3 -7
- package/src/Markdown/MarkdownActions/MarkdownDropdown/MarkdownDropdown.styled.js +8 -6
- package/src/Markdown/MarkdownEditor.js +6 -28
- package/src/Markdown/MarkdownHelpItems.js +61 -63
- package/src/Markdown/MarkdownHelpers/EmptyPreview.js +1 -1
- package/src/Markdown/MarkdownHelpers/MarkdownFormatButton.js +6 -7
- package/src/Markdown/MarkdownHelpers/constants.js +2 -2
- package/src/Markdown/MarkdownHelpers/markdownHelpers.d.ts +1 -0
- package/src/Markdown/MarkdownHelpers/markdownHelpers.js +50 -47
- package/src/Markdown/MarkdownHelpers/markdownListEnterHelpers.d.ts +2 -0
- package/src/Markdown/MarkdownHelpers/markdownListEnterHelpers.js +45 -0
- package/src/Markdown/MarkdownHelpers/markdownMentionHelpers.js +12 -12
- package/src/Markdown/MarkdownHelpers/markdownTextareaHelpers.js +34 -36
- package/src/Markdown/MarkdownMention.js +18 -64
- package/src/Markdown/constants.js +6 -6
- package/src/Markdown/utils/guid.js +13 -18
- package/src/Markdown/utils/htmlToMd.js +2 -2
- package/src/Markdown/utils/onInsertText.d.ts +1 -0
- package/src/Markdown/utils/onInsertText.js +3 -0
- package/src/Markdown/utils/saveFile.js +4 -4
- package/src/MarkdownCombination/MarkdownCombination.js +8 -9
- package/src/MarkdownCombination/MarkdownCombination.styled.js +7 -6
- package/src/MarkdownIcons/AttachLink.js +2 -2
- package/src/MarkdownIcons/AttachPaperclip.js +2 -2
- package/src/MarkdownIcons/CheckboxCheckedIcon.js +2 -2
- package/src/MarkdownIcons/CheckboxUncheckedIcon.js +2 -2
- package/src/MarkdownIcons/CheckedList.js +2 -2
- package/src/MarkdownIcons/Collapse.js +2 -2
- package/src/MarkdownIcons/Copy.js +1 -1
- package/src/MarkdownIcons/DocIcon.js +2 -2
- package/src/MarkdownIcons/EmojiFace.js +2 -2
- package/src/MarkdownIcons/EmptyPrviewArrow.js +1 -1
- package/src/MarkdownIcons/Expand.js +2 -2
- package/src/MarkdownIcons/EyeOpen.js +2 -2
- package/src/MarkdownIcons/List.js +2 -2
- package/src/MarkdownIcons/MarkdownIcons.styled.js +3 -6
- package/src/MarkdownIcons/NatureFxSparkleA2.js +1 -1
- package/src/MarkdownIcons/NumberedList.js +2 -2
- package/src/MarkdownIcons/SplitView.js +1 -1
- package/src/MarkdownIcons/Table.js +2 -2
- package/src/MarkdownIcons/ToolPencil.js +2 -2
- package/src/MarkdownViewer/Helpers/MarkdownImage.js +1 -2
- package/src/MarkdownViewer/Helpers/MarkdownLink.js +1 -4
- package/src/MarkdownViewer/Helpers/MarkdownTable.js +1 -2
- package/src/MarkdownViewer/MarkdownViewer.js +18 -26
- package/src/MarkdownViewer/MarkdownViewer.styles.js +163 -19
- package/src/styles/styled-components.js +1 -1
- package/src/styles/theme.js +5 -5
package/src/Markdown/Markdown.js
CHANGED
|
@@ -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
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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:
|
|
38
|
+
isSplitViewAvailable: `(width >= ${SPLIT_VIEW_THRESHOLD})`,
|
|
61
39
|
},
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
usePasteFromClipboard(textareaRef.current, api
|
|
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
|
-
|
|
68
|
-
useLayoutEffect(
|
|
69
|
-
|
|
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(
|
|
51
|
+
useEffect(() => {
|
|
74
52
|
if (fullscreen && isSplitViewAvailable)
|
|
75
53
|
setViewMode(ViewMode.Split);
|
|
76
54
|
else
|
|
77
|
-
setViewMode(
|
|
55
|
+
setViewMode(prevMode => (prevMode === ViewMode.Split ? ViewMode.Edit : prevMode));
|
|
78
56
|
}, [fullscreen, isSplitViewAvailable]);
|
|
79
|
-
useEffect(
|
|
57
|
+
useEffect(() => {
|
|
80
58
|
if (isMobile)
|
|
81
59
|
setFullScreen(false);
|
|
82
60
|
}, [isMobile]);
|
|
83
|
-
useEffect(
|
|
61
|
+
useEffect(() => {
|
|
84
62
|
if (fullscreen && isEditMode && textareaRef) {
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
setSelectionStart(textareaNode
|
|
97
|
-
setSelectionEnd(textareaNode
|
|
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
|
|
78
|
+
return () => document.removeEventListener('selectionchange', handleSelectionChange);
|
|
101
79
|
}, []);
|
|
102
|
-
|
|
80
|
+
const horizontalPaddings = {
|
|
103
81
|
panelPadding: panelHorizontalPadding,
|
|
104
82
|
fullscreenPadding: fullscreenTextareaPadding,
|
|
105
83
|
};
|
|
106
|
-
|
|
107
|
-
React.createElement(Wrapper,
|
|
108
|
-
React.createElement("input",
|
|
109
|
-
!
|
|
110
|
-
isEditMode && error &&
|
|
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:
|
|
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,
|
|
117
|
-
return (React.createElement(MarkdownThemeConsumer, null,
|
|
118
|
-
|
|
119
|
-
|
|
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:
|
|
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
|
-
|
|
109
|
+
const showMention = !!mention && !!getMentionValue(mention);
|
|
132
110
|
return (React.createElement(MarkdownEditorBlock, null,
|
|
133
|
-
React.createElement(MentionWrapper, { id:
|
|
111
|
+
React.createElement(MentionWrapper, { id: `${guid}${MENTION_WRAPPER_ID_POSTFIX}` }),
|
|
134
112
|
showMention && renderMentions(),
|
|
135
|
-
React.createElement(MarkdownEditor,
|
|
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,
|
|
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 &&
|
|
145
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
157
|
+
textareaNode?.setSelectionRange(0, 0);
|
|
181
158
|
}
|
|
182
159
|
function resetMention() {
|
|
183
160
|
setMention(undefined);
|
|
184
161
|
}
|
|
185
162
|
function handleClickFullscreen() {
|
|
186
|
-
setViewMode(
|
|
163
|
+
setViewMode(prevState => (prevState !== ViewMode.Split && isSplitViewAvailable ? ViewMode.Split : ViewMode.Edit));
|
|
187
164
|
setFullScreen(!fullscreen);
|
|
188
165
|
}
|
|
189
166
|
function getTextareaNode() {
|
|
190
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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[
|
|
80
|
-
finalConfig[
|
|
81
|
-
finalConfig[
|
|
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
|
-
|
|
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
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return ThemeFactory.create(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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;
|