-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBufferEditor.js
65 lines (60 loc) · 1.78 KB
/
BufferEditor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from 'react'
import IconUp from 'material-ui/svg-icons/navigation/arrow-upward'
import EditorPaper from 'components/EditorPaper'
import EditorHeader, { closeIconConfig } from 'components/EditorHeader'
const BufferEditor = ({buffer, onTextChanged, onCursorActivity, onSwapWithParent, onClose, style, isFocused}) => {
const {id, text:bufferText, metaData} = buffer
const {syntaxError, hasConnectedError} = metaData
let onEditorTextChange = ({value}) => {
if (value === bufferText) {
// text was changed by store
return
}
onTextChanged({
buffer,
newText: value
})
}
let onEditorActivity = (cursor) => onCursorActivity({
cursor,
buffer
})
let onCloseClick = () => {
onClose({
id
})
}
let onSwapWithParentClick = () => {
onSwapWithParent({
id
})
}
let editorProps = {
error: syntaxError,
hasConnectedError,
text: bufferText,
onTextChange: onEditorTextChange,
onActivity: onEditorActivity
}
let title = buffer.path || metaData.title
let headerProps = {
titlePrefix: 'buffer:',
title,
error: syntaxError,
hasConnectedError,
iconConfigs: [
{
tooltip: 'swap with parent function editor',
onTouchTap: onSwapWithParentClick,
Icon: IconUp
},
{
...closeIconConfig,
onTouchTap: onCloseClick
}
]
}
let header = <EditorHeader {...headerProps} />
return <EditorPaper style={ style } header={ header } editorProps={ editorProps } isFocused={ isFocused } />
}
export default BufferEditor