Commit b4d1216c authored by techird's avatar techird

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

parents 62615c38 564bb5a4
describe("command", function () { describe("command", function () {
//初始化kityminder
var kityMinderDiv = document.createElement("div"); var kityMinderDiv = document.createElement("div");
kityMinderDiv.id = "kityminder"; kityMinderDiv.id = "kityminder";
kityMinderDiv.style.height = "500px"; kityMinderDiv.style.height = "500px";
...@@ -6,11 +7,9 @@ describe("command", function () { ...@@ -6,11 +7,9 @@ describe("command", function () {
var obj; var obj;
var km; var km;
beforeEach(function(){ beforeEach(function(){
document.body.appendChild(kityMinderDiv); document.body.appendChild(kityMinderDiv);
km = KM.getKityMinder('kityminder'); km = KM.getMinder('kityminder', window.KITYMINDER_CONFIG);
obj = document.getElementById('kityminder'); obj = document.getElementById('kityminder');
}); });
...@@ -18,11 +17,12 @@ describe("command", function () { ...@@ -18,11 +17,12 @@ describe("command", function () {
// obj = null; // obj = null;
// document.body.removeChild(kityMinderDiv); // document.body.removeChild(kityMinderDiv);
}); });
//kityminder初始化end
it('',function(){ it('',function(){
console.log(km);
obj = document.getElementById('kityminder');
console.log(obj);
}) })
}); });
\ No newline at end of file
describe("minder.command", function () { describe("minder.command", function () {
//初始化kityminder
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.getMinder('kityminder', window.KITYMINDER_CONFIG);
obj = document.getElementById('kityminder');
});
afterEach(function(){
// obj = null;
// document.body.removeChild(kityMinderDiv);
});
//kityminder初始化end
it('',function(){ it('',function(){
}) })
......
describe("node", function () { describe("node", function () {
//初始化kityminder
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.getMinder('kityminder', window.KITYMINDER_CONFIG);
obj = document.getElementById('kityminder');
});
afterEach(function(){
// obj = null;
// document.body.removeChild(kityMinderDiv);
});
//kityminder初始化end
var root = new KM.MinderNode('root'); var root = new KM.MinderNode('root');
var first = new KM.MinderNode('first'); var first = new KM.MinderNode('first');
......
describe("utils", function () { describe("utils", function () {
//初始化kityminder
var kityMinderDiv = document.createElement("div"); var kityMinderDiv = document.createElement("div");
kityMinderDiv.id = "kityminder"; kityMinderDiv.id = "kityminder";
kityMinderDiv.style.height = "500px"; kityMinderDiv.style.height = "500px";
kityMinderDiv.style.position = "relative"; kityMinderDiv.style.position = "relative";
var obj; var obj;
var km; var km;
var flag = true;
beforeEach(function(){ beforeEach(function(){
if(flag){ document.body.appendChild(kityMinderDiv);
document.getElementById('HTMLReporter').appendChild(kityMinderDiv); km = KM.getMinder('kityminder', window.KITYMINDER_CONFIG);
km = KM.getKityMinder('kityminder'); obj = document.getElementById('kityminder');
obj = document.getElementById('kityminder');
flag = false;
}
}); });
afterEach(function(){ afterEach(function(){
// obj = null;
// document.body.removeChild(kityMinderDiv); // document.body.removeChild(kityMinderDiv);
// console.log(km);
}); });
//kityminder初始化end
// 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;
// }
......
...@@ -45,11 +45,11 @@ ...@@ -45,11 +45,11 @@
///import module/resource; ///import module/resource;
///import module/view; ///import module/view;
///import module/dragtree; ///import module/dragtree;
///import module/dropfile;
///import module/keyboard; ///import module/keyboard;
///import module/select; ///import module/select;
///import module/history; ///import module/history;
///import module/editor; ///import module/editor;
///import module/editor.keyboard;
///import module/editor.range; ///import module/editor.range;
///import module/editor.receiver; ///import module/editor.receiver;
///import module/editor.selection; ///import module/editor.selection;
...@@ -59,42 +59,67 @@ ...@@ -59,42 +59,67 @@
///import module/hyperlink; ///import module/hyperlink;
///import module/arrange; ///import module/arrange;
///import module/paste; ///import module/paste;
///import ui/jquery-ui-1.10.4.custom.min; ///import module/style;
///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/xmind;
///import protocal/freemind; ///import protocal/freemind;
///import protocal/mindmanager; ///import protocal/mindmanager;
///import protocal/plain; ///import protocal/plain;
///import protocal/json; ///import protocal/json;
///import protocal/png; ///import protocal/png;
///import protocal/svg; ///import protocal/svg;
\ No newline at end of file ///import ui/ui;
///import ui/eve;
///import ui/fuix;
///import ui/fiox;
///import ui/doc;
///import ui/widget/commandbutton;
///import ui/widget/commandbuttonset;
///import ui/widget/commandinputmenu;
///import ui/widget/friendlytimespan;
///import ui/widget/locallist;
///import ui/widget/netdiskfinder;
///import ui/widget/menutab;
///import ui/menu/menu;
///import ui/menu/header;
///import ui/menu/default;
///import ui/menu/new/new;
///import ui/menu/open/open;
///import ui/menu/open/recent;
///import ui/menu/open/netdisk;
///import ui/menu/open/local;
///import ui/menu/open/draft;
///import ui/menu/save/save;
///import ui/menu/save/netdisk;
///import ui/menu/save/download;
///import ui/menu/share/share;
///import ui/topbar/history;
///import ui/topbar/user;
///import ui/topbar/search;
///import ui/topbar/title;
///import ui/ribbon/tabs;
///import ui/ribbon/idea/insert;
///import ui/ribbon/idea/arrange;
///import ui/ribbon/idea/operation;
///import ui/ribbon/idea/attachment;
///import ui/ribbon/idea/link;
///import ui/ribbon/idea/image;
///import ui/ribbon/idea/priority;
///import ui/ribbon/idea/progress;
///import ui/ribbon/idea/resource;
///import ui/ribbon/appearence/template;
///import ui/ribbon/appearence/theme;
///import ui/ribbon/appearence/layout;
///import ui/ribbon/appearence/style;
///import ui/ribbon/appearence/font;
///import ui/ribbon/appearence/color;
///import ui/ribbon/view/level;
...@@ -58,9 +58,21 @@ class Kiss ...@@ -58,9 +58,21 @@ class Kiss
//先引用kity //先引用kity
print "<script src='../../lib/jquery-2.1.0.min.js'></script>\n"; print "<script src='../../lib/jquery-2.1.0.min.js'></script>\n";
print "<script src='../../lib/jquery.xml2json.js' charset='utf-8'></script>\n";
print "<script src='../../lib/jquery.transit.min.js' charset='utf-8'></script>\n";
print "<script src='../../lib/jquery.blob.js' charset='utf-8'></script>\n";
print "<script src='../../lib/zip.js' charset='utf-8'></script>\n";
print "<script src='../../lib/promise-1.0.0.js' charset='utf-8'></script>\n";
print "<script src='../../lib/ZeroClipboard.min.js' charset='utf-8'></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='../../lib/fui/dev-lib/jhtmls.min.js' charset='utf-8'></script>\n";
print "<script src='../../kity/dist/kity.js' charset='utf-8'></script>\n"; print "<script src='../../lib/fui/dist/fui.all.js' charset='utf-8'></script>\n";
print "<script src='../../lib/fio/src/fio.js' charset='utf-8'></script>\n";
print "<script src='../../lib/fio/provider/netdisk/oauth.js' charset='utf-8'></script>\n";
print "<script src='../../lib/fio/provider/netdisk/netdisk.js' charset='utf-8'></script>\n";
print "<script src='../../lib/kity/dist/kity.js' charset='utf-8'></script>\n";
//分成两部分:一部分默认加载(可配置),一部分针对文件加载(例如在文件头部有注释标注依赖文件,根据依赖文件动态加载) //分成两部分:一部分默认加载(可配置),一部分针对文件加载(例如在文件头部有注释标注依赖文件,根据依赖文件动态加载)
// core里面的文件全部加载,module加载用例对应的src文件,最后加载与用例同名的原文件 // core里面的文件全部加载,module加载用例对应的src文件,最后加载与用例同名的原文件
...@@ -70,10 +82,10 @@ class Kiss ...@@ -70,10 +82,10 @@ class Kiss
print "<script src='../../kityminder.config.js' charset='utf-8'></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='../../lang/zh-cn/zh-cn.js' charset='utf-8'></script>\n";
print "<script src='../../lib/zip.js' charset='utf-8'></script>\n"; print "<script type='text/javascript'>zip.inflateJSPath = '../../lib/inflate.js';</script>\n";
print "<script>zip.inflateJSPath = '../../lib/inflate.js';</script>\n"; print "<script type='text/javascript'>window._bd_share_config={'common':{'bdSnsKey':{},'bdMini':'2','bdMiniList':[],'bdPic':'','bdStyle':'1','bdSize':'32'},'share':{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>\n";
print "<script src='../../lib/jquery.xml2json.js' charset='utf-8'></script>\n"; // print "<script>zip.inflateJSPath = '../../lib/inflate.js';</script>\n";
print "<script src='../../lib/baidu-frontia-js-full-1.0.0.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/draftmanager.js' charset='utf-8'></script>\n";
// print "<script src='../../social/social.js' charset='utf-8'></script>\n"; // print "<script src='../../social/social.js' charset='utf-8'></script>\n";
...@@ -81,8 +93,8 @@ class Kiss ...@@ -81,8 +93,8 @@ class Kiss
//引用测试文件 //引用测试文件
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='../../ui/theme/default/css/default.all.css' rel='stylesheet'>\n";
print "<link href='../../themes/default/css/import.css' type='text/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='shortcut icon'>\n";
print "<link href='../../favicon.ico' type='image/x-icon' rel='apple-touch-icon-precomposed'>\n"; print "<link href='../../favicon.ico' type='image/x-icon' rel='apple-touch-icon-precomposed'>\n";
} }
......
...@@ -281,7 +281,12 @@ var utils = Utils = KityMinder.Utils = { ...@@ -281,7 +281,12 @@ var utils = Utils = KityMinder.Utils = {
utils.each(data,function(i,arr){ utils.each(data,function(i,arr){
if(initIndex + arr.length >= index){ if(initIndex + arr.length >= index){
if(index - initIndex == arr.length){ if(index - initIndex == arr.length){
if(arr.length == 1 && arr[0].width === 0){
initIndex++;
return;
}
result = { result = {
x: arr[arr.length - 1].x + arr[arr.length - 1].width, x: arr[arr.length - 1].x + arr[arr.length - 1].width,
y: arr[arr.length - 1].y y: arr[arr.length - 1].y
......
...@@ -210,11 +210,14 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -210,11 +210,14 @@ KityMinder.registerModule('TextEditModule', function() {
var node = e.getTargetNode(); var node = e.getTargetNode();
e.stopPropagationImmediately(); e.stopPropagationImmediately();
var offset = e.getPosition(node.getRenderContainer()); if(node){
var offset = e.getPosition(node.getRenderContainer());
receiver.updateSelectionByMousePosition(offset) receiver.updateSelectionByMousePosition(offset)
.updateSelection(offset) .updateSelection(offset)
.updateContainerRangeBySel(); .updateContainerRangeBySel();
}
}else if(mouseDownStatus && !selectionReadyShow){ }else if(mouseDownStatus && !selectionReadyShow){
......
...@@ -83,7 +83,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){ ...@@ -83,7 +83,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
// } // }
//重新渲染节点 //重新渲染节点
me.minderNode.setText(text); me.minderNode.setText(text);
me.re.setContainerStyle(); me.re.setContainerStyle();
me.minderNode.getRenderContainer().bringTop(); me.minderNode.getRenderContainer().bringTop();
...@@ -109,10 +108,11 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){ ...@@ -109,10 +108,11 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
me.timer = setTimeout(function() { me.timer = setTimeout(function() {
if(me.selection.isShow()){ if(me.selection.isShow()){
me.selection.setShow(); me.selection.setShow();
} }
}, 200); }, 200);
...@@ -227,7 +227,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){ ...@@ -227,7 +227,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
case keymap.F2: case keymap.F2:
if(browser.ipad){ if(browser.ipad){
if(this.selection.isShow()){ if(this.selection.isShow()){
this.clear(); this.re.clear();
this.km.setStatus('inputready'); this.km.setStatus('inputready');
clearTimeout(me.inputTextTimer); clearTimeout(me.inputTextTimer);
e.preventDefault(); e.preventDefault();
...@@ -237,12 +237,13 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){ ...@@ -237,12 +237,13 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
} }
return; return;
} }
if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) { if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) {
me._setTextToContainer(keyCode); me._setTextToContainer(keyCode);
} }
if (this.keydownNode === this.minderNode) { if (this.re.keydownNode === this.re.minderNode) {
this.rollbackStatus(); this.km.rollbackStatus();
this.clear(); this.re.clear();
} }
e.preventDefault(); e.preventDefault();
return; return;
...@@ -308,6 +309,11 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){ ...@@ -308,6 +309,11 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
}, },
//处理软回车操作 //处理软回车操作
_handlerEnterkey:function(){ _handlerEnterkey:function(){
function removeTmpTextNode(node){
if(node && node.nodeType == 3 && node.nodeValue.length === 0){
node.parentNode.removeChild(node);
}
}
var rng = this.range; var rng = this.range;
var br = document.createElement('br'); var br = document.createElement('br');
var me = this; var me = this;
...@@ -315,11 +321,22 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){ ...@@ -315,11 +321,22 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
rng.deleteContents(); rng.deleteContents();
} }
rng.insertNode(br); rng.insertNode(br);
removeTmpTextNode(br.previousSibling);
removeTmpTextNode(br.nextSibling);
rng.setStartAfter(br); rng.setStartAfter(br);
rng.collapse(true); rng.collapse(true);
var start = rng.startContainer.childNodes[rng.startOffset];
if(!start){
br = br.cloneNode(false);
rng.startContainer.appendChild(br);
rng.setStartBefore(br);
rng.collapse(true);
}
rng.select(); rng.select();
me._setTextToContainer(keymap.Enter); me._setTextToContainer(keymap.Enter);
} }
}; };
......
...@@ -28,13 +28,13 @@ Minder.Range = kity.createClass('Range',function(){ ...@@ -28,13 +28,13 @@ Minder.Range = kity.createClass('Range',function(){
var rOffset = 0,cont = rng.container; var rOffset = 0,cont = rng.container;
utils.each(cont.childNodes,function(index,node){ utils.each(cont.childNodes,function(index,node){
if(node.nodeType == 1){ if(node.nodeType == 1){
rOffset++;
if(rOffset == offset){ if(rOffset == offset){
rng['set' + dir](cont,index); rng['set' + dir](cont,index);
return false; return false;
} }
rOffset++;
return; return;
} }
...@@ -65,12 +65,20 @@ Minder.Range = kity.createClass('Range',function(){ ...@@ -65,12 +65,20 @@ Minder.Range = kity.createClass('Range',function(){
return this._updateBoundary(); return this._updateBoundary();
}, },
select:function(){ select:function(){
var start = this.nativeRange.startContainer; var start = this.nativeRange.startContainer;
if(start.nodeType == 1 && start.childNodes.length === 0){ if(start.nodeType == 1 && start.childNodes.length === 0){
var char = document.createTextNode('\u200b'); var char = document.createTextNode('\u200b');
start.appendChild(char); start.appendChild(char);
this.nativeRange.setStart(char,1); this.nativeRange.setStart(char,1);
this.nativeRange.collapse(true); this.nativeRange.collapse(true);
}else if(this.collapsed && start.nodeType == 1){
start = start.childNodes[this.startOffset];
if(start && start.nodeType == 3 && start.nodeValue.length === 0){
this.nativeRange.setStart(start,1);
this.nativeRange.collapse(true);
}
} }
try{ try{
this.nativeSel.removeAllRanges(); this.nativeSel.removeAllRanges();
...@@ -84,6 +92,7 @@ Minder.Range = kity.createClass('Range',function(){ ...@@ -84,6 +92,7 @@ Minder.Range = kity.createClass('Range',function(){
_updateBoundary : function(){ _updateBoundary : function(){
var nRange = this.nativeRange; var nRange = this.nativeRange;
this.startContainer = nRange.startContainer; this.startContainer = nRange.startContainer;
this.startContainer = nRange.startContainer;
this.endContainer = nRange.endContainer; this.endContainer = nRange.endContainer;
this.startOffset = nRange.startOffset; this.startOffset = nRange.startOffset;
this.endOffset = nRange.endOffset; this.endOffset = nRange.endOffset;
...@@ -108,6 +117,9 @@ Minder.Range = kity.createClass('Range',function(){ ...@@ -108,6 +117,9 @@ Minder.Range = kity.createClass('Range',function(){
setStartAfter:function(node){ setStartAfter:function(node){
return this.setStart(node.parentNode,utils.getNodeIndex(node) + 1); return this.setStart(node.parentNode,utils.getNodeIndex(node) + 1);
}, },
setStartBefore:function(node){
return this.setStart(node.parentNode,utils.getNodeIndex(node));
},
setEnd:function(node,offset){ setEnd:function(node,offset){
this.nativeRange.setEnd(node,offset); this.nativeRange.setEnd(node,offset);
this._updateBoundary(); this._updateBoundary();
......
...@@ -194,8 +194,8 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -194,8 +194,8 @@ Minder.Receiver = kity.createClass('Receiver', {
return false; return false;
} }
if (i == arr.length - 1 && offset.x >= v.x) { if (i == arr.length - 1 && offset.x >= v.x) {
me.index += arr.length;
me.index += (arr.length == 1 && arr[0].width === 0 ? 0 : arr.length);
return false; return false;
} }
}); });
...@@ -245,7 +245,8 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -245,7 +245,8 @@ Minder.Receiver = kity.createClass('Receiver', {
return false; return false;
} }
if (i == arr.length - 1 && offset.x >= v.x) { if (i == arr.length - 1 && offset.x >= v.x) {
result += arr.length;
result += (arr.length == 1 && arr[0].width === 0 ? 0 : arr.length);
return false; return false;
} }
......
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