Commit 15202ad1 authored by campaign's avatar campaign

修复编辑节点

parent 91215a80
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
1. 添加保存时可修改文件名 1. 添加保存时可修改文件名
2. 添加超链接功能 2. 添加超链接功能
3. 选中节点时,按F2直接进入文字编辑状态 3. 选中节点时,按F2直接进入文字编辑状态
4. 展开所有收起节点 4. 添加展开收起节点
5. 当前选中的高亮的节点可直接进行文字编辑
###问题修复
##问题修复
1. 修复当滚动鼠标滚轮时,光标不跟着移动的问题 1. 修复当滚动鼠标滚轮时,光标不跟着移动的问题
2. 优化了拖拽节点操作体验 2. 优化了拖拽节点操作体验
3. 修复回退操作后所选节点未回选问题 3. 修复回退操作后所选节点未回选问题
4. 修复回退操作后展开收起的节点没有记录问题 4. 修复回退操作后展开收起的节点没有记录问题
5. ** 选中节点后可直接输入文字** 5. 优化了输入文字时的卡顿效果
6. 优化了输入文字时的卡顿效果 6. 优化了当输入中文时,中文显示位置与光标距离过远的问题
7. 优化了当输入中文时,中文显示位置与光标距离过远的问题
## v1.1.2 ## v1.1.2
......
...@@ -28,13 +28,13 @@ KM.registerUI( 'contextmenu', function () { ...@@ -28,13 +28,13 @@ KM.registerUI( 'contextmenu', function () {
}); });
me.$container.append($menu); me.$container.append($menu);
me.on('contextmenu',function(e){ me.on('contextmenu',function(e){
if(this.getSelectedNodes().length == 0){ var node = e.getTargetNode();
var node = e.getTargetNode(); if(node){
if(node){ this.removeAllSelectedNodes();
this.select(node); this.select(node)
}
} }
var items = me.getContextmenu(); var items = me.getContextmenu();
var data = []; var data = [];
......
...@@ -252,7 +252,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -252,7 +252,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
}, },
clone: function () { clone: function () {
function cloneNode( parent, isClonedNode,fn ) { function cloneNode( parent, isClonedNode) {
var _tmp = new KM.MinderNode( isClonedNode.getText() ); var _tmp = new KM.MinderNode( isClonedNode.getText() );
_tmp.data = Utils.clonePlainObject( isClonedNode.getData() ); _tmp.data = Utils.clonePlainObject( isClonedNode.getData() );
...@@ -264,13 +264,12 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -264,13 +264,12 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
} }
for ( var i = 0, ci; for ( var i = 0, ci;
( ci = isClonedNode.children[ i++ ] ); ) { ( ci = isClonedNode.children[ i++ ] ); ) {
cloneNode( _tmp, ci ,fn); cloneNode( _tmp, ci );
} }
fn && fn(isClonedNode,_tmp);
return _tmp; return _tmp;
} }
return function (fn) { return function () {
return cloneNode( null, this,fn ); return cloneNode( null, this );
}; };
}(), }(),
equals: function ( node ) { equals: function ( node ) {
......
...@@ -18,6 +18,30 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -18,6 +18,30 @@ KityMinder.registerModule( "TextEditModule", function () {
return km.receiver.isTextEditStatus(); return km.receiver.isTextEditStatus();
}; };
km.textEditNode = function(node){
var textShape = node.getTextShape();
this.setStatus('textedit');
sel.setHide();
sel.setStartOffset(0);
sel.setEndOffset(textShape.getContent().length);
receiver.setTextEditStatus(true)
.setSelection(sel)
.setKityMinder(this)
.setMinderNode(node)
.setTextShape(textShape)
.setRange(range)
.setBaseOffset()
.setContainerStyle()
.setSelectionHeight()
.setContainerTxt(textShape.getContent())
.updateTextData()
.updateSelectionShow()
.updateRange(range).setTextEditStatus(true);
sel.setData('relatedNode',node);
};
var selectionByClick = false; var selectionByClick = false;
var dragmoveTimer; var dragmoveTimer;
...@@ -72,7 +96,7 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -72,7 +96,7 @@ KityMinder.registerModule( "TextEditModule", function () {
sel.setShow(); sel.setShow();
selectionByClick = false; selectionByClick = false;
} }
km.setStatus('textedit') km.setStatus('textedit');
lastMousedownTimer = +new Date; lastMousedownTimer = +new Date;
} }
} }
......
...@@ -198,9 +198,11 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -198,9 +198,11 @@ Minder.Receiver = kity.createClass( 'Receiver', {
updateIndex: function () { updateIndex: function () {
this.index = this.range.getStart().startOffset; this.index = this.range.getStart().startOffset;
return this;
}, },
updateTextData: function () { updateTextData: function () {
this.textShape.textData = this.getTextOffsetData(); this.textShape.textData = this.getTextOffsetData();
return this;
}, },
setSelection: function ( selection ) { setSelection: function ( selection ) {
this.selection = selection; this.selection = selection;
......
...@@ -4,24 +4,13 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -4,24 +4,13 @@ KityMinder.registerModule( "HistoryModule", function () {
var Scene = kity.createClass( 'Scene', { var Scene = kity.createClass( 'Scene', {
constructor: function ( root ) { constructor: function ( root ) {
this.data = root.clone( function ( node, cloneNode ) { this.data = root.clone();
km.fire( 'cloneNode', {
'targetNode': cloneNode,
'sourceNode': node
} )
} );
}, },
getData: function () { getData: function () {
return this.data; return this.data;
}, },
cloneData: function () { cloneData: function () {
var fn = function ( node, cloneNode ) { return this.getData().clone( );
km.fire( 'cloneNode', {
'targetNode': cloneNode,
'sourceNode': node
} )
};
return this.getData().clone( fn );
}, },
equals: function ( scene ) { equals: function ( scene ) {
return this.getData().equals( scene.getData() ) return this.getData().equals( scene.getData() )
......
...@@ -210,6 +210,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -210,6 +210,7 @@ KityMinder.registerModule( "LayoutModule", function () {
return null; return null;
} }
km.select( selectedNode, true ); km.select( selectedNode, true );
km.textEditNode(selectedNode);
}, },
queryState: function ( km ) { queryState: function ( km ) {
var selectedNode = km.getSelectedNode(); var selectedNode = km.getSelectedNode();
...@@ -253,11 +254,6 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -253,11 +254,6 @@ KityMinder.registerModule( "LayoutModule", function () {
}, },
"import": function ( e ) { "import": function ( e ) {
this.initStyle(); this.initStyle();
},
"cloneNode": function ( e ) {
var target = e.targetNode;
var source = e.sourceNode;
target._layout = utils.extend( {}, source._layout );
} }
}, },
'contextmenu': [ { 'contextmenu': [ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment