diff --git a/ui_framework/dist/ui_framework.css b/ui_framework/dist/ui_framework.css index bd4e82c6b101d..a926f5382fb9b 100644 --- a/ui_framework/dist/ui_framework.css +++ b/ui_framework/dist/ui_framework.css @@ -688,6 +688,10 @@ input[type="button"] { .kuiCodeEditorWrapper { position: relative; } + .kuiCodeEditorWrapper .ace_hidden-cursors { + opacity: 0; } + .kuiCodeEditorWrapper.kuiCodeEditorWrapper-isEditing .ace_hidden-cursors { + opacity: 1; } .kuiCodeEditorKeyboardHint { position: absolute; diff --git a/ui_framework/doc_site/src/views/code_editor/code_editor_example.js b/ui_framework/doc_site/src/views/code_editor/code_editor_example.js index 35afd30f04473..e8af21a45ceb4 100644 --- a/ui_framework/doc_site/src/views/code_editor/code_editor_example.js +++ b/ui_framework/doc_site/src/views/code_editor/code_editor_example.js @@ -11,6 +11,9 @@ import { import CodeEditor from './code_editor'; const codeEditorSource = require('!!raw-loader!./code_editor'); +import ReadOnly from './read_only'; +const readOnlySource = require('!!raw-loader!./read_only'); + export default props => ( ( + + + + + + ); diff --git a/ui_framework/doc_site/src/views/code_editor/read_only.js b/ui_framework/doc_site/src/views/code_editor/read_only.js new file mode 100644 index 0000000000000..5c455e5e89a60 --- /dev/null +++ b/ui_framework/doc_site/src/views/code_editor/read_only.js @@ -0,0 +1,27 @@ +import React, { Component } from 'react'; + +import 'brace/mode/less'; +import 'brace/theme/github'; + +import { + KuiCodeEditor +} from '../../../../components'; + +export default class extends Component { + state = { + value: '

This code is read only

' + }; + + render() { + return ( + + ); + } +} diff --git a/ui_framework/src/components/code_editor/__snapshots__/code_editor.test.js.snap b/ui_framework/src/components/code_editor/__snapshots__/code_editor.test.js.snap index c4faf3450cac8..971c88b219d5f 100644 --- a/ui_framework/src/components/code_editor/__snapshots__/code_editor.test.js.snap +++ b/ui_framework/src/components/code_editor/__snapshots__/code_editor.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`KuiCodeEditor hint element should be disabled when the ui ace box gains focus 1`] = ` +exports[`KuiCodeEditor behavior hint element should be disabled when the ui ace box gains focus 1`] = `
- Press Enter to start editing. + Press Enter to start + editing + .

- When you’re done, press Escape to stop editing. + When you’re done, press Escape to stop + editing + .

`; -exports[`KuiCodeEditor hint element should be enabled when the ui ace box loses focus 1`] = ` +exports[`KuiCodeEditor behavior hint element should be enabled when the ui ace box loses focus 1`] = `
- Press Enter to start editing. + Press Enter to start + editing + .

- When you’re done, press Escape to stop editing. + When you’re done, press Escape to stop + editing + .

`; @@ -60,12 +68,28 @@ exports[`KuiCodeEditor is rendered 1`] = `

- Press Enter to start editing. + + Press Enter to start + + + editing + + + . +

- When you’re done, press Escape to stop editing. + + When you’re done, press Escape to stop + + + editing + + + . +

`; + +exports[`KuiCodeEditor props isReadOnly renders alternate hint text 1`] = ` +
+
+

+ + Press Enter to start + + + interacting with the code + + + . + +

+

+ + When you’re done, press Escape to stop + + + interacting with the code + + + . + +

+
+
+