Skip to content

Commit 59858dd

Browse files
committed
UX improvements in source code views, diffs, and reviews.
1 parent ce8bf1c commit 59858dd

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/components/Solutions/SourceCodeBox/SourceCodeBox.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import ResourceRenderer from '../../helpers/ResourceRenderer';
1111
import Icon, { CodeCompareIcon, DownloadIcon, LoadingIcon, WarningIcon } from '../../icons';
1212

1313
import { getPrismModeFromExtension } from '../../helpers/syntaxHighlighting';
14-
import { getFileExtensionLC } from '../../../helpers/common';
14+
import { getFileExtensionLC, simpleScalarMemoize } from '../../../helpers/common';
15+
16+
const normalizeLineEndings = simpleScalarMemoize(content => content.replaceAll('\r', ''));
1517

1618
const diffViewHighlightSyntax = lang => str =>
1719
str && (
@@ -201,8 +203,8 @@ const SourceCodeBox = ({
201203
) : secondContent && !secondContent.malformedCharacters ? (
202204
<div className="diff-wrapper">
203205
<ReactDiffViewer
204-
oldValue={content.content}
205-
newValue={secondContent.content}
206+
oldValue={normalizeLineEndings(content.content)}
207+
newValue={normalizeLineEndings(secondContent.content)}
206208
splitView={true}
207209
renderContent={diffViewHighlightSyntax(getPrismModeFromExtension(getFileExtensionLC(name)))}
208210
compareMethod={DiffMethod.WORDS_WITH_SPACE}

src/components/forms/ReviewCommentForm/ReviewCommentForm.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,24 @@ const ReviewCommentForm = ({
4747
<FormattedMessage id="app.reviewCommentForm.labelEdit" defaultMessage="Modify existing commment:" />
4848
)}
4949
</FormLabel>
50-
<Field name="text" component={MarkdownTextAreaField} validate={textValidator} />
50+
<Field
51+
name="text"
52+
component={MarkdownTextAreaField}
53+
validate={textValidator}
54+
focus
55+
commands={[
56+
{
57+
name: 'save',
58+
bindKey: { win: 'Ctrl-enter', mac: 'Cmd-enter' },
59+
exec: editor => {
60+
const button = editor.container.closest('.commentForm').querySelector('button[type=submit]');
61+
if (button) {
62+
button.click();
63+
}
64+
},
65+
},
66+
]}
67+
/>
5168
<hr />
5269
</Col>
5370
</Row>

0 commit comments

Comments
 (0)