浏览代码

- 编辑内容时记住光标位置
- 修复编辑图标不显示的问题

oldj 8 年之前
父节点
当前提交
cce7ad9434
共有 6 个文件被更改,包括 18 次插入12 次删除
  1. 1 0
      app-ui/content/Content.jsx
  2. 13 8
      app-ui/content/Editor.jsx
  3. 2 1
      app-ui/panel/ListItem.less
  4. 1 1
      app-ui/panel/Panel.less
  5. 0 1
      app/ui/bundle.js
  6. 1 1
      app/version.js

+ 1 - 0
app-ui/content/Content.jsx

@@ -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}

+ 13 - 8
app-ui/content/Editor.jsx

@@ -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 {
@@ -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(() => {
@@ -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>
     )
   }

+ 2 - 1
app-ui/panel/ListItem.less

@@ -25,7 +25,7 @@
     }
 
     &:hover {
-      i.icon-edit {
+      :global(i.icon-edit) {
         display: inline-block;
         color: #fff;
       }
@@ -62,4 +62,5 @@
 .item-buttons {
   position: absolute;
   right: 10px;
+  margin-top: -2px;
 }

+ 1 - 1
app-ui/panel/Panel.less

@@ -1,5 +1,5 @@
 @import '../cfg.less';
-//@import '../assets/iconfont/iconfont.css';
+//@import '../styles/iconfont/iconfont.css';
 
 .root {
   position: fixed;

文件差异内容过多而无法显示
+ 0 - 1
app/ui/bundle.js


+ 1 - 1
app/version.js

@@ -1 +1 @@
-exports.version = [3,3,7,5319];
+exports.version = [3,3,7,5321];

部分文件因为文件数量过多而无法显示