Skip to content

Commit

Permalink
- 编辑内容时记住光标位置
Browse files Browse the repository at this point in the history
- 修复编辑图标不显示的问题
  • Loading branch information
oldj committed Sep 7, 2017
1 parent a2c0ed6 commit 8e1304c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions app-ui/content/Content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class Content extends React.Component {
})}>{current.error}</div>
<Editor
readonly={readonly}
id={current.id}
code={current.content || ''}
setValue={this.setValue.bind(this)}
show_search={show_search}
Expand Down
21 changes: 13 additions & 8 deletions app-ui/content/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'codemirror/lib/codemirror.css'
import styles from './Editor.less'

import modeHosts from './cm_hl'

modeHosts()

export default class Editor extends React.Component {
Expand Down Expand Up @@ -186,11 +187,14 @@ export default class Editor extends React.Component {
}

componentWillReceiveProps (next_props) {
// console.log(next_props);
//console.log(next_props);
let cm = this.codemirror
let v = cm.getDoc().getValue()
let doc = cm.getDoc()
let v = doc.getValue()
if (v !== next_props.code) {
cm.getDoc().setValue(next_props.code)
let cursor_pos = doc.getCursor()
doc.setValue(next_props.code)
doc.setCursor(cursor_pos)
}
cm.setOption('readOnly', next_props.readonly)
setTimeout(() => {
Expand All @@ -207,11 +211,12 @@ export default class Editor extends React.Component {
[styles.root]: 1,
readonly: this.props.readonly,
[styles.show_search]: this.props.show_search
})}>
<textarea
ref={(c) => this.cnt_node = c}
defaultValue={this.props.code || ''}
/>
})}
>
<textarea
ref={(c) => this.cnt_node = c}
defaultValue={this.props.code || ''}
/>
</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion app-ui/panel/ListItem.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}

&:hover {
i.icon-edit {
:global(i.icon-edit) {
display: inline-block;
color: #fff;
}
Expand Down Expand Up @@ -62,4 +62,5 @@
.item-buttons {
position: absolute;
right: 10px;
margin-top: -2px;
}
2 changes: 1 addition & 1 deletion app-ui/panel/Panel.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../cfg.less';
//@import '../assets/iconfont/iconfont.css';
//@import '../styles/iconfont/iconfont.css';

.root {
position: fixed;
Expand Down
4 changes: 2 additions & 2 deletions app/ui/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exports.version = [3,3,7,5319];
exports.version = [3,3,7,5321];

0 comments on commit 8e1304c

Please sign in to comment.