Commit 0333a2d9 authored by techird's avatar techird

merge reflact

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