Commit 1e0a7717 authored by techird's avatar techird

Merge branch 'dev' of github.com:fex-team/kityminder into dev

parents 938b2bb3 f2941b7f
# KityMinder 更新日志 # KityMinder 更新日志
## v1.3.0
### 体验优化
1. 当在空白处右键时,在菜单项中添加插入节点选项
### BUG修复
1. 修复在空白节点有时会出现a字符的问题
## v1.2.1 ## v1.2.1
### 体验优化 ### 体验优化
......
Subproject commit fec9187f532aea5284d1fac25767dcca9ad43ce4 Subproject commit f83c5f109addefd4f89ba11b4dfa88c191809e77
...@@ -14,6 +14,10 @@ KityMinder.LANG['zh-cn'] = { ...@@ -14,6 +14,10 @@ KityMinder.LANG['zh-cn'] = {
'fresh-purple': '浪漫紫', 'fresh-purple': '浪漫紫',
'fresh-pink': '脑残粉' 'fresh-pink': '脑残粉'
}, },
'insert':{
//'maintopic':'插入中心主题',
'topic':'插入分支主题'
},
'maintopic': '中心主题', 'maintopic': '中心主题',
'topic': '分支主题', 'topic': '分支主题',
'tooltips': { 'tooltips': {
......
describe("command", function () { describe("command", function () {
var kityMinderDiv = document.createElement("div");
kityMinderDiv.id = "kityminder";
kityMinderDiv.style.height = "500px";
kityMinderDiv.style.position = "relative";
var obj;
var km;
beforeEach(function(){
document.body.appendChild(kityMinderDiv);
km = KM.getKityMinder('kityminder');
obj = document.getElementById('kityminder');
});
afterEach(function(){
// obj = null;
// document.body.removeChild(kityMinderDiv);
});
it('',function(){ it('',function(){
}) })
......
describe("utils", function () { describe("utils", function () {
var kityMinderDiv = document.createElement("div");
kityMinderDiv.id = "kityminder";
kityMinderDiv.style.height = "500px";
kityMinderDiv.style.position = "relative";
var obj;
var km;
var flag = true;
beforeEach(function(){
if(flag){
document.getElementById('HTMLReporter').appendChild(kityMinderDiv);
km = KM.getKityMinder('kityminder');
obj = document.getElementById('kityminder');
flag = false;
}
});
afterEach(function(){
// document.body.removeChild(kityMinderDiv);
// console.log(km);
});
// var kityMinderDiv = document.createElement("div");
// kityMinderDiv.id = "kityminder";
// kityMinderDiv.style.height = "500px";
// kityMinderDiv.style.position = "relative";
// var obj;
// var km;
// var flag = true;
//
// if(flag){
// document.body.appendChild(kityMinderDiv);
// km = KM.getKityMinder('kityminder');
// obj = document.getElementById('kityminder');
// flag = false;
// }
describe('compareObject',function(){ describe('compareObject',function(){
...@@ -8,6 +48,31 @@ describe("utils", function () { ...@@ -8,6 +48,31 @@ describe("utils", function () {
}; };
var obj2 = utils.clonePlainObject(obj1); var obj2 = utils.clonePlainObject(obj1);
it('相等',function(){
// console.log(km);
console.log(document.getElementById('kityminder'));
expect(utils.compareObject(obj1,obj2)).toBeTruthy();
});
it('长度不同',function(){
obj2.test2 = '1';
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
it('数组中的数据不同',function(){
obj1.test[2] = {};
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
});
describe('compareObject',function(){
var obj1 = {
'test':[1,2],
'test1':1
};
var obj2 = utils.clonePlainObject(obj1);
it('相等',function(){ it('相等',function(){
expect(utils.compareObject(obj1,obj2)).toBeTruthy(); expect(utils.compareObject(obj1,obj2)).toBeTruthy();
}); });
...@@ -21,5 +86,126 @@ describe("utils", function () { ...@@ -21,5 +86,126 @@ describe("utils", function () {
expect(utils.compareObject(obj1,obj2)).toBeFalsy(); expect(utils.compareObject(obj1,obj2)).toBeFalsy();
}) })
}); });
describe('compareObject',function(){
var obj1 = {
'test':[1,2],
'test1':1
};
var obj2 = utils.clonePlainObject(obj1);
it('相等',function(){
expect(utils.compareObject(obj1,obj2)).toBeTruthy();
});
it('长度不同',function(){
obj2.test2 = '1';
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
it('数组中的数据不同',function(){
obj1.test[2] = {};
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
});describe('compareObject',function(){
var obj1 = {
'test':[1,2],
'test1':1
};
var obj2 = utils.clonePlainObject(obj1);
it('相等',function(){
expect(utils.compareObject(obj1,obj2)).toBeTruthy();
});
it('长度不同',function(){
obj2.test2 = '1';
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
it('数组中的数据不同',function(){
obj1.test[2] = {};
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
});describe('compareObject',function(){
var obj1 = {
'test':[1,2],
'test1':1
};
var obj2 = utils.clonePlainObject(obj1);
it('相等',function(){
expect(utils.compareObject(obj1,obj2)).toBeTruthy();
});
it('长度不同',function(){
obj2.test2 = '1';
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
it('数组中的数据不同',function(){
obj1.test[2] = {};
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
});describe('compareObject',function(){
var obj1 = {
'test':[1,2],
'test1':1
};
var obj2 = utils.clonePlainObject(obj1);
it('相等',function(){
expect(utils.compareObject(obj1,obj2)).toBeTruthy();
});
it('长度不同',function(){
obj2.test2 = '1';
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
it('数组中的数据不同',function(){
obj1.test[2] = {};
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
});
describe('compareObject',function(){
var obj1 = {
'test':[1,2],
'test1':1
};
var obj2 = utils.clonePlainObject(obj1);
it('相等',function(){
expect(utils.compareObject(obj1,obj2)).toBeTruthy();
});
it('长度不同',function(){
obj2.test2 = '1';
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
it('数组中的数据不同',function(){
obj1.test[2] = {};
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
});
describe('compareObject',function(){
var obj1 = {
'test':[1,2],
'test1':1
};
var obj2 = utils.clonePlainObject(obj1);
it('相等',function(){
expect(utils.compareObject(obj1,obj2)).toBeTruthy();
});
it('长度不同',function(){
obj2.test2 = '1';
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
it('数组中的数据不同',function(){
obj1.test[2] = {};
expect(utils.compareObject(obj1,obj2)).toBeFalsy();
})
});
}); });
\ No newline at end of file
...@@ -8,9 +8,93 @@ ...@@ -8,9 +8,93 @@
///import core/module; ///import core/module;
///import core/event; ///import core/event;
///import core/minder; ///import core/minder;
///import core/minder.data.compatibility;
///import core/minder.data; ///import core/minder.data;
///import core/minder.event; ///import core/minder.event;
///import core/minder.module; ///import core/minder.module;
///import core/minder.command; ///import core/minder.command;
///import core/minder.node; ///import core/minder.node;
///import core/minder.select; ///import core/minder.select;
\ No newline at end of file ///import core/keymap;
///import core/minder.lang;
///import core/minder.defaultoptions;
///import core/minder.preference;
///import core/browser;
///import core/layout;
///import core/connect;
///import core/render;
///import core/theme;
///import core/template;
///import layout/default;
///import layout/default.connect;
///import layout/bottom;
///import layout/filetree;
///import theme/default;
///import theme/snow;
///import theme/fresh;
///import template/structure;
///import module/node;
///import module/text;
///import module/expand;
///import module/outline;
///import module/geometry;
///import module/history;
///import module/progress;
///import module/priority;
///import module/image;
///import module/resource;
///import module/view;
///import module/dragtree;
///import module/dropfile;
///import module/keyboard;
///import module/select;
///import module/history;
///import module/editor;
///import module/editor.range;
///import module/editor.receiver;
///import module/editor.selection;
///import module/basestyle;
///import module/font;
///import module/zoom;
///import module/hyperlink;
///import module/arrange;
///import module/paste;
///import ui/jquery-ui-1.10.4.custom.min;
///import ui/widget;
///import ui/button;
///import ui/toolbar;
///import ui/menu;
///import ui/dropmenu;
///import ui/splitbutton;
///import ui/colorsplitbutton;
///import ui/popup;
///import ui/scale;
///import ui/colorpicker;
///import ui/combobox;
///import ui/buttoncombobox;
///import ui/modal;
///import ui/tooltip;
///import ui/tab;
///import ui/separator;
///import ui/scale;
///import adapter/utils;
///import adapter/adapter;
///import adapter/button;
///import adapter/combobox;
///import adapter/color;
///import adapter/saveto;
///import adapter/tooltips;
///import adapter/face;
///import adapter/node;
///import adapter/contextmenu;
///import adapter/dialog;
///import adapter/hyperlink;
///import adapter/image;
///import adapter/zoom;
///import protocal/xmind;
///import protocal/freemind;
///import protocal/mindmanager;
///import protocal/plain;
///import protocal/json;
///import protocal/png;
///import protocal/svg;
\ No newline at end of file
This diff is collapsed.
...@@ -51,16 +51,40 @@ class Kiss ...@@ -51,16 +51,40 @@ class Kiss
print '<script type="text/javascript" src="' . $this->testPath . $f . '"></script>' . "\n"; print '<script type="text/javascript" src="' . $this->testPath . $f . '"></script>' . "\n";
} }
} }
//先引用kity //先引用kity
print "<script src='../../kity/dist/kitygraph.all.js'></script>\n"; print "<script src='../../lib/jquery-2.1.0.min.js'></script>\n";
print "<script src='../../lib/ZeroClipboard.min.js' charset='utf-8'></script>\n";
print "<script type='text/javascript'>ZeroClipboard.setDefaults( { moviePath: '../../lib/ZeroClipboard.swf' } );</script>\n";
print "<script src='../../kity/dist/kity.js' charset='utf-8'></script>\n";
//分成两部分:一部分默认加载(可配置),一部分针对文件加载(例如在文件头部有注释标注依赖文件,根据依赖文件动态加载) //分成两部分:一部分默认加载(可配置),一部分针对文件加载(例如在文件头部有注释标注依赖文件,根据依赖文件动态加载)
// core里面的文件全部加载,module加载用例对应的src文件,最后加载与用例同名的原文件 // core里面的文件全部加载,module加载用例对应的src文件,最后加载与用例同名的原文件
$importurl = "{$this->testPath}tools/import.php?f=$this->name"; $importurl = "{$this->testPath}tools/import.php?f=$this->name";
if ( $cov ) $importurl .= '^&cov=true'; if ( $cov ) $importurl .= '^&cov=true';
print "<script type='text/javascript' src='".$importurl."' ></script>\n"; print "<script type='text/javascript' src='".$importurl."' ></script>\n";
print "<script src='../../kityminder.config.js' charset='utf-8'></script>\n";
print "<script src='../../lang/zh-cn/zh-cn.js' charset='utf-8'></script>\n";
print "<script src='../../lib/zip.js' charset='utf-8'></script>\n";
print "<script>zip.inflateJSPath = '../../lib/inflate.js';</script>\n";
print "<script src='../../lib/jquery.xml2json.js' charset='utf-8'></script>\n";
print "<script src='../../lib/baidu-frontia-js-full-1.0.0.js' charset='utf-8'></script>\n";
// print "<script src='../../social/draftmanager.js' charset='utf-8'></script>\n";
// print "<script src='../../social/social.js' charset='utf-8'></script>\n";
//引用测试文件 //引用测试文件
print '<script type="text/javascript" src="' .$this->testPath.$this->name. '.js"></script>' . "\n"; print '<script type="text/javascript" src="' .$this->testPath.$this->name. '.js"></script>' . "\n";
print "<link href='../../social/social.css' rel='stylesheet'>\n";
print "<link href='../../themes/default/css/import.css' type='text/css' rel='stylesheet' />\n";
print "<link href='../../favicon.ico' type='image/x-icon' rel='shortcut icon'>\n";
print "<link href='../../favicon.ico' type='image/x-icon' rel='apple-touch-icon-precomposed'>\n";
} }
public function match( $matcher ) public function match( $matcher )
{ {
......
...@@ -147,7 +147,7 @@ a.button:active span { ...@@ -147,7 +147,7 @@ a.button:active span {
} }
.runningarea { .runningarea {
height: 60%; height: 100%;
} }
.runningmaindiv { .runningmaindiv {
......
...@@ -39,7 +39,7 @@ function importSrc(){ ...@@ -39,7 +39,7 @@ function importSrc(){
$path = $i . '.js'; $path = $i . '.js';
$srcFile = Config::$projroot . Config::$src_PATH . $path; $srcFile = Config::$projroot . Config::$src_PATH . $path;
if (file_exists($srcFile)) { if (file_exists($srcFile)) {
echo "document.write('<script charset=utf-8 src=\"$srcFile\"></script>');"; echo "document.write('<script charset=utf-8 src=\"$srcFile\"></script>');\n";
} }
} }
if(file_exists($this_src)){ if(file_exists($this_src)){
...@@ -50,7 +50,7 @@ function importSrc(){ ...@@ -50,7 +50,7 @@ function importSrc(){
if(custom_strEmpty($statment)){ if(custom_strEmpty($statment)){
continue ; continue ;
}else if(preg_match('/\/\/\/import\s+([^;]+);?/ies', $statment,$r)){ }else if(preg_match('/\/\/\/import\s+([^;]+);?/ies', $statment,$r)){
echo "document.write('<script charset=utf-8 src=\"".Config::$projroot . Config::$src_PATH.$r[1].".js\"></script>');"; echo "document.write('<script charset=utf-8 src=\"".Config::$projroot . Config::$src_PATH.$r[1].".js\"></script>');\n";
}else{ }else{
break; break;
} }
...@@ -59,7 +59,7 @@ function importSrc(){ ...@@ -59,7 +59,7 @@ function importSrc(){
} }
//加载与用例同名的原文件,并避免重复加载 //加载与用例同名的原文件,并避免重复加载
if($flag_ownSrc){ if($flag_ownSrc){
echo "document.write('<script charset=utf-8 src=\"".$this_src."\"></script>');"; echo "document.write('<script charset=utf-8 src=\"".$this_src."\"></script>');\n";
} }
} }
importSrc(); importSrc();
\ No newline at end of file
ZeroClipboard.setDefaults( { moviePath: '../../../lib/ZeroClipboard.swf' } );
\ No newline at end of file
/**
*
* Created by Ryan on 14-9-3.
*/
zip.inflateJSPath = '../../../lib/inflate.js';
...@@ -132,6 +132,7 @@ function run(kiss,runnext) { ...@@ -132,6 +132,7 @@ function run(kiss,runnext) {
var iframe = document.createElement('iframe'); var iframe = document.createElement('iframe');
iframe.id = fid; iframe.id = fid;
iframe.src = url; iframe.src = url;
iframe.style.minHeight="1500px";
addClass(iframe, "runningframe"); addClass(iframe, "runningframe");
runningarea.appendChild(iframe); runningarea.appendChild(iframe);
wb.kissstart = new Date().getTime(); wb.kissstart = new Date().getTime();
......
...@@ -60,7 +60,12 @@ $cov = array_key_exists( 'cov' , $_GET ); ...@@ -60,7 +60,12 @@ $cov = array_key_exists( 'cov' , $_GET );
}; };
function execJasmine() { function execJasmine() {
// jasmineEnv.beforeEach(function(){console.log(12)});
// jasmine.Suite.beforeEach(function(){console.log(123)});
// console.log(jasmineEnv.currentSpec);
// jasmineEnv.currentSpec.start=function(){console.log(123)};
jasmineEnv.execute(); jasmineEnv.execute();
} }
})(); })();
......
...@@ -18,7 +18,7 @@ KM.registerUI( 'contextmenu', function () { ...@@ -18,7 +18,7 @@ KM.registerUI( 'contextmenu', function () {
if(item.exec){ if(item.exec){
item.exec.apply(km) item.exec.apply(me);
}else{ }else{
me.execCommand(item.cmdName); me.execCommand(item.cmdName);
} }
...@@ -50,11 +50,19 @@ KM.registerUI( 'contextmenu', function () { ...@@ -50,11 +50,19 @@ KM.registerUI( 'contextmenu', function () {
data.length && data.push(item); data.length && data.push(item);
return; return;
} }
if(item.query){
if(item.query.apply(me) != -1)
data.push({
label:item.label,
value:item.cmdName
});
return;
}
if(me.queryCommandState(item.cmdName)!=-1){ if(me.queryCommandState(item.cmdName)!=-1){
data.push({ data.push({
label:item.label, label:item.label,
value:item.cmdName value:item.cmdName
}) });
} }
}); });
if(data.length){ if(data.length){
...@@ -79,6 +87,6 @@ KM.registerUI( 'contextmenu', function () { ...@@ -79,6 +87,6 @@ KM.registerUI( 'contextmenu', function () {
if(e.isRightMB()){ if(e.isRightMB()){
//e.stopPropagationImmediately(); //e.stopPropagationImmediately();
} }
}) });
} ); } );
...@@ -20,6 +20,7 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -20,6 +20,7 @@ KityMinder.registerModule('TextEditModule', function() {
function inputStatusReady(node){ function inputStatusReady(node){
if (node && km.isSingleSelect() && node.isSelected()) { if (node && km.isSingleSelect() && node.isSelected()) {
var color = node.getStyle('text-selection-color'); var color = node.getStyle('text-selection-color');
//准备输入状态 //准备输入状态
...@@ -47,8 +48,6 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -47,8 +48,6 @@ KityMinder.registerModule('TextEditModule', function() {
} }
receiver.minderNode.setTmpData('_lastTextContent',receiver.textShape.getContent());
km.setStatus('inputready'); km.setStatus('inputready');
} }
...@@ -73,16 +72,6 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -73,16 +72,6 @@ KityMinder.registerModule('TextEditModule', function() {
} }
if(receiver.minderNode){
var textShape = receiver.minderNode.getTextShape();
if(textShape && textShape.getOpacity() === 0){
receiver.minderNode.setText(receiver.minderNode.getTmpData('_lastTextContent'));
receiver.minderNode.render();
receiver.minderNode.getTextShape().setOpacity(1);
km.layout(300);
}
}
mouseDownStatus = true; mouseDownStatus = true;
selectionReadyShow = sel.isShow(); selectionReadyShow = sel.isShow();
...@@ -104,6 +93,7 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -104,6 +93,7 @@ KityMinder.registerModule('TextEditModule', function() {
if(node){ if(node){
var textShape = node.getTextShape(); var textShape = node.getTextShape();
textShape.setStyle('cursor', 'default'); textShape.setStyle('cursor', 'default');
if (this.isSingleSelect() && node.isSelected()) { if (this.isSingleSelect() && node.isSelected()) {
sel.collapse(true); sel.collapse(true);
......
...@@ -75,7 +75,9 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -75,7 +75,9 @@ Minder.Receiver = kity.createClass('Receiver', {
return this; return this;
}, },
getTextShapeHeight: function() { getTextShapeHeight: function() {
return this.textShape.getRenderBox().height; var height = this.textShape.getRenderBox().height;
return height || this.minderNode._lastTextShapeBox.height;
}, },
setKityMinder: function(km) { setKityMinder: function(km) {
this.km = km; this.km = km;
...@@ -115,7 +117,6 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -115,7 +117,6 @@ Minder.Receiver = kity.createClass('Receiver', {
var keyCode = orgEvt.keyCode; var keyCode = orgEvt.keyCode;
function setTextToContainer() { function setTextToContainer() {
clearTimeout(me.timer); clearTimeout(me.timer);
if (!me.range.hasNativeRange()) { if (!me.range.hasNativeRange()) {
return; return;
...@@ -139,26 +140,11 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -139,26 +140,11 @@ Minder.Receiver = kity.createClass('Receiver', {
text += '\u200b'; text += '\u200b';
} }
me.minderNode.setText(text);
//如果接受框已经空了,并且已经添加了占位的a了就什么都不做了
if(text.length === 0 && me.textShape.getOpacity() === 0){
return;
}
if (text.length === 0) {
me.minderNode.setTmpData('_lastTextContent',me.textShape.getContent());
me.minderNode.setText('a');
}else {
me.minderNode.setText(text);
if (me.textShape.getOpacity() === 0) {
me.textShape.setOpacity(1);
}
}
me.setContainerStyle(); me.setContainerStyle();
me.minderNode.getRenderContainer().bringTop(); me.minderNode.getRenderContainer().bringTop();
me.minderNode.render(); me.minderNode.render();
//移动光标不做layout //移动光标不做layout
if(!keymap.notContentChange[keyCode]){ if(!keymap.notContentChange[keyCode]){
clearTimeout(me.inputTextTimer); clearTimeout(me.inputTextTimer);
...@@ -170,9 +156,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -170,9 +156,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me.textShape = me.minderNode.getRenderer('TextRenderer').getRenderShape(); me.textShape = me.minderNode.getRenderer('TextRenderer').getRenderShape();
if (text.length === 0) {
me.textShape.setOpacity(0);
}
me.setBaseOffset(); me.setBaseOffset();
me.updateTextOffsetData(); me.updateTextOffsetData();
me.updateRange(); me.updateRange();
...@@ -187,18 +171,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -187,18 +171,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me.km.setStatus('textedit'); me.km.setStatus('textedit');
} }
function restoreTextContent(){
if(me.minderNode){
var textShape = me.minderNode.getTextShape();
if(textShape && textShape.getOpacity() === 0){
me.minderNode.setText(me.minderNode.getTmpData('_lastTextContent'));
me.minderNode.render();
me.minderNode.getTextShape().setOpacity(1);
me.km.layout(300);
}
}
}
switch (e.type) { switch (e.type) {
case 'input': case 'input':
...@@ -223,7 +196,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -223,7 +196,7 @@ Minder.Receiver = kity.createClass('Receiver', {
this.km.setStatus('normal'); this.km.setStatus('normal');
this.km.fire('contentchange'); this.km.fire('contentchange');
} }
restoreTextContent();
return; return;
case keymap.left: case keymap.left:
case keymap.right: case keymap.right:
...@@ -233,7 +206,6 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -233,7 +206,6 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.Del: case keymap.Del:
case keymap['/']: case keymap['/']:
if(this.selection.isHide()){ if(this.selection.isHide()){
restoreTextContent();
this.km.setStatus('normal'); this.km.setStatus('normal');
return; return;
} }
...@@ -257,7 +229,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -257,7 +229,7 @@ Minder.Receiver = kity.createClass('Receiver', {
88:1, 88:1,
67:1 67:1
}[keyCode]){ }[keyCode]){
restoreTextContent();
this.km.setStatus('normal'); this.km.setStatus('normal');
return; return;
} }
...@@ -305,7 +277,6 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -305,7 +277,6 @@ Minder.Receiver = kity.createClass('Receiver', {
this.km.setStatus('normal'); this.km.setStatus('normal');
this.km.fire('contentchange'); this.km.fire('contentchange');
} }
restoreTextContent();
return; return;
} }
if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) { if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) {
...@@ -343,6 +314,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -343,6 +314,7 @@ Minder.Receiver = kity.createClass('Receiver', {
return true; return true;
case 'keyup': case 'keyup':
var node = this.km.getSelectedNode(); var node = this.km.getSelectedNode();
if(this.km.getStatus() == 'normal' && node && this.selection.isHide()){ if(this.km.getStatus() == 'normal' && node && this.selection.isHide()){
if (node && this.km.isSingleSelect() && node.isSelected()) { if (node && this.km.isSingleSelect() && node.isSelected()) {
...@@ -374,8 +346,6 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -374,8 +346,6 @@ Minder.Receiver = kity.createClass('Receiver', {
} }
this.minderNode.setTmpData('_lastTextContent',this.textShape.getContent());
this.km.setStatus('inputready'); this.km.setStatus('inputready');
} }
...@@ -390,7 +360,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -390,7 +360,7 @@ Minder.Receiver = kity.createClass('Receiver', {
return this; return this;
}, },
updateTextOffsetData: function() { updateTextOffsetData: function() {
this.textShape.textData = this.getTextOffsetData(); this.getTextOffsetData();
return this; return this;
}, },
setSelection: function(selection) { setSelection: function(selection) {
...@@ -452,6 +422,15 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -452,6 +422,15 @@ Minder.Receiver = kity.createClass('Receiver', {
height: box.height height: box.height
}); });
} }
if(this.textData.length === 0){
var lastBox = this.minderNode._lastTextShapeBox;
this.textData.push({
x: lastBox.x ,
y: lastBox.y,
width: 0,
height: lastBox.height
});
}
return this; return this;
}, },
setCurrentIndex: function(offset) { setCurrentIndex: function(offset) {
...@@ -460,6 +439,10 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -460,6 +439,10 @@ Minder.Receiver = kity.createClass('Receiver', {
var hadChanged = false; var hadChanged = false;
//要剪掉基数 //要剪掉基数
this._getRelativeValue(offset); this._getRelativeValue(offset);
if(this.textData.length == 1 && this.textData[0].width === 0){
me.index = 0;
return this;
}
utils.each(this.textData, function(i, v) { utils.each(this.textData, function(i, v) {
//点击开始之前 //点击开始之前
if (i === 0 && offset.x <= v.x) { if (i === 0 && offset.x <= v.x) {
...@@ -578,6 +561,9 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -578,6 +561,9 @@ Minder.Receiver = kity.createClass('Receiver', {
updateContainerRangeBySel:function(){ updateContainerRangeBySel:function(){
var me = this; var me = this;
var node = this.container.firstChild; var node = this.container.firstChild;
if(!node){
node = this.container;
}
this.range.setStart(node, this.selection.startOffset); this.range.setStart(node, this.selection.startOffset);
this.range.setEnd(node, this.selection.endOffset); this.range.setEnd(node, this.selection.endOffset);
if(browser.gecko){ if(browser.gecko){
......
...@@ -111,6 +111,16 @@ KityMinder.registerModule('NodeModule', function() { ...@@ -111,6 +111,16 @@ KityMinder.registerModule('NodeModule', function() {
cmdName: 'RemoveNode' cmdName: 'RemoveNode'
}, { }, {
divider: 1 divider: 1
},{
label: this.getLang('insert.topic'),
exec: function() {
this.select(this.getRoot());
this.execCommand('AppendSiblingNode', this.getLang('topic'));
},
query:function(){
var nodes = this.getSelectedNodes();
return nodes.length === 0 ? 0 : -1;
}
}] }]
}; };
}); });
\ No newline at end of file
...@@ -10,16 +10,35 @@ var TextRenderer = KityMinder.TextRenderer = kity.createClass('TextRenderer', { ...@@ -10,16 +10,35 @@ var TextRenderer = KityMinder.TextRenderer = kity.createClass('TextRenderer', {
.setAttr('text-rendering', 'inherit'); .setAttr('text-rendering', 'inherit');
}, },
update: function(text, node) { update: function(text,node) {
this.setTextStyle(node, text.setContent(node.getText()));
var box = text.getBoundaryBox(); var tmpText = node.getText();
var r = Math.round;
if (kity.Browser.ie) { this.setTextStyle(node, text.setContent(tmpText));
box.y += 1;
if(tmpText.length || !this._lastBox){
var box = text.getBoundaryBox();
var r = Math.round;
if (kity.Browser.ie) {
box.y += 1;
}
this._lastBox = {
x : r(box.x),
y : r(box.y),
width : r(box.width),
height: r(box.height)
};
}else {
this._lastBox.width = 0;
} }
var lastBox = this._lastBox;
node._lastTextShapeBox = lastBox;
return function() { return function() {
return new kity.Box(r(box.x), r(box.y), r(box.width), r(box.height)); return new kity.Box(lastBox.x, lastBox.y,lastBox.width, lastBox.height);
}; };
}, },
setTextStyle: function(node, text) { setTextStyle: function(node, text) {
......
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