Commit e24ff46d authored by techird's avatar techird

dev

parent c08d830a
......@@ -149,9 +149,12 @@ kity.extendClass(Minder, {
function layoutNode(node) {
// layout all children first
node.children.forEach(function(child) {
layoutNode(child);
});
// 剪枝:收起的节点无需计算
if (node.isExpanded()) {
node.children.forEach(function(child) {
layoutNode(child);
});
}
var layout = node.getLayoutInstance();
layout.doLayout(node);
......
......@@ -38,6 +38,7 @@ var DEFAULT_TEXT = {
function importNode(node, json, km) {
var data = json.data;
node.data = {};
for (var field in data) {
node.setData(field, data[field]);
}
......@@ -105,9 +106,10 @@ kity.extendClass(Minder, {
json = params.json || (params.json = protocal.decode(local));
if (typeof json === 'object' && 'then' in json){
if (typeof json === 'object' && 'then' in json) {
var self = this;
json.then(local, function(data) {
params.json = data;
self._doImport(data, params);
});
} else {
......@@ -117,32 +119,27 @@ kity.extendClass(Minder, {
},
_doImport: function(json, params) {
try{
this._fire(new MinderEvent('preimport', params, false));
this._fire(new MinderEvent('preimport', params, false));
// 删除当前所有节点
while (this._root.getChildren().length) {
this.removeNode(this._root.getChildren()[0]);
}
// 删除当前所有节点
while (this._root.getChildren().length) {
this.removeNode(this._root.getChildren()[0]);
}
importNode(this._root, json, this);
this._root.preTraverse(function(node) {
node.render();
});
this._root.layout();
importNode(this._root, json, this);
this.fire('beforeimport', params);
this.fire('import', params);
this._root.preTraverse(function(node) {
node.render();
});
this._root.layout();
this._firePharse({
type: 'contentchange'
});
this._firePharse({
type: 'interactchange'
});
}catch(e){
this.fire('rendererror');
}
}
this.fire('import', params);
this._firePharse({
type: 'contentchange'
});
this._firePharse({
type: 'interactchange'
});
}
});
\ No newline at end of file
......@@ -75,7 +75,7 @@ KityMinder.registerModule('TextEditModule', function() {
if (node) {
var textShape = node.getRenderer('TextRenderer').getRenderShape();
textShape.setStyle('cursor', 'default');
if (this.isSingleSelect() && node.isSelected()) { // && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
if (this.isSingleSelect() && node.isSelected()) {
sel.collapse();
sel.setSelectionShowStatus(true);
......@@ -111,10 +111,14 @@ KityMinder.registerModule('TextEditModule', function() {
if (this.isSingleSelect() && node.isSelected()) {
var orgEvt = e.originEvent,
keyCode = orgEvt.keyCode;
if (!keymap.notContentInput[keyCode] && range.nativeSel.rangeCount !== 0 && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey) {
if (!keymap.notContentInput[keyCode] &&
range.nativeSel.rangeCount !== 0 &&
!orgEvt.ctrlKey && !orgEvt.metaKey &&
!orgEvt.shiftKey && !orgEvt.altKey) {
var nativeRange = range.nativeSel.getRangeAt(0);
if (nativeRange && (nativeRange.startContainer === receiver.container || receiver.container.contains(nativeRange.startContainer))) {
if (nativeRange && (nativeRange.startContainer === receiver.container ||
receiver.container.contains(nativeRange.startContainer))) {
km.setStatus('textedit');
sel.setSelectionShowStatus(true);
km.fire('saveScene');
......@@ -326,29 +330,13 @@ KityMinder.registerModule('TextEditModule', function() {
}
// if ((e.commandName == 'priority' || e.commandName == 'progress') && this.getStatus() == 'textedit') {
//
// sel.setHide();
// receiver.setBaseOffset()
// .getTextOffsetData();
////
//// if (sel.collapsed) {
//// receiver.updateSelection();
//// } else {
//// receiver.updateSelectionShow(1);
//// }
//
// return;
//
//
// }
receiver.clear().setTextEditStatus(false);
if (this.getStatus() == 'textedit') {
this.setStatus('normal');
}
},
'layoutfinish':function(e){
if(e.node === receiver.minderNode && this.getStatus() == 'textedit'){
'layoutfinish':function(e) {
if (e.node === receiver.minderNode && this.getStatus() == 'textedit') {
receiver
.setBaseOffset()
.setContainerStyle()
......
......@@ -149,10 +149,11 @@ KityMinder.registerModule('Expand', function() {
this.addShapes([this.outline, this.sign]);
this.initEvent(node);
this.setId(KityMinder.uuid('node_expander'));
this.setStyle('cursor', 'pointer');
},
initEvent: function(node) {
this.on('click', function(e) {
this.on('mousedown', function(e) {
if (node.isExpanded()) {
node.collapse();
} else {
......@@ -225,6 +226,9 @@ KityMinder.registerModule('Expand', function() {
'layoutapply': function(e) {
var r = e.node.getRenderer('ExpanderRenderer');
r.update(r.getRenderShape(), e.node);
},
'preimport': function(e) {
var json = e.json;
}
},
renderers: {
......
......@@ -7,7 +7,7 @@ KityMinder.registerModule("fontmodule", function() {
var dataColor = node.getData('color');
var selectedColor = node.getStyle('selected-color');
var styleColor = node.getStyle('color');
text.fill(dataColor || (node.isSelected() ? selectedColor : styleColor));
text.fill(dataColor || (node.isSelected() && selectedColor ? selectedColor : styleColor));
text.setFont({
family: getNodeDataOrStyle(node, 'font-family'),
size: getNodeDataOrStyle(node, 'font-size')
......
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