From 0efbc9b4dbf5bf6ff83ca7cd7589df173e7115a0 Mon Sep 17 00:00:00 2001 From: Martin Krulis Date: Wed, 22 May 2019 16:18:24 +0200 Subject: [PATCH] Hacking ACE Editor to hide cursor in read-only mode. --- .../forms/Fields/MarkdownTextAreaField.js | 5 +- .../forms/Fields/SourceCodeField.js | 46 ++++++++++--------- src/containers/App/recodex.css | 12 +++++ 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/components/forms/Fields/MarkdownTextAreaField.js b/src/components/forms/Fields/MarkdownTextAreaField.js index 1ef11c790..270bc7e89 100644 --- a/src/components/forms/Fields/MarkdownTextAreaField.js +++ b/src/components/forms/Fields/MarkdownTextAreaField.js @@ -40,10 +40,7 @@ class MarkdownTextAreaField extends Component { - this.toggleShowPreview()}> + diff --git a/src/components/forms/Fields/SourceCodeField.js b/src/components/forms/Fields/SourceCodeField.js index 5cf4b18b5..6d9e7d0d2 100644 --- a/src/components/forms/Fields/SourceCodeField.js +++ b/src/components/forms/Fields/SourceCodeField.js @@ -11,32 +11,35 @@ import { loadAceEditor, getAceModeFromExtension } from '../../helpers/AceEditorL let AceEditor = loadAceEditor(); const SourceCodeField = ( - { input, mode, meta: { error, warning }, label = null, children, tabIndex, onBlur, ...props }, + { input, mode, meta: { error, warning }, label = null, children, tabIndex, onBlur, readOnly = false, ...props }, { userSettings: { vimMode = false, darkTheme = false } } ) => ( {Boolean(label) && {label}} - input.onBlur() // this is a hack that will ensure blur call witout distorting the contents - } - editorProps={{ - $blockScrolling: Infinity, - $autoScrollEditorIntoView: true, - }} - /> +
+ input.onBlur() // this is a hack that will ensure blur call witout distorting the contents + } + editorProps={{ + $blockScrolling: Infinity, + $autoScrollEditorIntoView: true, + }} + /> +
{error && {error} } {!error && warning && {warning} } @@ -61,6 +64,7 @@ SourceCodeField.propTypes = { PropTypes.element, PropTypes.shape({ type: PropTypes.oneOf([FormattedMessage]) }), ]), + readOnly: PropTypes.bool, onBlur: PropTypes.func, }; diff --git a/src/containers/App/recodex.css b/src/containers/App/recodex.css index 9a5e5a8ad..9e1abd9bf 100644 --- a/src/containers/App/recodex.css +++ b/src/containers/App/recodex.css @@ -184,3 +184,15 @@ th.shrink-col { .wider-tooltip>.tooltip-inner { max-width: 300px; } + + +/* + * ACE Editor Overrides + */ +.noselection .ace_marker-layer .ace_selection { + background: transparent !important; +} + +.noselection .ace_cursor { + color: transparent !important; +}