Commit 0333a2d9 authored by techird's avatar techird

merge reflact

parents c007c290 045469a1
# KityMinder 更新日志
## v1.2.0
### 功能更新
1. 支持ipad上的文字编辑
## v1.1.3.1
......
......@@ -716,11 +716,17 @@
function seekEOCDR(offset, entriesCallback) {
reader.readUint8Array(reader.size - offset, offset, function(bytes) {
var dataView = getDataHelper(bytes.length, bytes).view;
if (dataView.getUint32(0) != 0x504b0506) {
seekEOCDR(offset + 1, entriesCallback);
} else {
entriesCallback(dataView);
try{
if (dataView.getUint32(0) != 0x504b0506) {
seekEOCDR(offset + 1, entriesCallback);
} else {
entriesCallback(dataView);
}
}catch(e){
console.log(e);
onerror(ERR_READ);
}
}, function() {
onerror(ERR_READ);
});
......
......@@ -67,7 +67,9 @@ var browser = KityMinder.browser = function(){
* }
* ```
*/
quirks : ( document.compatMode == 'BackCompat' )
quirks : ( document.compatMode == 'BackCompat' ),
ipad : ( agent.indexOf( 'ipad' ) > -1 )
};
/**
......
......@@ -18,12 +18,8 @@ KityMinder.registerLayout('default', kity.createClass({
node = node.parent;
}
var mainIndex = node.getIndex();
return {
0: 'right',
1: 'right',
2: 'left',
3: 'left'
}[mainIndex] || (mainIndex % 2 ? 'right' : 'left');
var length = node.parent.children.length;
return mainIndex < length / 2 ? 'right' : 'left';
},
doLayoutRoot: function(root) {
......
......@@ -45,7 +45,7 @@ KityMinder.registerModule('TextEditModule', function() {
};
var selectionByClick = false;
var dragmoveTimer;
return {
'events': {
'ready': function() {
......@@ -132,7 +132,12 @@ KityMinder.registerModule('TextEditModule', function() {
if (this.isSingleSelect() && node.isSelected()) {
var orgEvt = e.originEvent,
keyCode = orgEvt.keyCode;
if (keymap.isSelectedNodeKey[keyCode] && km.getStatus() != 'textedit' && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey) {
if (keymap.isSelectedNodeKey[keyCode] &&
km.getStatus() != 'textedit' &&
!orgEvt.ctrlKey &&
!orgEvt.metaKey &&
!orgEvt.shiftKey &&
!orgEvt.altKey) {
//准备输入状态
var textShape = node.getTextShape();
......@@ -162,16 +167,18 @@ KityMinder.registerModule('TextEditModule', function() {
if (mouseDownStatus) {
if (!sel.collapsed) {
try {
receiver.updateRange(range);
} catch (error) {
console.log(error);
}
} else
} else {
sel.setShow();
} else {
}
if (browser.ipad) {
receiver.container.focus();
}
//当选中节点后,输入状态准备
var node = e.getTargetNode();
if (node) {
......@@ -206,7 +213,8 @@ KityMinder.registerModule('TextEditModule', function() {
oneTime = 0;
},
'textedit.beforemousemove': function(e) {
if (mouseDownStatus) {
//ipad下不做框选
if (mouseDownStatus && !browser.ipad) {
e.stopPropagationImmediately();
var offset = e.getPosition(this.getRenderContainer());
......@@ -268,10 +276,10 @@ KityMinder.registerModule('TextEditModule', function() {
receiver.clear().setTextEditStatus(false);
km.setStatus('normal');
},
"resize": function(e) {
'resize': function(e) {
sel.setHide();
},
"execCommand": function(e) {
'execCommand': function(e) {
var cmds = {
'appendchildnode': 1,
'appendsiblingnode': 1,
......
......@@ -27,12 +27,12 @@ Minder.Receiver = kity.createClass('Receiver', {
_div.setAttribute('contenteditable', true);
_div.className = 'km_receiver';
this.container = _div;
if (browser.ie && browser.version == 11) {
utils.listen(this.container, 'keydown keypress keyup', function(e) {
me.keyboardEvents.call(me, new MinderEvent(e.type == 'keyup' ? "beforekeyup" : e.type, e));
if (browser.ie && browser.version == 11 || browser.ipad) {
utils.listen(this.container, 'keydown keypress keyup input', function(e) {
me.keyboardEvents.call(me, new MinderEvent(e.type == 'keyup' ? 'beforekeyup' : e.type, e));
});
}
utils.addCssRule('km_receiver_css', ' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);}'); //
utils.addCssRule('km_receiver_css', ' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);'); //
this.km.on('textedit.beforekeyup textedit.keydown textedit.keypress textedit.paste', utils.proxy(this.keyboardEvents, this));
this.timer = null;
this.index = 0;
......@@ -97,7 +97,7 @@ Minder.Receiver = kity.createClass('Receiver', {
}
//#46 修复在ff下定位到文字后方空格光标不移动问题
if (browser.gecko && /\s$/.test(text)) {
text += "\u200b";
text += '\u200b';
}
me.minderNode.setText(text);
......@@ -129,6 +129,14 @@ Minder.Receiver = kity.createClass('Receiver', {
switch (e.type) {
case 'input':
if (browser.ipad) {
setTimeout(function() {
setTextToContainer();
});
}
break;
case 'keydown':
this.isTypeText = keyCode == 229 || keyCode === 0;
switch (keyCode) {
......@@ -169,7 +177,6 @@ Minder.Receiver = kity.createClass('Receiver', {
}
return;
}
setTimeout(function() {
setTextToContainer();
});
......@@ -253,8 +260,10 @@ Minder.Receiver = kity.createClass('Receiver', {
return this;
},
setContainerStyle: function() {
var textShapeBox = this.getBaseOffset('screen');
this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + (textShapeBox.y + textShapeBox.height * 0.1) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
var textShapeBox = this.getBaseOffset('paper');
this.container.style.cssText = ';left:' + (browser.ipad ? '-' : '') +
textShapeBox.x + 'px;top:' + (textShapeBox.y + textShapeBox.height * 0.1) +
'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
if (!this.selection.isShow()) {
var paperContainer = this.km.getPaper();
......@@ -351,7 +360,8 @@ Minder.Receiver = kity.createClass('Receiver', {
if (offset.x <= v.x + v.width / 2) {
me.selection.collapse();
} else {
me.selection.setEndOffset(i + ((me.selection.endOffset > i || dir == 1) && i != me.textData.length - 1 ? 1 : 0));
me.selection.setEndOffset(i + ((me.selection.endOffset > i ||
dir == 1) && i != me.textData.length - 1 ? 1 : 0));
}
} else if (i > me.index) {
......@@ -359,7 +369,8 @@ Minder.Receiver = kity.createClass('Receiver', {
me.selection.setEndOffset(i + 1);
} else {
if (dir == 1) {
me.selection.setStartOffset(i + (offset.x >= v.x + v.width / 2 && i != me.textData.length - 1 ? 1 : 0));
me.selection.setStartOffset(i + (offset.x >= v.x + v.width / 2 &&
i != me.textData.length - 1 ? 1 : 0));
} else {
me.selection.setStartOffset(i);
}
......@@ -385,7 +396,7 @@ Minder.Receiver = kity.createClass('Receiver', {
var lastOffset = this.textData[this.textData.length - 1];
width = lastOffset.x - startOffset.x + lastOffset.width;
} catch (e) {
console.log('e');
console.log(e);
}
} else {
......
......@@ -74,6 +74,10 @@ KityMinder.registerProtocal( 'mindmanager', function () {
return result;
}
function onerror(){
alert('文件过程解压出错,请检查该文件是否损坏');
}
function getEntries( file, onend ) {
zip.createReader( new zip.BlobReader( file ), function ( zipReader ) {
zipReader.getEntries( onend );
......
......@@ -80,6 +80,10 @@ KityMinder.registerProtocal( 'xmind', function () {
return result;
}
function onerror(){
alert('文件过程解压出错,请检查该文件是否损坏');
}
function getEntries(file, onend) {
zip.createReader(new zip.BlobReader(file), function(zipReader) {
zipReader.getEntries(onend);
......
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