diff --git a/CHANGELOG.md b/CHANGELOG.md index 9793011ca4f..c5bc3419ba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Added icons to match Kibana's app directory [(#162)](https://github.com/elastic/eui/pull/162) - Convert icons from SVG to React component during the build and stop using sprites [(#160)](https://github.com/elastic/eui/pull/160) +- Add `isReadOnly`, `setOptions`, and `cursorStart` props to `` ([#169](https://github.com/elastic/eui/pull/169)) **Bug fixes** diff --git a/src-docs/src/views/code_editor/code_editor_example.js b/src-docs/src/views/code_editor/code_editor_example.js index 66a35f7a9d8..bf68115b17a 100644 --- a/src-docs/src/views/code_editor/code_editor_example.js +++ b/src-docs/src/views/code_editor/code_editor_example.js @@ -16,6 +16,10 @@ import CodeEditor from './code_editor'; const codeEditorSource = require('!!raw-loader!./code_editor'); const codeEditorHtml = renderToHtml(CodeEditor); +import ReadOnly from './read_only'; +const readOnlySource = require('!!raw-loader!./read_only'); +const readOnlyrHtml = renderToHtml(ReadOnly); + export default props => ( ( } /> + + + } + /> ); diff --git a/src-docs/src/views/code_editor/read_only.js b/src-docs/src/views/code_editor/read_only.js new file mode 100644 index 00000000000..6a3cefcc5d6 --- /dev/null +++ b/src-docs/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 { + EuiCodeEditor, +} from '../../../../src/components'; + +export default class extends Component { + state = { + value: '

This code is read only

' + }; + + render() { + return ( + + ); + } +} diff --git a/src/components/code_editor/__snapshots__/code_editor.test.js.snap b/src/components/code_editor/__snapshots__/code_editor.test.js.snap index 2fd2cf4f1b5..865da505adc 100644 --- a/src/components/code_editor/__snapshots__/code_editor.test.js.snap +++ b/src/components/code_editor/__snapshots__/code_editor.test.js.snap @@ -1,27 +1,31 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EuiCodeEditor hint element should be disabled when the ui ace box gains focus 1`] = ` +exports[`EuiCodeEditor 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[`EuiCodeEditor hint element should be enabled when the ui ace box loses focus 1`] = ` +exports[`EuiCodeEditor 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 + .

`; -exports[`EuiCodeEditor hint element should be tabable 1`] = ` +exports[`EuiCodeEditor behavior hint element should be tabable 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 + .

`; @@ -75,12 +87,12 @@ exports[`EuiCodeEditor is rendered 1`] = ` tabindex="0" >

Press Enter to start editing.

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

@@ -175,3 +187,117 @@ exports[`EuiCodeEditor is rendered 1`] = ` `; + +exports[`EuiCodeEditor 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. +

+
+
+