Skip to content

Commit

Permalink
UX improvements in source code views, diffs, and reviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Dec 4, 2022
1 parent ce8bf1c commit 59858dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/components/Solutions/SourceCodeBox/SourceCodeBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import ResourceRenderer from '../../helpers/ResourceRenderer';
import Icon, { CodeCompareIcon, DownloadIcon, LoadingIcon, WarningIcon } from '../../icons';

import { getPrismModeFromExtension } from '../../helpers/syntaxHighlighting';
import { getFileExtensionLC } from '../../../helpers/common';
import { getFileExtensionLC, simpleScalarMemoize } from '../../../helpers/common';

const normalizeLineEndings = simpleScalarMemoize(content => content.replaceAll('\r', ''));

const diffViewHighlightSyntax = lang => str =>
str && (
Expand Down Expand Up @@ -201,8 +203,8 @@ const SourceCodeBox = ({
) : secondContent && !secondContent.malformedCharacters ? (
<div className="diff-wrapper">
<ReactDiffViewer
oldValue={content.content}
newValue={secondContent.content}
oldValue={normalizeLineEndings(content.content)}
newValue={normalizeLineEndings(secondContent.content)}
splitView={true}
renderContent={diffViewHighlightSyntax(getPrismModeFromExtension(getFileExtensionLC(name)))}
compareMethod={DiffMethod.WORDS_WITH_SPACE}
Expand Down
19 changes: 18 additions & 1 deletion src/components/forms/ReviewCommentForm/ReviewCommentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ const ReviewCommentForm = ({
<FormattedMessage id="app.reviewCommentForm.labelEdit" defaultMessage="Modify existing commment:" />
)}
</FormLabel>
<Field name="text" component={MarkdownTextAreaField} validate={textValidator} />
<Field
name="text"
component={MarkdownTextAreaField}
validate={textValidator}
focus
commands={[
{
name: 'save',
bindKey: { win: 'Ctrl-enter', mac: 'Cmd-enter' },
exec: editor => {
const button = editor.container.closest('.commentForm').querySelector('button[type=submit]');
if (button) {
button.click();
}
},
},
]}
/>
<hr />
</Col>
</Row>
Expand Down

0 comments on commit 59858dd

Please sign in to comment.