提交 1cdee1f2 编写于 作者: C campaign

Merge branch 'dev-1.2.7' of https://github.com/campaign/ueditor into dev-1.2.7

......@@ -37,8 +37,7 @@
docStyle.backgroundImage = 'url("about:blank")';
docStyle.backgroundAttachment = 'fixed';
}
var bakCssText,
placeHolder = document.createElement('div'),
var placeHolder = document.createElement('div'),
toolbarBox,orgTop,
getPosition,
flag =true; //ie7模式下需要偏移
......@@ -71,7 +70,6 @@
if(placeHolder.parentNode){
placeHolder.parentNode.removeChild(placeHolder);
}
toolbarBox.style.cssText = bakCssText;
}
function updateFloating(){
......@@ -98,7 +96,6 @@
getPosition = uiUtils.getClientRect;
toolbarBox = me.ui.getDom('toolbarbox');
orgTop = getPosition(toolbarBox).top;
bakCssText = toolbarBox.style.cssText;
placeHolder.style.height = toolbarBox.offsetHeight + 'px';
if(LteIE6){
fixIE6FixedPos();
......
......@@ -88,7 +88,7 @@ UE.plugins['autoheight'] = function () {
domUtils.on(browser.ie ? me.body : me.document, browser.webkit ? 'dragover' : 'drop', function () {
clearTimeout(timer);
timer = setTimeout(function () {
adjustHeight.call(this);
adjustHeight.call(me);
}, 100);
});
......
///import core
///commands 修复chrome下图片不能点击的问题
///commands 修复chrome下图片不能点击的问题,出现八个角可改变大小
///commandsName FixImgClick
///commandsTitle 修复chrome下图片不能点击的问题
//修复chrome下图片不能点击的问题
//todo 可以改大小
UE.plugins['fiximgclick'] = function() {
var me = this;
if ( browser.webkit ) {
me.addListener( 'click', function( type, e ) {
if ( e.target.tagName == 'IMG' ) {
var range = new dom.Range( me.document );
range.selectNode( e.target ).select();
///commandsTitle 修复chrome下图片不能点击的问题,出现八个角可改变大小
//修复chrome下图片不能点击的问题,出现八个角可改变大小
UE.plugins['fiximgclick'] = (function () {
function Scale() {
this.editor = null;
this.resizer = null;
this.cover = null;
this.doc = document;
this.prePos = {x: 0, y: 0};
this.startPos = {x: 0, y: 0};
}
(function () {
var rect = [
//[left, top, width, height]
[0, 0, -1, -1],
[0, 0, 0, -1],
[0, 0, 1, -1],
[0, 0, -1, 0],
[0, 0, 1, 0],
[0, 0, -1, 1],
[0, 0, 0, 1],
[0, 0, 1, 1]
];
Scale.prototype = {
init: function (editor) {
var me = this;
me.editor = editor;
me.startPos = this.prePos = {x: 0, y: 0};
me.dragId = -1;
var hands = [],
cover = me.cover = document.createElement('div'),
resizer = me.resizer = document.createElement('div');
cover.id = me.editor.ui.id + '_imagescale_cover';
cover.style.cssText = 'position:absolute;display:none;z-index:' + (me.editor.options.zIndex) + ';filter:alpha(opacity=0); opacity:0;background:#CCC;';
domUtils.on(cover, 'mousedown click', function () {
me.hide();
});
for (i = 0; i < 8; i++) {
hands.push('<span class="edui-editor-scale-hand' + i + '"></span>');
}
resizer.id = me.editor.ui.id + '_imagescale';
resizer.className = 'edui-editor-scale';
resizer.innerHTML = hands.join('');
resizer.style.cssText += ';display:none;border:1px solid #3b77ff;z-index:' + (me.editor.options.zIndex) + ';';
me.editor.ui.getDom().appendChild(cover);
me.editor.ui.getDom().appendChild(resizer);
me.initStyle();
me.initEvents();
},
initStyle: function () {
utils.cssRule('imagescale', '.edui-editor-scale{position:absolute;border:1px solid #38B2CE;}' +
'.edui-editor-scale span{position:absolute;width:6px;height:6px;overflow:hidden;font-size:0px;display:block;background-color:#3C9DD0;}'
+ '.edui-editor-scale .edui-editor-scale-hand0{cursor:nw-resize;top:0;margin-top:-4px;left:0;margin-left:-4px;}'
+ '.edui-editor-scale .edui-editor-scale-hand1{cursor:n-resize;top:0;margin-top:-4px;left:50%;margin-left:-4px;}'
+ '.edui-editor-scale .edui-editor-scale-hand2{cursor:ne-resize;top:0;margin-top:-4px;left:100%;margin-left:-3px;}'
+ '.edui-editor-scale .edui-editor-scale-hand3{cursor:w-resize;top:50%;margin-top:-4px;left:0;margin-left:-4px;}'
+ '.edui-editor-scale .edui-editor-scale-hand4{cursor:e-resize;top:50%;margin-top:-4px;left:100%;margin-left:-3px;}'
+ '.edui-editor-scale .edui-editor-scale-hand5{cursor:sw-resize;top:100%;margin-top:-3px;left:0;margin-left:-4px;}'
+ '.edui-editor-scale .edui-editor-scale-hand6{cursor:s-resize;top:100%;margin-top:-3px;left:50%;margin-left:-4px;}'
+ '.edui-editor-scale .edui-editor-scale-hand7{cursor:se-resize;top:100%;margin-top:-3px;left:100%;margin-left:-3px;}');
},
initEvents: function () {
var me = this;
me.startPos.x = me.startPos.y = 0;
me.isDraging = false;
},
_eventHandler: function (e) {
var me = this;
switch (e.type) {
case 'mousedown':
var hand = e.target || e.srcElement, hand;
if (hand.className.indexOf('edui-editor-scale-hand') != -1 && me.dragId == -1) {
me.dragId = hand.className.slice(-1);
me.startPos.x = me.prePos.x = e.clientX;
me.startPos.y = me.prePos.y = e.clientY;
domUtils.on(me.doc,'mousemove', me.proxy(me._eventHandler, me));
}
break;
case 'mousemove':
if (me.dragId != -1) {
me.updateContainerStyle(me.dragId, {x: e.clientX - me.prePos.x, y: e.clientY - me.prePos.y});
me.prePos.x = e.clientX;
me.prePos.y = e.clientY;
me.updateTargetElement();
}
break;
case 'mouseup':
if (me.dragId != -1) {
me.updateContainerStyle(me.dragId, {x: e.clientX - me.prePos.x, y: e.clientY - me.prePos.y});
me.updateTargetElement();
if (me.target.parentNode) me.attachTo(me.target);
me.dragId = -1;
}
domUtils.un(me.doc,'mousemove', me.proxy(me._eventHandler, me));
break;
default:
break;
}
},
updateTargetElement: function () {
var me = this,
targetPos;
domUtils.setStyles(me.target, {
'width': me.resizer.style.width,
'height': me.resizer.style.height
})
me.attachTo(me.target);
},
updateContainerStyle: function (dir, offset) {
var me = this,
dom = me.resizer, tmp;
if (rect[dir][0] != 0) {
tmp = parseInt(dom.style.left) + offset.x;
dom.style.left = me._validScaledProp('left', tmp) + 'px';
}
if (rect[dir][1] != 0) {
tmp = parseInt(dom.style.top) + offset.y;
dom.style.top = me._validScaledProp('top', tmp) + 'px';
}
if (rect[dir][2] != 0) {
tmp = dom.clientWidth + rect[dir][2] * offset.x;
dom.style.width = me._validScaledProp('width', tmp) + 'px';
}
if (rect[dir][3] != 0) {
tmp = dom.clientHeight + rect[dir][3] * offset.y;
dom.style.height = me._validScaledProp('height', tmp) + 'px';
}
},
_validScaledProp: function (prop, value) {
var ele = this.resizer,
wrap = document;
value = isNaN(value) ? 0 : value;
switch (prop) {
case 'left':
return value < 0 ? 0 : (value + ele.clientWidth) > wrap.clientWidth ? wrap.clientWidth - ele.clientWidth : value;
case 'top':
return value < 0 ? 0 : (value + ele.clientHeight) > wrap.clientHeight ? wrap.clientHeight - ele.clientHeight : value;
case 'width':
return value <= 0 ? 1 : (value + ele.offsetLeft) > wrap.clientWidth ? wrap.clientWidth - ele.offsetLeft : value;
case 'height':
return value <= 0 ? 1 : (value + ele.offsetTop) > wrap.clientHeight ? wrap.clientHeight - ele.offsetTop : value;
}
},
hideCover: function () {
this.cover.style.display = 'none';
},
showCover: function () {
var me = this,
editorPos = domUtils.getXY(me.editor.ui.getDom()),
iframePos = domUtils.getXY(me.editor.iframe);
domUtils.setStyles(me.cover, {
'width': me.editor.iframe.offsetWidth + 'px',
'height': me.editor.iframe.offsetHeight + 'px',
'top': iframePos.y - editorPos.y + 'px',
'left': iframePos.x - editorPos.x + 'px',
'position': 'absolute',
'display': ''
})
},
show: function (targetObj) {
var me = this;
me.resizer.style.display = 'block';
if(targetObj) me.attachTo(targetObj);
domUtils.on(this.resizer, 'mousedown', me.proxy(me._eventHandler, me));
domUtils.on(me.doc, 'mouseup', me.proxy(me._eventHandler, me));
me.showCover();
me.editor.fireEvent('afterscaleshow', me);
me.editor.fireEvent('saveScene');
},
hide: function () {
var me = this;
me.hideCover();
me.resizer.style.display = 'none';
domUtils.un(me.resizer, 'mousedown', me.proxy(me._eventHandler, me));
domUtils.un(me.doc, 'mouseup', me.proxy(me._eventHandler, me));
me.editor.fireEvent('afterscalehide', me);
},
proxy: function( fn, context ) {
return function(e) {
return fn.apply( context || this, arguments);
};
},
attachTo: function (targetObj) {
var me = this,
target = me.target = targetObj,
resizer = this.resizer,
imgPos = domUtils.getXY(target),
iframePos = domUtils.getXY(me.editor.iframe),
editorPos = domUtils.getXY(resizer.parentNode);
domUtils.setStyles(resizer, {
'width': target.width + 'px',
'height': target.height + 'px',
'left': iframePos.x + imgPos.x - me.editor.document.body.scrollLeft - editorPos.x - parseInt(resizer.style.borderLeftWidth) + 'px',
'top': iframePos.y + imgPos.y - me.editor.document.body.scrollTop - editorPos.y - parseInt(resizer.style.borderTopWidth) + 'px'
});
}
} );
}
})();
return function () {
var me = this,
imageScale;
if (browser.webkit) {
me.addListener('click', function (type, e) {
var range = me.selection.getRange(),
img = range.getClosedNode();
if (img && img.tagName == 'IMG') {
if (!imageScale) {
imageScale = new Scale();
imageScale.init(me);
me.ui.getDom().appendChild(imageScale.resizer);
var _keyDownHandler = function (e) {
imageScale.hide();
}, _mouseDownHandler = function (e) {
var ele = e.target || e.srcElement;
if (ele && (ele.className===undefined || ele.className.indexOf('edui-editor-scale') == -1)) {
_keyDownHandler(e);
}
}, timer;
me.addListener('afterscaleshow', function (e) {
domUtils.on(document, 'keydown', _keyDownHandler);
domUtils.on(me.document,'keydown', _keyDownHandler);
domUtils.on(document,'mousedown', _mouseDownHandler);
domUtils.on(me.document,'mousedown', _mouseDownHandler);
me.selection.getNative().removeAllRanges();
});
me.addListener('afterscalehide', function (e) {
domUtils.un(document, 'keydown', _keyDownHandler);
domUtils.un(me.document,'keydown', _keyDownHandler);
domUtils.un(document,'mousedown', _mouseDownHandler);
domUtils.un(me.document,'mousedown', _mouseDownHandler);
var target = imageScale.target;
if (target.parentNode) {
me.selection.getRange().selectNode(target).select();
}
});
//TODO 有iframe的情况,mousedown不能往下传。。
domUtils.on(imageScale.resizer, 'mousedown', function (e) {
me.selection.getNative().removeAllRanges();
var ele = e.target || e.srcElement;
if (ele && ele.className.indexOf('edui-editor-scale-hand') == -1) {
timer = setTimeout(function () {
imageScale.hide();
}, 200);
}
});
domUtils.on(imageScale.resizer, 'mouseup', function (e) {
var ele = e.target || e.srcElement;
if (ele && ele.className.indexOf('edui-editor-scale-hand') == -1) {
clearTimeout(timer);
}
});
}
imageScale.show(img);
} else {
if (imageScale && imageScale.resizer.style.display != 'none') imageScale.hide();
}
});
me.addListener('click', function (type, e) {
if (e.target.tagName == 'IMG') {
var range = new dom.Range(me.document);
range.selectNode(e.target).select();
}
});
}
}
};
\ No newline at end of file
})();
\ No newline at end of file
此差异已折叠。
......@@ -3,82 +3,100 @@ module( "EventBase" );
test( "addListener,fireEvent", function() {
var editor = te.obj[1];
var div = te.dom[0];
editor.render( div );
editor.focus();
expect(6);
editor.render(div);
stop();
editor.ready(function () {
editor.focus();
editor.addListener( "event1", function() {
ok( true, "listener1 is fired" );
} );
editor.addListener( "event2", function() {
ok( true, "listener2 is fired" );
} );
editor.fireEvent( "event1" );
editor.fireEvent( "event2" );
editor.addListener("event1", function () {
ok(true, "listener1 is fired");
});
editor.addListener("event2", function () {
ok(true, "listener2 is fired");
});
editor.fireEvent("event1");
editor.fireEvent("event2");
editor.fireEvent( "event1 event2" );
var fun=function(type) {
ok( true, type + " is fired" );
};
editor.addListener( "event3 event4 ", fun);
editor.fireEvent( "event3 event4 " );
expect(6 );
editor.fireEvent("event1 event2");
var fun = function (type) {
ok(true, type + " is fired");
};
editor.addListener("event3 event4 ", fun);
editor.fireEvent("event3 event4 ");
start();
});
} );
test( "addListener,fireEvent --同一个侦听器绑定多个事件", function() {
var editor = te.obj[1];
var div = te.dom[0];
editor.render( div );
editor.focus();
expect( 2 );
editor.addListener( "event1", function() {
ok( true, "listener1 is fired" );
} );
editor.addListener( "event1", function() {
ok( true, "listener2 is fired" );
} );
editor.fireEvent( "event1" );
stop();
editor.ready(function () {
editor.focus();
editor.addListener( "event1", function() {
ok( true, "listener1 is fired" );
} );
editor.addListener( "event1", function() {
ok( true, "listener2 is fired" );
} );
editor.fireEvent( "event1" );
start();
});
} );
test( "removeListener", function() {
var editor = te.obj[1];
var div = te.dom[0];
editor.render( div );
editor.focus();
editor.render( div);
expect(3);
stop();
editor.ready(function () {
editor.focus();
function fun1() {
ok(true, "listener1 is fired");
}
function fun2() {
ok(true, "listener2 is fired");
}
function fun1() {
ok( true, "listener1 is fired" );
}
function fun2() {
ok( true, "listener2 is fired" );
}
editor.addListener( "event1", fun1 );
editor.addListener( "event1", fun2 );
editor.fireEvent( "event1" );
editor.removeListener( "event1", fun1 );
editor.fireEvent( "event1" );
editor.addListener("event1", fun1);
editor.addListener("event1", fun2);
editor.fireEvent("event1");
function fun(type){
ok( true, type + " is fired" );
}
editor.addListener( "event3 event4 ",fun);
editor.removeListener( "event3 event4 ", fun );
editor.fireEvent( "event3 event4 " );
expect( 3 );
editor.removeListener("event1", fun1);
editor.fireEvent("event1");
function fun(type) {
ok(true, type + " is fired");
}
editor.addListener("event3 event4 ", fun);
editor.removeListener("event3 event4 ", fun);
editor.fireEvent("event3 event4 ");
start();
});
} );
test( "fireEvent--nolisteners", function() {
var editor = te.obj[1];
var div = te.dom[0];
editor.render( div );
editor.focus();
function fun1() {
ok( true, "listener1 is fired" );
}
editor.render(div);
stop();
editor.ready(function () {
editor.focus();
function fun1() {
ok(true, "listener1 is fired");
}
editor.fireEvent( "event1" );//no listener is fired
editor.addListener( "event1", fun1 );
editor.fireEvent( "event1" );//listener1 and listener2 are both fired
editor.fireEvent("event1");//no listener is fired
editor.addListener("event1", fun1);
editor.fireEvent("event1");//listener1 and listener2 are both fired
start();
});
} );
......@@ -1465,8 +1465,10 @@ test('b节点取range', function () {
editor.setContent('<p>hello<strong>hello1</strong>hello2</p>');
range.setStart(editor.body.firstChild.lastChild, 0).collapse(1).select();
range = editor.selection.getRange();
if (ua.browser.ie || ua.browser.webkit)
if ((ua.browser.ie &&ua.browser.ie < 9) || ua.browser.webkit)
ua.checkResult(range, editor.body.firstChild.lastChild.previousSibling, editor.body.firstChild.lastChild.previousSibling, 1, 1, true, '节点后--check range');
else if(ua.browser.ie &&ua.browser.ie > 8)//todo ie9,10改range
ua.checkResult(range, editor.body.firstChild, editor.body.firstChild, 3, 3, true, '节点后--check range');
else
ua.checkResult(range, editor.body.firstChild.lastChild.previousSibling, editor.body.firstChild.lastChild.previousSibling, 0, 0, true, '节点后--check range');
......@@ -1475,8 +1477,10 @@ test('b节点取range', function () {
range = editor.selection.getRange();
if (ua.browser.webkit)
ua.checkResult(range, editor.body.firstChild.firstChild.nextSibling.firstChild, editor.body.firstChild.firstChild.nextSibling.firstChild, 1, 1, true, '节点内文本节点前--check range');
else if (ua.browser.ie)
else if (ua.browser.ie&&ua.browser.ie < 9)
ua.checkResult(range, editor.body.firstChild.childNodes[1].childNodes[1], editor.body.firstChild.childNodes[1].childNodes[1], 0, 0, true, '节点内文本节点前--check range');
else if(ua.browser.ie &&ua.browser.ie > 8)//todo ie9,10改range
ua.checkResult(range, editor.body.firstChild.childNodes[1], editor.body.firstChild.childNodes[1], 1, 1, true, '节点内文本节点前--check range');
else
ua.checkResult(range, editor.body.firstChild.firstChild.nextSibling.firstChild, editor.body.firstChild.firstChild.nextSibling.firstChild, 0, 0, true, '节点内文本节点前--check range');
......@@ -1484,8 +1488,10 @@ test('b节点取range', function () {
range = editor.selection.getRange();
if (ua.browser.webkit)
ua.checkResult(range, editor.body.firstChild.childNodes[1].firstChild, editor.body.firstChild.childNodes[1].firstChild, 1, 1, true, 'b节点--check range');
else if (ua.browser.ie)
else if (ua.browser.ie&&ua.browser.ie < 9)
ua.checkResult(range, editor.body.firstChild.childNodes[1].childNodes[1], editor.body.firstChild.childNodes[1].childNodes[1], 0, 0, true, '节点内文本节点前--check range');
else if(ua.browser.ie &&ua.browser.ie > 8)//todo ie9,10改range
ua.checkResult(range, editor.body.firstChild.childNodes[1], editor.body.firstChild.childNodes[1], 1, 1, true, '节点内文本节点前--check range');
else
ua.checkResult(range, editor.body.firstChild.childNodes[1].firstChild, editor.body.firstChild.childNodes[1].firstChild, 0, 0, true, 'b节点--check range');
start();
......@@ -1501,9 +1507,10 @@ test('文本节点中间取range', function () {
var range = new baidu.editor.dom.Range(editor.document);
editor.setContent('<p>hello2</p>');
range.setStart(editor.body.firstChild.firstChild, 2).collapse(1).select();
range = editor.selection.getRange();
if (ua.browser.ie)
range = editor.selection.getRange(); if (ua.browser.ie&&ua.browser.ie < 9)
ua.checkResult(range, editor.body.firstChild.lastChild, editor.body.firstChild.lastChild, 0, 0, true, 'check range');
else if(ua.browser.ie &&ua.browser.ie > 8)//todo ie9,10改range
ua.checkResult(range, editor.body.firstChild, editor.body.firstChild, 2, 2, true, 'check range');
else
ua.checkResult(range, editor.body.firstChild.lastChild, editor.body.firstChild.lastChild, 2, 2, true, 'check range');
start();
......
......@@ -90,49 +90,48 @@ module("core.Selection");
test('getRange--闭合选区的边界情况', function () {
var div_new = document.createElement('div');
document.body.appendChild(div_new);
var editor = new baidu.editor.Editor({'autoFloatEnabled':false});
var editor = new baidu.editor.Editor({'autoFloatEnabled': false});
stop();
setTimeout(function () {
editor.render(div_new);
editor.ready(function () {
setTimeout(function () {
var range = new baidu.editor.dom.Range(editor.document);
editor.setContent('<p><strong>xxx</strong></p>');
range.setStart(editor.body.firstChild.firstChild, 0).collapse(true).select();
range = editor.selection.getRange();
var strong = editor.body.firstChild.firstChild;
ok(range.startContainer.nodeType == 3, 'startContainer是文本节点');
/*startContainer:ie is xxx,others are strong.firstChild*/
ok(( range.startContainer === strong.firstChild) && strong.firstChild.length == 1 || (range.startContainer.nodeValue.length == 3 && range.startContainer === strong.lastChild), 'startContainer是xxx左边的占位符或者xxx');
ua.manualDeleteFillData(editor.body);
range.setStart(editor.body.firstChild.firstChild, 1).collapse(true).select();
/*去掉占位符*/
range = editor.selection.getRange();
/*可能为(strong,1)或者(xxx,3)*/
ok(( range.startContainer === strong) || ( range.startContainer === strong.lastChild) && strong.lastChild.length == 1 || (range.startContainer.nodeValue.length == 3 && range.startContainer === strong.firstChild), 'startContainer是xxx或者xxx右边的占位符');
var range = new baidu.editor.dom.Range(editor.document);
editor.setContent('<p><strong>xxx</strong></p>');
range.setStart(editor.body.firstChild.firstChild, 0).collapse(true).select();
range = editor.selection.getRange();
var strong = editor.body.firstChild.firstChild;
if(ua.browser.ie&&ua.browser.ie>8){//todo ie9,10改range
ok(range.startContainer === strong,'startContainer是strong');
ok(range.startOffset == 1,'startOffset是1')
}
else{
ok(range.startContainer.nodeType == 3, 'startContainer是文本节点');
/*startContainer:ie is xxx,others are strong.firstChild*/
ok(( range.startContainer === strong.firstChild) && strong.firstChild.length == 1 || (range.startContainer.nodeValue.length == 3 && range.startContainer === strong.lastChild), 'startContainer是xxx左边的占位符或者xxx');
}
ua.manualDeleteFillData(editor.body);
range.setStart(editor.body.firstChild.firstChild, 1).collapse(true).select();
/*去掉占位符*/
range = editor.selection.getRange();
/*可能为(strong,1)或者(xxx,3)*/
ok(( range.startContainer === strong) || ( range.startContainer === strong.lastChild) && strong.lastChild.length == 1 || (range.startContainer.nodeValue.length == 3 && range.startContainer === strong.firstChild), 'startContainer是xxx或者xxx右边的占位符');
// ok( range.startContainer.nodeType == 1 ? range.startContainer.tagName.toLowerCase() == 'strong' && range.startOffset == 1 : range.startContainer.data == 'xxx' && range.startOffset == 3, 'strong,1或xxx,3' );
ua.manualDeleteFillData(editor.body);
/*p,0*/
range.setStart(editor.body.firstChild, 0).collapse(true).select();
range = editor.selection.getRange();
/*startContainer:ie is xxx,ff is p, chrome is strong*/
ua.manualDeleteFillData(editor.body);
/*p,0*/
range.setStart(editor.body.firstChild, 0).collapse(true).select();
range = editor.selection.getRange();
/*startContainer:ie is xxx,ff is p, chrome is strong*/
// ok( ( range.startContainer === strong.parentNode.firstChild)&& strong.parentNode.firstChild.length == 1 || (range.startContainer.nodeValue.length == 3 && range.startContainer === strong.firstChild.nextSibling), 'startContainer是第一个占位符或者xxx' );
// ua.manualDeleteFillData( editor.body );
// range.setStart( editor.body.firstChild, 1 ).collapse( true ).select();
// equal( range.startContainer.tagName.toLowerCase(), 'p', 'p,1' );
te.dom.push(div_new);
te.obj.push(editor);
start();
te.dom.push(div_new);
te.obj.push(editor);
start();
}, 50);
});
}, 50);
......@@ -148,8 +147,8 @@ test('trace 1742 isFocus', function () {
var div2 = document.createElement('div');
document.body.appendChild(div1);
document.body.appendChild(div2);
var editor1 = new UE.Editor({'initialContent':'<span>hello</span>', 'autoFloatEnabled':false});
var editor2 = new UE.Editor({'initialContent':'<span>hello</span>', 'autoFloatEnabled':false});
var editor1 = new UE.Editor({'initialContent': '<span>hello</span>', 'autoFloatEnabled': false});
var editor2 = new UE.Editor({'initialContent': '<span>hello</span>', 'autoFloatEnabled': false});
editor1.render(div1);
stop();
editor1.ready(function () {
......@@ -168,8 +167,8 @@ test('trace 1742 isFocus', function () {
var div4 = document.createElement('div');
document.body.appendChild(div3);
document.body.appendChild(div4);
var editor3 = new UE.Editor({'initialContent':'<h1>hello</h1>', 'autoFloatEnabled':false});
var editor4 = new UE.Editor({'initialContent':'<h1>hello</h1>', 'autoFloatEnabled':false});
var editor3 = new UE.Editor({'initialContent': '<h1>hello</h1>', 'autoFloatEnabled': false});
var editor4 = new UE.Editor({'initialContent': '<h1>hello</h1>', 'autoFloatEnabled': false});
editor3.render(div3);
editor3.ready(function () {
editor4.render(div4);
......
......@@ -1073,8 +1073,7 @@ test( 'getComputedStyle-在body上设置字体大小', function() {
var h1 = body.appendChild( editor.document.createElement( 'h1' ) );
// editor.body.style['fontSize'] = '10px';
// h1的字体大小不是10px
//TODO 各个浏览器没有默认的H1的大小,在默认字体大小为16px时,ie下H1的大小为33px,其他为32px
var fontSize = (ua.browser.ie && ua.browser.ie < 9) ? '33px' : '32px';
var fontSize = '32px';
equal( domUtils.getComputedStyle( h1, 'font-size' ), fontSize, 'body的fontSize属性不应当覆盖p的fontSize属性' );
// editor.setContent( '<h2>这是h2的文本<a>这是一个超链接</a></h2>' );
start();
......
......@@ -25,6 +25,7 @@
te.obj.push(domUtils);
}
var _d = function () {
if (te) {
if (te.dom && te.dom.length) {
for (var i = 0; i < te.dom.length; i++) {
......
......@@ -8,7 +8,7 @@ test('文本居中',function(){
editor.execCommand('autotypeset');
equal($(editor.body.firstChild).css('text-align'),'center','文本居中');
start();
}, 50 );
}, 100 );
stop();
});
......
......@@ -69,9 +69,9 @@ test( '不闭合插入上下标', function () {
setTimeout( function () {
range.setStart( body.firstChild.firstChild, 0 ).setEnd( body.firstChild.lastChild, 3 ).select();
editor.execCommand( 'superscript' );
ua.manualDeleteFillData( body );
ua.checkSameHtml( editor.getContent(), '<p><sup><strong>hello1<em>hello2</em></strong></sup><a href="http://www.baid.com/" ><sup><strong>baidu_link</strong></sup></a><sup>hel</sup>lo3</p>', '普通文本添加上标' );
start();
ua.manualDeleteFillData( body );
ua.checkSameHtml( editor.getContent(), '<p><sup><strong>hello1<em>hello2</em></strong></sup><a href="http://www.baid.com/" ><sup><strong>baidu_link</strong></sup></a><sup>hel</sup>lo3</p>', '普通文本添加上标' );
start();
}, 100 );
} );
......@@ -93,10 +93,11 @@ test( 'trace 870:加粗文本前面去加粗', function () {
equal( editor.queryCommandState( 'bold' ), 0, '不加粗' );
range.insertNode( editor.document.createTextNode( 'hello2' ) ); /*插入一个文本节点*/
ua.manualDeleteFillData( editor.body );
if (!ua.browser.chrome && !ua.browser.safari) /*ie下插入节点后会自动移动光标到节点后面,而其他浏览器不会*/
equal( editor.getContent(), '<p><strong>hello</strong>hello2<br/></p>' );
else
/*ie下插入节点后会自动移动光标到节点后面,而其他浏览器不会*/
if(ua.browser.chrome ||ua.browser.safari ||(ua.browser.ie&&ua.browser.ie>8))//todo ie9,10改range
equal( editor.getContent(), '<p>hello2<strong>hello</strong><br/></p>' );
else
equal( editor.getContent(), '<p><strong>hello</strong>hello2<br/></p>' );
} );
/*trace 1043*/
......@@ -215,7 +216,7 @@ test( '单击B再在其他地方单击I,空的strong标签被删除 ', functio
equal( editor.queryCommandState( 'italic' ), 1, 'b高亮' );
ua.manualDeleteFillData( body );
if(!ua.browser.ie){ //ie下有问题不能修,屏蔽ie
equal( body.innerHTML.toLowerCase(), '<p><em></em>hello</p>', '空strong标签被删除' )
equal( body.innerHTML.toLowerCase(), '<p><em></em>hello</p>', '空strong标签被删除' )
}
} );
......@@ -225,20 +226,20 @@ test( 'ctrl+i', function() {
var editor = UE.getEditor('ue');
editor.ready(function () {
var range = new baidu.editor.dom.Range(editor.document);
var body = editor.body;
editor.setContent( '<p>没有加粗的文本</p>' );
range.selectNode( body.firstChild ).select();
var p = body.firstChild;
editor.focus();
setTimeout( function() {
ua.keydown(editor.body,{'keyCode':73,'ctrlKey':true});
var body = editor.body;
editor.setContent( '<p>没有加粗的文本</p>' );
range.selectNode( body.firstChild ).select();
var p = body.firstChild;
editor.focus();
setTimeout( function() {
equal( ua.getChildHTML( p ), '<em>没有加粗的文本</em>' );
UE.delEditor('ue');
start();
}, 150 );
}, 100 );
ua.keydown(editor.body,{'keyCode':73,'ctrlKey':true});
editor.focus();
setTimeout( function() {
equal( ua.getChildHTML( p ), '<em>没有加粗的文本</em>' );
UE.delEditor('ue');
start();
}, 150 );
}, 100 );
});
stop();
} );
......@@ -249,21 +250,21 @@ test( 'ctrl+u', function() {
var editor = UE.getEditor('ue');
editor.ready(function () {
var range = new baidu.editor.dom.Range(editor.document);
var body = editor.body;
var body = editor.body;
editor.setContent( '<p>没有加粗的文本</p>' );
setTimeout( function() {
range.selectNode( body.firstChild ).select();
editor.focus();
editor.setContent( '<p>没有加粗的文本</p>' );
setTimeout( function() {
var html = '<span style="text-decoration: underline;">没有加粗的文本</span>';
ua.checkHTMLSameStyle( html, editor.document, body.firstChild, '文本被添加了下划线' );
equal(editor.body.firstChild.firstChild.style.textDecoration,'underline');
UE.delEditor('ue');
start();
range.selectNode( body.firstChild ).select();
editor.focus();
setTimeout( function() {
var html = '<span style="text-decoration: underline;">没有加粗的文本</span>';
ua.checkHTMLSameStyle( html, editor.document, body.firstChild, '文本被添加了下划线' );
equal(editor.body.firstChild.firstChild.style.textDecoration,'underline');
UE.delEditor('ue');
start();
}, 150 );
ua.keydown(editor.body,{'keyCode':85,'ctrlKey':true});
}, 150 );
ua.keydown(editor.body,{'keyCode':85,'ctrlKey':true});
}, 150 );
});
stop();
} );
......@@ -274,18 +275,18 @@ test( 'ctrl+b', function() {
var editor = UE.getEditor('ue');
editor.ready(function () {
var range = new baidu.editor.dom.Range(editor.document);
var body = editor.body;
editor.setContent( '<p>没有加粗的文本</p>' );
range.selectNode( body.firstChild ).select();
editor.focus();
setTimeout( function() {
ua.keydown(editor.body,{'keyCode':66,'ctrlKey':true});
var body = editor.body;
editor.setContent( '<p>没有加粗的文本</p>' );
range.selectNode( body.firstChild ).select();
editor.focus();
setTimeout( function() {
equal( ua.getChildHTML( body.firstChild ), '<strong>没有加粗的文本</strong>' );
UE.delEditor('ue');
start();
ua.keydown(editor.body,{'keyCode':66,'ctrlKey':true});
setTimeout( function() {
equal( ua.getChildHTML( body.firstChild ), '<strong>没有加粗的文本</strong>' );
UE.delEditor('ue');
start();
}, 150 );
}, 150 );
}, 150 );
});
stop();
} );
......
......@@ -37,7 +37,7 @@ test( '成功远程图片抓取', function () {
}, 100 );
te.dom.push( div );
},50);
});
},100);
} );
//test( '失败远程图片抓取', function () {
......
此差异已折叠。
......@@ -6,6 +6,20 @@
* To change this template use File | Settings | File Templates.
*/
module( 'plugins.defaultfilter' );
test( '对代码的行号不处理', function () {
var editor = te.obj[0];
editor.setContent( '<td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div></td>');
// var br = ua.browser.ie?'':'<br>';
var html = '<table><tbody><tr><td class=\"gutter\"><div class=\"line number1 index0 alt2\">1</div><div class=\"line number2 index1 alt1\">2</div></td></tr></tbody></table>';
ua.checkSameHtml(editor.body.innerHTML,html,'table补全,对代码的行号不处理')
} );
test( '空td,th,caption', function () {
var editor = te.obj[0];
editor.setContent( '<table><caption></caption><tbody><tr><th></th><th></th></tr><tr><td></td><td></td></tr><tr><td></td><td></td></tr></tbody></table>' );
var br = ua.browser.ie?'':'<br>';
var html = '<table><caption>'+br+'</caption><tbody><tr><th>'+br+'</th><th>'+br+'</th></tr><tr><td>'+br+'</td><td>'+br+'</td></tr><tr><td>'+br+'</td><td>'+br+'</td></tr></tbody></table>';
ua.checkSameHtml(editor.body.innerHTML,html,'空td,th,caption,添加text')
} );
test( '转换a标签', function () {
var editor = te.obj[0];
editor.setContent( '<a href="http://elearning.baidu.com/url/RepositoryEntry/68616197" target="_blank">' );
......@@ -34,12 +48,13 @@ test( '删span中的white-space标签', function () {
// var html = '<p style="list-style: none;">hello</p>';
// ua.checkSameHtml(html,editor.body.innerHTML,'删p中的margin|padding标签');
//} );
test( '给空p加br', function () {
test( '给空p加br&&转对齐样式', function () {
var editor = te.obj[0];
editor.setContent( '<p style="list-style: none;" ></p>' );
editor.setContent( '<p align ="center" ></p>' );
var br = ua.browser.ie?'&nbsp;':'<br>';
// var html = '<p style="list-style: none;">'+br+'</p>';
equal(editor.body.firstChild.innerHTML,br)
// "<p style=\"text-align:center;list-style: none;\"><br></p>"
var html = '<p style=\"text-align:center;\">'+br+'</p>';
ua.checkSameHtml(editor.body.innerHTML,html, '给空p加br&&转对齐样式');
} );
test( '删div', function () {
var editor = te.obj[0];
......@@ -47,6 +62,21 @@ test( '删div', function () {
var html = '<p>视频</p>';
ua.checkSameHtml(html,editor.body.innerHTML,'删div');
} );
test( 'allowDivTransToP--false 不转div', function () {
var div = document.body.appendChild(document.createElement('div'));
div.id ='ue';
var editor = UE.getEditor('ue',{allowDivTransToP:false});
stop();
editor.ready(function(){
var html = '<div class="socore" ><div class="sooption" style="padding: 1px;" >视频</div></div>';
editor.setContent( html );
var padding = (ua.browser.ie&&ua.browser.ie<9)?'PADDING-BOTTOM: 1px; PADDING-LEFT: 1px; PADDING-RIGHT: 1px; PADDING-TOP: 1px':'padding: 1px;';
var html_a = '<div class="socore" ><div class="sooption" style="'+padding+'" >视频</div></div>';
ua.checkSameHtml(html_a,editor.body.innerHTML,'不转div');
UE.delEditor('ue');
start();
});
} );
test( 'li', function () {
var editor = te.obj[0];
editor.setContent( '<li style="margin: 0px 0px 0px 6px;" ><a href="http://www.baidu.com/p/pistachio%E5%A4%A9?from=zhidao" class="user-name" >天<i class="i-arrow-down"></i></a></li>' );
......
此差异已折叠。
module( 'plugins.fiximgclick' );
test( 'webkit下图片可以被选中', function() {
test( 'webkit下图片可以被选中并出现八个角', function() {
if ( ua.browser.webkit ) {
var editor = te.obj[0];
editor.setContent( '<p>修正webkit下图片选择的问题<img src="" />修正webkit下图片选择的问题</p>' );
var img = editor.body.getElementsByTagName( 'img' )[0];
var range = editor.selection.getRange();
var p = editor.body.firstChild;
ua.click( img );
range = editor.selection.getRange();
ua.checkResult( range, p, p, 1, 2, false, '检查当前的range是否为img' );
var sc = document.createElement("script");
sc.id="sc";
sc.type = "text/plain";
document.body.appendChild(sc);
var editor = new UE.ui.Editor({'autoFloatEnabled':true,'topOffset':60,'autoHeightEnabled':true,'scaleEnabled':false});
editor.render(sc.id);
editor.ready(function () {
editor.setContent( '<p>修正webkit下图片选择的问题<img src="" width="200" height="100" />修正webkit下图片选择的问题</p>' );
var img = editor.body.getElementsByTagName( 'img' )[0];
var p = editor.body.firstChild;
ua.click( img );
var range = editor.selection.getRange();
ua.checkResult( range, p, p, 1, 2, false, '检查当前的range是否为img' );
var scale = document.getElementById(editor.ui.id + '_scale');
ok(scale && scale.style.display!='none', "检查八个角是否已出现");
ok(img.style.width == scale.style.width && img.style.height == scale.style.height, "检查八个角和图片宽高度是否相等");
UE.delEditor(sc.id);
domUtils.remove(sc);
start();
});
stop();
}
} );
test( '鼠标在八个角上拖拽改变图片大小', function() {
if ( ua.browser.webkit ) {
var sc = document.createElement("script");
sc.id="sc";
sc.type = "text/plain";
document.body.appendChild(sc);
var editor = new UE.ui.Editor({'autoFloatEnabled':true,'topOffset':60,'autoHeightEnabled':true,'scaleEnabled':false});
editor.render(sc.id);
editor.ready(function () {
editor.setContent( '<p>修正webkit下图片选择的问题<img src="" width="200" height="100" />修正webkit下图片选择的问题</p>' );
var img = editor.body.getElementsByTagName( 'img' )[0];
var p = editor.body.firstChild;
ua.click( img );
var scale = document.getElementById(editor.ui.id + '_imagescale');
var hand0 = scale.children[0], width, height;
width = parseInt(scale.style.width);
height = parseInt(scale.style.height);
ua.mousedown( hand0, {clientX: 322, clientY: 281} );
ua.mousemove( document, {clientX: 352, clientY: 301} );
equal(width-parseInt(scale.style.width), 30, "检查鼠标拖拽中图片宽度是否正确 --");
equal(height-parseInt(scale.style.height), 20, "检查鼠标拖拽中图片高度是否正确 --");
ua.mousemove( document, {clientX: 382, clientY: 321} );
ua.mouseup( document, {clientX: 382, clientY: 321} );
equal(width-parseInt(scale.style.width), 60, "检查鼠标拖拽完毕图片高度是否正确 --");
equal(height-parseInt(scale.style.height), 40, "检查鼠标拖拽完毕图片高度是否正确 --");
ok(img.style.width == scale.style.width && img.style.height == scale.style.height, "检查八个角和图片宽高度是否相等");
UE.delEditor(sc.id);
domUtils.remove(sc);
start();
});
stop();
}
} );
test( '鼠标点击图片外的其他区域时,八个角消失', function() {
if ( ua.browser.webkit ) {
var sc = document.createElement("script");
sc.id="sc";
sc.type = "text/plain";
document.body.appendChild(sc);
var editor = new UE.ui.Editor({'autoFloatEnabled':true,'topOffset':60,'autoHeightEnabled':true,'scaleEnabled':false});
editor.render(sc.id);
editor.ready(function () {
editor.setContent( '<p>修正webkit下图片选择的问题<img src="" width="200" height="100" />修正webkit下图片选择的问题</p>' );
var img = editor.body.getElementsByTagName( 'img' )[0];
var p = editor.body.firstChild;
ua.click( img );
var scale = document.getElementById(editor.ui.id + '_imagescale'),
cover = document.getElementById(editor.ui.id + '_imagescale_cover');
ok(scale && scale.style.display!='none', "检查八个角是否已出现");
ok(cover && cover.style.display!='none', "检查遮罩层是否已出现");
ua.mousedown( editor.ui.getDom(), {clientX: 100, clientY: 100} );
ok(cover && cover.style.display=='none', "检查遮罩层是否已消失");
ok(scale && scale.style.display=='none', "检查八个角是否已消失");
UE.delEditor(sc.id);
domUtils.remove(sc);
start();
});
stop();
}
} );
test( '键盘有操作时,八个角消失', function() {
if ( ua.browser.webkit ) {
var sc = document.createElement("script");
sc.id="sc";
sc.type = "text/plain";
document.body.appendChild(sc);
var editor = new UE.ui.Editor({'autoFloatEnabled':true,'topOffset':60,'autoHeightEnabled':true,'scaleEnabled':false});
editor.render(sc.id);
editor.ready(function () {
editor.setContent( '<p>修正webkit下图片选择的问题<img src="" width="200" height="100" />修正webkit下图片选择的问题</p>' );
var img = editor.body.getElementsByTagName( 'img' )[0];
var p = editor.body.firstChild;
ua.click( img );
var scale = document.getElementById(editor.ui.id + '_imagescale'),
cover = document.getElementById(editor.ui.id + '_imagescale_cover');
ok(scale && scale.style.display!='none', "检查八个角是否已出现");
ok(cover && cover.style.display!='none', "检查遮罩层是否已出现");
ua.keydown( editor.ui.getDom());
ok(cover && cover.style.display=='none', "检查遮罩层是否已消失");
ok(scale && scale.style.display=='none', "检查八个角是否已消失");
UE.delEditor(sc.id);
domUtils.remove(sc);
start();
});
stop();
}
} );
\ No newline at end of file
module("plugins.font");
test('trace 3337:字符边框', function () {
if (ua.browser.opera)return;
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('<p></p>');
range.setStart(editor.body.firstChild, 0).collapse(true).select();
editor.execCommand('fontborder');
range = editor.selection.getRange();
range.insertNode(editor.document.createTextNode('hello'));
ua.manualDeleteFillData(editor.body);
var br = baidu.editor.browser.ie ? '&nbsp;' : '<br>';
if (ua.browser.ie && ua.browser.ie < 9) {
equal(editor.queryCommandValue('fontborder'), '#000 1px solid', '检查反射值');
equal(ua.getChildHTML(editor.body.firstChild), "<span style=\"border-bottom: #000 1px solid; border-left: #000 1px solid; border-top: #000 1px solid; border-right: #000 1px solid\">hello</span>&nbsp;", '查看添加了字符边框后的样式');
}
else {
equal(editor.queryCommandValue('fontborder'), '1px solid rgb(0, 0, 0)', '检查反射值');
ua.checkHTMLSameStyle('<span style="border: 1px solid rgb(0, 0, 0);">hello</span>' + br, editor.document, editor.body.firstChild, '查看添加了字符边框后的样式');
}
range.setStart(editor.body.firstChild.firstChild.firstChild, 5).collapse(true).select();
editor.execCommand('fontborder');
equal(editor.queryCommandState('fontborder'), '0');
equal(editor.queryCommandValue('fontborder'), '', '无反射值');
editor.setContent('<p><span style="color: red">欢</span>迎光临</p>');
range.setStart(editor.body.firstChild.firstChild, 0).setEnd(editor.body.firstChild.lastChild, 3).select();
editor.execCommand('fontborder');
var p1 = '<span style="border: 1px solid rgb(0, 0, 0);"><span style="color: red;">欢</span>迎光临</span>';
var p2 = '<span style=\"border-bottom: #000 1px solid; border-left: #000 1px solid; border-top: #000 1px solid; border-right: #000 1px solid\"><span style="color: red;">欢</span>迎光临</span>';
if (ua.browser.ie && ua.browser.ie < 9)
ua.checkSameHtml(editor.body.firstChild.innerHTML, p2, '查看添加了字符边框后的样式');
else
ua.checkHTMLSameStyle(p1, editor.document, editor.body.firstChild, '查看添加了字符边框后的样式');
});
test('设置超链接前景色再清除颜色', function () {
if(ua.browser.ie < 9)return;//TODO 1.2.6
var editor = te.obj[2];
var div = document.body.appendChild(document.createElement('div'));
$(div).css('width', '500px').css('height', '500px').css('border', '1px solid #ccc');
editor.render(div);
stop();
editor.ready(function () {
var range = new baidu.editor.dom.Range(editor.document);
editor.setContent('<p>hello<a href="www.baidu.com">baidu</a></p>');
range.selectNode(editor.body.firstChild).select();
editor.execCommand('forecolor', 'rgb(255,0,0)');
editor.execCommand('backcolor', 'rgb(0,255,0)');
editor.execCommand('forecolor', 'default');
// var html = '<span style="background-color: rgb(0, 255, 0);">hello</span><a href="www.baidu.com" _href=\"www.baidu.com\" style="text-decoration: underline;"><span style="background-color: rgb(0, 255, 0);">baidu</span></a>';todo 1.2.6.1 样式复制了一次
var html = '<span style="background-color: rgb(0, 255, 0);">hello</span><a href="www.baidu.com" _href=\"www.baidu.com\" style="background-color: rgb(0, 255, 0);text-decoration: underline;"><span style="background-color: rgb(0, 255, 0);">baidu</span></a>';
ua.checkHTMLSameStyle(html, editor.document, editor.body.firstChild, '清除前景色');
setTimeout(function () {
div.parentNode.removeChild(div);
start();
}, 50);
});
});
test('font转span', function () {
var editor = te.obj[0];
......@@ -396,28 +454,6 @@ test('trace 744:设置超链接背景色后切换到源码再切回来', funct
});
});
test('设置超链接前景色再清除颜色', function () {
var editor = te.obj[2];
var div = document.body.appendChild(document.createElement('div'));
$(div).css('width', '500px').css('height', '500px').css('border', '1px solid #ccc');
editor.render(div);
stop();
editor.ready(function () {
var range = new baidu.editor.dom.Range(editor.document);
editor.setContent('<p>hello<a href="www.baidu.com">baidu</a></p>');
range.selectNode(editor.body.firstChild).select();
editor.execCommand('forecolor', 'rgb(255,0,0)');
editor.execCommand('backcolor', 'rgb(0,255,0)');
editor.execCommand('forecolor', 'default');
// var html = '<span style="background-color: rgb(0, 255, 0);">hello</span><a href="www.baidu.com" _href=\"www.baidu.com\" style="text-decoration: underline;"><span style="background-color: rgb(0, 255, 0);">baidu</span></a>';todo 1.2.6.1 样式复制了一次
var html = '<span style="background-color: rgb(0, 255, 0);">hello</span><a href="www.baidu.com" _href=\"www.baidu.com\" style="background-color: rgb(0, 255, 0);text-decoration: underline;"><span style="background-color: rgb(0, 255, 0);">baidu</span></a>';
ua.checkHTMLSameStyle(html, editor.document, editor.body.firstChild, '清除前景色');
setTimeout(function () {
div.parentNode.removeChild(div);
start();
}, 50);
});
});
test('对表格中的文本添加颜色和下划线', function () {
var editor = te.obj[2];
......@@ -517,39 +553,6 @@ test('trace 721:预先设置下划线和字体颜色,再输入文本,查
}
});
test('trace 3337:字符边框', function () {
if (ua.browser.opera)return;
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('<p></p>');
range.setStart(editor.body.firstChild, 0).collapse(true).select();
editor.execCommand('fontborder');
range = editor.selection.getRange();
range.insertNode(editor.document.createTextNode('hello'));
ua.manualDeleteFillData(editor.body);
var br = baidu.editor.browser.ie ? '&nbsp;' : '<br>';
if (ua.browser.ie && ua.browser.ie < 9) {
equal(editor.queryCommandValue('fontborder'), '#000 1px solid', '检查反射值');
equal(ua.getChildHTML(editor.body.firstChild), "<span style=\"border-bottom: #000 1px solid; border-left: #000 1px solid; border-top: #000 1px solid; border-right: #000 1px solid\">hello</span>&nbsp;", '查看添加了字符边框后的样式');
}
else {
equal(editor.queryCommandValue('fontborder'), '1px solid rgb(0, 0, 0)', '检查反射值');
ua.checkHTMLSameStyle('<span style="border: 1px solid rgb(0, 0, 0);">hello</span>' + br, editor.document, editor.body.firstChild, '查看添加了字符边框后的样式');
}
range.setStart(editor.body.firstChild.firstChild.firstChild, 5).collapse(true).select();
editor.execCommand('fontborder');
equal(editor.queryCommandState('fontborder'), '0');
equal(editor.queryCommandValue('fontborder'), '', '无反射值');
editor.setContent('<p><span style="color: red">欢</span>迎光临</p>');
range.setStart(editor.body.firstChild.firstChild, 0).setEnd(editor.body.firstChild.lastChild, 3).select();
editor.execCommand('fontborder');
var p1 = '<span style="border: 1px solid rgb(0, 0, 0);"><span style="color: red;">欢</span>迎光临</span>';
var p2 = '<span style=\"border-bottom: #000 1px solid; border-left: #000 1px solid; border-top: #000 1px solid; border-right: #000 1px solid\"><span style="color: red;">欢</span>迎光临</span>';
if (ua.browser.ie && ua.browser.ie < 9)
equal(ua.getChildHTML(editor.body.firstChild), p2, '查看添加了字符边框后的样式');
else
ua.checkHTMLSameStyle(p1, editor.document, editor.body.firstChild, '查看添加了字符边框后的样式');
});
test('trace 3342:字符ab, 给a 加边框再给b加边框,边框效果错误', function () {
var editor = te.obj[0];
......
......@@ -5,6 +5,26 @@ module( 'plugins.image' );
* 选区闭合和不闭合
* 表格中插入图像
*/
/*trace1491 修改动图的宽高*/
test( 'trace1491 修改动图的宽高', function () {
var editor = te.obj[0];
var range = te.obj[1];
var body = editor.body;
editor.setContent( '<p><br></p>' );
range.setStart( body.firstChild, 0 ).collapse( 1 ).select();
editor.execCommand( 'insertimage', {src:'../data/test.JPG'} );
ua.manualDeleteFillData( editor.body );
range.selectNode( body.firstChild.firstChild ).select();
var img = body.getElementsByTagName( 'img' )[0];
editor.execCommand( 'insertimage', {src:'../data/test.JPG', width:50, height:80} );
img.onload = function () {
equal( $( img ).attr( 'width' ), '50', '比较width' );
equal( $( img ).attr( 'height' ), '80', '比较width' );
start();
};
ok(/data\/test\.JPG/.test( img.getAttribute( 'src' )), '比较src' );
stop();
} );
test( '插入新图像', function () {
var editor = te.obj[0];
var range = te.obj[1];
......@@ -66,31 +86,6 @@ test( '修改已有图片的属性', function () {
equal( body.firstChild.childNodes.length, 3, '2个img孩子' );
} );
/*trace1491 修改动图的宽高*/
test( 'trace1491 修改动图的宽高', function () {
var editor = te.obj[0];
var range = te.obj[1];
var body = editor.body;
editor.setContent( '<p><br></p>' );
range.setStart( body.firstChild, 0 ).collapse( 1 ).select();
editor.execCommand( 'insertimage', {src:'../data/test.JPG'} );
ua.manualDeleteFillData( editor.body );
range.selectNode( body.firstChild.firstChild ).select();
var img = body.getElementsByTagName( 'img' )[0];
img.onload = function () { //这里必须要等一下才能过
equal( $( img ).attr( 'width' ), '30', '比较width' );
equal( $( img ).attr( 'height' ), '853', '比较width' );
start();
};
editor.execCommand( 'insertimage', {src:'../data/test.JPG', width:50, height:80} );
img.onload = function () {
equal( $( img ).attr( 'width' ), '50', '比较width' );
equal( $( img ).attr( 'height' ), '80', '比较width' );
start();
};
ok(/data\/test\.JPG/.test( img.getAttribute( 'src' )), '比较src' );
stop();
} );
test( '选区不闭合插入图像', function () {
var editor = te.obj[0];
......
module( "plugins.inserthtml" );
test( '向span里面插入p', function() {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('<address><span style="color:#ff0000">hello1</span></address>');
range.setStart(editor.body.firstChild.firstChild, 0 ).collapse(true).select();
editor.execCommand( 'inserthtml','<p >hello3</p>' );
stop();
setTimeout(function(){
// equal(editor.body.innerHTML.toLowerCase(),'<address><p >hello3</p><span style="color:#ff0000">hello1</span></address>','向span里面插入p');
ua.checkSameHtml(editor.body.getElementsByTagName('address')[0].innerHTML.toLowerCase(),'<p >hello3</p><span style="color:#ff0000">hello1</span>','向span里面插入p');
start();
},50);
});
//列表中插入列表 TODO 1.2.6 trace 3413
test( '列表中插入列表 trace 3413', function() {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('<ol><li><p>hello1</p></li><li><p>hello2</p></li></ol>');
var lis = editor.body.getElementsByTagName('li');
range.setStart( lis[1], 0 ).collapse(true).select();
editor.execCommand( 'inserthtml','<ul><li><p>hello3</p></li></ul>' );
stop();
setTimeout(function(){
lis = editor.body.getElementsByTagName('li');
equal(lis.length,3,'列表长度');
equal(lis[1].innerHTML.toLowerCase(),'<p>hello3</p>','列表中插入列表');
start();
},50);
});
test( 'trace 3301:闭合方式插入文本', function() {
var editor = te.obj[0];
......@@ -104,23 +134,7 @@ test( 'trace 3297:notSerialize', function() {
},50);
stop();
} );
//列表中插入列表 TODO 1.2.6 trace 3413
//test( '列表中插入列表', function() {
// var editor = te.obj[0];
// var range = te.obj[1];
// editor.setContent('<ol><li><p>hello1</p></li><li><p>hello2</p></li></ol>');
// var lis = editor.body.getElementsByTagName('li');
// range.setStart( lis[1], 0 ).collapse(true).select();
// editor.execCommand( 'inserthtml','<ul><li><p>hello3</p></li></ul>' );
// stop();
// setTimeout(function(){
//
//// equal(lis.length,1,'列表长度没有变化');
//// equal(lis[0].firstChild.tagName.toLowerCase(),'table','列表中插入表格');
//// start();
// },50);
//
//});
//列表中插入表格
test( '列表中插入表格', function() {
var editor = te.obj[0];
......
......@@ -8,6 +8,7 @@
module( "plugins.keystrokes" );
test('跨节点输入tab键',function(){
//todo ie9,10改range bug trace
var editor = te.obj[0];
editor.setContent( '<h1>hello<br></h1><p>he<img src="http://img.baidu.com/hi/jx2/j_0015.gif" />oll</p>' );
var range = te.obj[1];
......
......@@ -12,18 +12,20 @@ module("plugins.list");
* */
test('回车将p转成列表', function () {
//todo ie9,10改range bug trace
var editor = te.obj[0];
var range = te.obj[1];
var br = ua.browser.ie ? '' : '<br>';
editor.setContent('<p>1. 2</p>');
range.setStart(editor.body.firstChild, 0).collapse(true).select();
ua.keydown(editor.body, {keyCode:13});
stop()
stop();
setTimeout(function () {
ua.checkSameHtml(ua.getChildHTML(editor.body), '<ol style=\"list-style-type: decimal;\" class=\" list-paddingleft-2\"><li><p> 2</p></li><li><p>' + br + '</p></li></ol>', '回车将p转成列表');
start()
}, 50);
range.setStart(editor.body.firstChild, 0).collapse(true).select();
ua.keydown(editor.body, {keyCode:13});
setTimeout(function () {
ua.checkSameHtml(ua.getChildHTML(editor.body), '<ol style=\"list-style-type: decimal;\" class=\" list-paddingleft-2\"><li><p> 2</p></li><li><p>' + br + '</p></li></ol>', '回车将p转成列表');
start()
}, 50);
}, 100);
});
//todo bug3418
......@@ -40,16 +42,16 @@ test('li内添加p标签', function () {
ua.checkSameHtml(editor.body.innerHTML, '<ol class=\" list-paddingleft-2\"><li><p>asd</p><p>asd</p></li></ol>', '添加p标签');
});
//todo 1.2.6.1
test('p转成列表',function(){
test('p转成列表', function () {
var editor = te.obj[0];
var br = ua.browser.ie?'&nbsp;':'<br>';
var br = ua.browser.ie ? '&nbsp;' : '<br>';
editor.setContent('<p class="MsoListParagraph">1.a</p><ol><li>b</li></ol>');
ua.manualDeleteFillData(editor.body);
//todo 1.2.6.1
// ua.checkSameHtml(editor.body.innerHTML,'<ol style=\"list-style-type: decimal;\" class=\" list-paddingleft-2\"><li><p>a</p></li><li><p>b</p></li></ol>','p转成有序列表');
editor.setContent('<p class="MsoListParagraph"><span style="font-family: Symbol;">abc</span></p>');
ua.manualDeleteFillData(editor.body);
ua.checkSameHtml(editor.body.innerHTML,'<ul style=\"list-style-type: disc;\" class=\" list-paddingleft-2\"><li><p>'+br+'</p></li></ul>','p转成无序列表');
ua.checkSameHtml(editor.body.innerHTML, '<ul style=\"list-style-type: disc;\" class=\" list-paddingleft-2\"><li><p>' + br + '</p></li></ul>', 'p转成无序列表');
//todo bug3417
// editor.setContent('<p class="MsoListParagraph"><span style="font-family: Symbol;">n</span></p>');
// ua.manualDeleteFillData(editor.body);
......@@ -889,7 +891,7 @@ test('trace 3133:表格中插入列表再取消列表', function () {
/*插入列表*/
equal(tds[0].firstChild.tagName.toLowerCase(), 'ol', '查询列表的类型');
equal(ua.getChildHTML(tds[0].firstChild), '<li class="list-num-3-1 list-num2-paddingleft-1"><p><br></p></li>');
editor.execCommand('insertorderedlist', 'num2');
editor.execCommand('insertorderedlist', 'num2');
/*取消列表*/
equal(ua.getChildHTML(tds[0]), '<p><br></p>');
ua.keydown(editor.body, {'keyCode':65, 'ctrlKey':true});
......@@ -927,7 +929,7 @@ test('trace 3165:检查表格中列表tab键', function () {
editor.ready(function () {
var range = new baidu.editor.dom.Range(editor.document);
var body = editor.body;
setTimeout(function(){
setTimeout(function () {
editor.execCommand('inserttable');
var tds = body.getElementsByTagName('td');
range.setStart(tds[6], 0).collapse(1).select();
......@@ -939,14 +941,14 @@ test('trace 3165:检查表格中列表tab键', function () {
equal(range.startContainer.parentNode.tagName.toLowerCase(), 'td', 'tab键前光标位于td中');
ua.keydown(editor.body, {keyCode:9});
setTimeout(function () {
range = editor.selection.getRange();
range = editor.selection.getRange();
if (!ua.browser.gecko && !ua.browser.ie)//TODO 1.2.6
equal(range.startContainer.parentNode.tagName.toLowerCase(), 'li', 'tab键后光标跳到有列表的单元格中');
equal(tds[6].firstChild.style['listStyleType'], 'decimal', '检查有序列表的类型不应该被改变');
UE.delEditor('ue');
start();
}, 100);
},100);
}, 100);
});
stop();
......
......@@ -20,6 +20,7 @@ test('trace 3381:查找',function(){
///*trace 974,先替换再撤销再全部替换,则不会替换
//* ie下会出现的bug*/
test('全部替换',function(){
//todo ie9,10改range bug trace
if(ua.browser.opera)
return;
var editor = te.obj[0];
......
......@@ -11,22 +11,76 @@ test( '基本的shortcutmenu', function() {
//设置菜单内容\
var div = document.body.appendChild(document.createElement('div'));
div.id = 'ue';
var editor = UE.getEditor("ue" ,{ shortcutMenu: ["fontfamily", "fontsize", "bold", "italic", "underline", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist"]});
var editor = UE.getEditor("ue", { shortcutMenu: ["fontfamily", "fontsize", "bold", "italic", "underline", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist"]});
stop();
editor.ready(function () {
ua.contextmenu(editor.body);
setTimeout(function(){
var menu=document.getElementsByClassName("edui-shortcutmenu")[0];
equal(!!menu,true,'右键检查菜单是否存在');
setTimeout(function () {
var menu = document.getElementsByClassName("edui-shortcutmenu")[0];
equal(!!menu, true, '右键检查菜单是否存在');
ok(menu.style.display==""||menu.style.display=="block",'右键检查菜单是否显示');
ok(menu.style.display == "" || menu.style.display == "block", '右键检查菜单是否显示');
ua.mousedown(editor.body.firstChild);
equal(menu.style.display,"none",'鼠标按下检查菜单是否隐藏');
equal(menu.style.display, "none", '鼠标按下检查菜单是否隐藏');
UE.delEditor('ue');
te.dom.push(document.getElementById('ue'));
te.dom.push(document.getElementById('edui_fixedlayer'));
start()
}, 100);
});
});
test( '键盘操作,隐藏shortcutmenu', function() {
//设置菜单内容\
var div = document.body.appendChild(document.createElement('div'));
div.id = 'ue';
var editor = UE.getEditor("ue" ,{ shortcutMenu: ["fontfamily", "fontsize", "bold", "italic", "underline", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist"]});
stop();
editor.ready(function () {
ua.contextmenu(editor.body);
setTimeout(function(){
var menu=document.getElementsByClassName("edui-shortcutmenu")[0];
equal(!!menu,true,'右键检查菜单是否存在');
ok(menu.style.display==""||menu.style.display=="block",'右键检查菜单是否显示');
ua.keydown(editor.body.firstChild);
equal(menu.style.display,"none",'键盘按下检查菜单是否隐藏');
UE.delEditor('ue');
te.dom.push(document.getElementById('ue'));
te.dom.push(document.getElementById('edui_fixedlayer'));
start()
},100);
});
} );
test( '框选内容', function() {
//设置菜单内容\
var div = document.body.appendChild(document.createElement('div'));
div.id = 'ue';
var editor = UE.getEditor("ue" ,{ shortcutMenu: ["fontfamily", "fontsize", "bold", "italic", "underline", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist"]});
stop();
editor.ready(function () {
editor.setContent('<p>hello</p>');
var range = new baidu.editor.dom.Range(editor.document);
range.setStart(editor.body.firstChild.firstChild,0).setEnd(editor.body.firstChild.firstChild,2).select();
var sc =editor.selection.getRange().startContainer;
var ec =editor.selection.getRange().endContainer;
var so =editor.selection.getRange().startOffset;
var eo =editor.selection.getRange().endOffset;
var collapsed =editor.selection.getRange().collapsed;
ua.contextmenu(editor.body);
setTimeout(function(){
var menu=document.getElementsByClassName("edui-shortcutmenu")[0];
equal(!!menu,true,'右键检查菜单是否存在');
ok(menu.style.display==""||menu.style.display=="block",'右键检查菜单是否显示');
ua.checkResult(editor.selection.getRange(), sc, ec, so, eo, collapsed,'检查range不变');
ua.keydown(editor.body.firstChild);
UE.delEditor('ue');
te.dom.push(document.getElementById('ue'));
te.dom.push(document.getElementById('edui_fixedlayer'));
start()
},100);
});
} );
\ No newline at end of file
......@@ -160,7 +160,10 @@ test( 'trace 1734 range的更新/特殊符号的转换', function () {
// var label = ua.browser.gecko ? 'html' : 'body';
var label = 'html';
ua.manualDeleteFillData(editor.body);
equal( editor.selection.getRange().startContainer.parentNode.parentNode.tagName.toLowerCase(), label, 'range的更新' );
if (ua.browser.ie && ua.browser.ie > 8)//todo ie9,10改range
equal(editor.selection.getRange().startContainer.parentNode.tagName.toLowerCase(), label, 'range的更新');
else
equal(editor.selection.getRange().startContainer.parentNode.parentNode.tagName.toLowerCase(), label, 'range的更新');
editor.execCommand( 'source' );
setTimeout( function () {
editor.execCommand( 'source' );
......
......@@ -6,6 +6,82 @@
* To change this template use File | Settings | File Templates.
*/
test( '在第一个单元格里最前面回车,且表格前面没有内容', function() {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( '<p></p>' );
range.setStart( editor.body.firstChild, 0 ).collapse( true ).select();
editor.execCommand( 'inserttable', {numCols:3,numRows:3} );
var trs = editor.body.firstChild.getElementsByTagName( 'tr' );
var ut = editor.getUETable(editor.body.firstChild);
var cellsRange = ut.getCellsRange(trs[0].cells[0], trs[1].cells[0]);
ut.setSelected(cellsRange);
range.setStart(trs[0].cells[0], 0).collapse(true).select();
ua.keydown(editor.body,{'keyCode':13});
stop();
setTimeout(function(){
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,ua.browser.ie?'&nbsp;':'<br>','表格前插入空行');
equal(editor.body.firstChild.tagName.toLowerCase(),'p','表格前插入空行');
equal(editor.body.childNodes[1].tagName.toLowerCase(),'table','表格在空行后面');
start();
},50);
});
test( 'delete 事件', function() {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( '<p></p>' );
range.setStart( editor.body.firstChild, 0 ).collapse( true ).select();
editor.execCommand( 'inserttable', {numCols:3,numRows:3} );
expect(4);
editor.addListener('saveScene',function(){
ok(true);
});
var trs = editor.body.firstChild.getElementsByTagName( 'tr' );
trs[0].cells[0].innerHTML = 'hello';
trs[1].cells[0].innerHTML = 'hello';
var ut = editor.getUETable(editor.body.firstChild);
var cellsRange = ut.getCellsRange(trs[0].cells[0], trs[1].cells[0]);
ut.setSelected(cellsRange);
range.setStart(trs[0].cells[0], 0).collapse(true).select();
ua.keydown(editor.body,{'keyCode':46});
stop();
setTimeout(function(){
ua.manualDeleteFillData(editor.body);
trs = editor.body.firstChild.getElementsByTagName( 'tr' );
equal(trs[0].cells[0].innerHTML,ua.browser.ie?'':'<br>','内容');
equal(trs[1].cells[0].innerHTML,ua.browser.ie?'':'<br>','内容');
start();
},20);
});
/*trace 3047,3545*/
test('trace 3047 ,3545 全屏插入表格',function(){
if(ua.browser.gecko)return;//TODO 1.2.6
if(ua.browser.ie < 9)return;//TODO 1.2.6
var div = document.body.appendChild( document.createElement( 'div' ) );
$( div ).css( 'width', '500px' ).css( 'height', '500px' ).css( 'border', '1px solid #ccc' );
var editor = te.obj[2];
editor.render(div);
stop();
editor.ready(function(){
editor.setContent('<p></p>');
editor.ui.setFullScreen(!editor.ui.isFullScreen());
editor.execCommand('inserttable');
var width1 = editor.body.getElementsByTagName('td')[0].width;
setTimeout(function () {
editor.ui.setFullScreen(!editor.ui.isFullScreen());
setTimeout(function () {
var width2 = editor.body.getElementsByTagName('td')[0].width;
ok((width1 - width2) > 10, '页面宽度自适应');
div.parentNode.removeChild(div);
start();
}, 500);
}, 500);
});
});
test( 'backspace事件:删除caption', function() {
var editor = te.obj[0];
var range = te.obj[1];
......@@ -111,6 +187,7 @@ test( 'trace 3097 标题行中backspace键', function() {
});
test('拖拽',function(){
//todo ie9,10改range bug trace
if (browser.ie && browser.version < 8) return;
var editor = te.obj[0];
var range = te.obj[1];
......@@ -166,30 +243,6 @@ test( 'trace 3022 表格名称中backspace、ctrl+z、enter', function() {
},20);
});
/*trace 3047*/
test('trace 3047 全屏插入表格',function(){
if(ua.browser.gecko)return;//TODO 1.2.6
var div = document.body.appendChild( document.createElement( 'div' ) );
$( div ).css( 'width', '500px' ).css( 'height', '500px' ).css( 'border', '1px solid #ccc' );
var editor = te.obj[2];
editor.render(div);
stop();
editor.ready(function(){
editor.setContent('<p></p>');
editor.ui.setFullScreen(!editor.ui.isFullScreen());
editor.execCommand('inserttable');
var width1 = editor.body.getElementsByTagName('td')[0].width;
setTimeout(function () {
editor.ui.setFullScreen(!editor.ui.isFullScreen());
setTimeout(function () {
var width2 = editor.body.getElementsByTagName('td')[0].width;
ok((width1 - width2) > 10, '页面宽度自适应');
div.parentNode.removeChild(div);
start();
}, 500);
}, 200);
});
});
/*trace 3067*/
test( 'trace 3067 向右合并--tab键', function() {
......@@ -282,6 +335,7 @@ test('trace 3059 表格右浮动',function(){
});
test('trace 3378:拖拽后tab,不影响表格样式',function(){
//todo ie9,10改range bug trace
if (browser.ie && browser.version < 8) return;
var editor = te.obj[0];
var range = te.obj[1];
......@@ -430,6 +484,7 @@ test('trace 3114 在单元格内粘贴行',function(){
editor.setContent('');
editor.execCommand('inserttable');
var tds = editor.body.getElementsByTagName('td');
var ut = editor.getUETable(editor.body.firstChild);
var cellsRange = ut.getCellsRange(tds[0],tds[9]);
ut.setSelected(cellsRange);
......@@ -449,4 +504,48 @@ test('trace 3114 在单元格内粘贴行',function(){
start();
},50);
},50);
});
test('在单元格中粘贴_粘到最后',function(){
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('');
editor.execCommand('inserttable', {numCols:3,numRows:3} ); /*插入表格*/
var tds = editor.body.getElementsByTagName('td');
var ut = editor.getUETable(editor.body.firstChild);
var cellsRange = ut.getCellsRange(tds[0],tds[4]);
ut.setSelected(cellsRange); /*确定选区*/
range.setStart( tds[0], 0 ).collapse( true ).select(); /*定光标*/
ua.keydown(editor.body,{'keyCode':67,'ctrlKey':true}); /*ctrl+c*/
var html ={html:editor.body.innerHTML};
range.setStart( tds[8],0).collapse(true).select();
equal(editor.body.getElementsByTagName('tr').length,3,'触发粘贴事件前有3个tr');
equal(editor.body.getElementsByTagName('td').length,9,'触发粘贴事件前有9个td');
editor.fireEvent('beforepaste',html); /*粘贴*/
editor.fireEvent("afterpaste");
equal(editor.body.getElementsByTagName('tr').length,4,'触发粘贴事件后有4个tr');
equal(editor.body.getElementsByTagName('td').length,16,'触发粘贴事件后有12个td');
});
test('在单元格中粘贴_整列',function(){
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('');
editor.execCommand('inserttable', {numCols:3,numRows:3} ); /*插入表格*/
var tds = editor.body.getElementsByTagName('td');
range.setStart(tds[0],0).collapse(true).select();
editor.execCommand('inserttitle');
var ut = editor.getUETable(editor.body.firstChild);
var cellsRange = ut.getCellsRange(tds[0],tds[6]);
ut.setSelected(cellsRange); /*确定选区*/
range.setStart( tds[0], 0 ).collapse( true ).select(); /*定光标*/
ua.keydown(editor.body,{'keyCode':67,'ctrlKey':true}); /*ctrl+c*/
var html ={html:editor.body.innerHTML};
range.setStart( tds[6],0).collapse(true).select();
equal(editor.body.getElementsByTagName('tr').length,4,'触发粘贴事件前有4个tr');
equal(editor.body.getElementsByTagName('th').length,3,'触发粘贴事件前有3个th');
equal(editor.body.getElementsByTagName('td').length,9,'触发粘贴事件前有9个td');
editor.fireEvent('beforepaste',html); /*粘贴*/
editor.fireEvent("afterpaste");
equal(editor.body.getElementsByTagName('tr').length,4,'触发粘贴事件后有4个tr');
equal(editor.body.getElementsByTagName('th').length,4,'触发粘贴事件前有4个th');
equal(editor.body.getElementsByTagName('td').length,12,'触发粘贴事件后有12个td');
});
\ No newline at end of file
......@@ -79,6 +79,7 @@ test('向下合并-拆分成行', function () {
});
test('完全拆分单元格', function () {
//todo ie9,10改range bug trace 单元格不能框选
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('<p></p>');
......
......@@ -57,7 +57,7 @@ test("getSameEndPosCells", function () {
cells1 = ut.getSameEndPosCells(cell, "x"),
cells2 = ut.getSameEndPosCells(cell, "y");
ok(cells1.length == 1, "获取到同样X轴结尾位置的cell1个");
if(ua.browser.ie!=9)//TODO 1.2.6
if(ua.browser.ie)//TODO 1.2.6
ok(cells2.length == 2, "获取到同样Y轴结尾位置的cell2个");
});
......
......@@ -9,8 +9,8 @@
}
var div = document.body.appendChild(document.createElement('div'));
$(div).css('width', '500px').css('height', '500px').css('border', '1px solid #ccc');
var editor = new baidu.editor.Editor({'initialContent':'<p>欢迎使用ueditor</p>', 'autoFloatEnabled':false});
var ue = new UE.ui.Editor({'UEDITOR_HOME_URL':'../../../', 'autoFloatEnabled':true});
var editor = new baidu.editor.Editor({'initialContent':'<p>欢迎使用ueditor</p>', 'autoFloatEnabled':false,webAppKey:'Qr0M9yTEoLIiUSXXQTtq7yFt'});
var ue = new UE.ui.Editor({'UEDITOR_HOME_URL':'../../../', 'autoFloatEnabled':true,webAppKey:'Qr0M9yTEoLIiUSXXQTtq7yFt'});
editor.render(div);
editor.ready(function () {
var range = new baidu.editor.dom.Range(editor.document);
......
......@@ -370,7 +370,28 @@ test('undo--redo', function () {
else
equal(ua.getChildHTML(editor.body), '<p><img anchorname=\"hello\" class=\"anchorclass\">' + spase + '</p>', '');
});
test('reset,index', function () {
var editor = te.obj[0];
editor.setContent('<p></p>');
editor.focus();
editor.execCommand('anchor', 'hello');
var listLength = editor.undoManger.list.length;
ok(listLength>0,'检查undoManger.list');
equal(editor.undoManger.index,1,'检查undoManger.index');
editor.undoManger.undo();
equal(editor.undoManger.list.length,listLength,'undo操作,undoManger.list不变');
equal(editor.undoManger.index,0,'undo操作,undoManger.index-1');
var spase = ua.browser.ie ? '&nbsp;' : '<br>';
equal(ua.getChildHTML(editor.body), '<p>' + spase + '</p>', '检查内容');
editor.reset();
equal(editor.undoManger.list.length,0,'reset,undoManger.list清空');
equal(editor.undoManger.index,0,'reset,undoManger.index清空');
editor.undoManger.redo();
ua.manualDeleteFillData(editor.body);
var spase = ua.browser.ie ? '&nbsp;' : '<br>';
equal(ua.getChildHTML(editor.body), '<p>' + spase + '</p>','检查内容');
});
/*trace 1068 格式刷图片*/
test('trace 1068 默认样式的图片刷左浮动图片,撤销,左浮动图片刷默认样式的图片', function () {
var div = document.body.appendChild(document.createElement('div'));
......
......@@ -1725,6 +1725,14 @@ UserAction = {
return ele.style['cssFloat'];
},
getComputedStyle:function(ele ){
if(this.browser.ie&&ua.browser.ie<9){
return ele.currentStyle;
}else{
return window.getComputedStyle(ele);
}
},
readTxt:function (name, f) {
var args = {};
args['name'] = './txt/' + name;
......@@ -1766,7 +1774,14 @@ UserAction = {
var styleName = nodeAStyle[i].match(/\w+\s*:/)[0].replace(/\s*:/, "");
nodeA.attrs.style = nodeA.attrs.style.replace(/&quot;/g,'');
nodeB.attrs.style = nodeB.attrs.style.replace(/&quot;/g,'');
if (nodeA.getStyle(styleName).toLowerCase().replace(/\s+/g, "") != nodeB.getStyle(styleName).toLowerCase().replace(/\s+/g, ""))
var styleValueA = nodeA.getStyle(styleName).toLowerCase().replace(/\s+/g, "");
var styleValueB = nodeB.getStyle(styleName).toLowerCase().replace(/\s+/g, "");
if(/color/.test(styleName)){
styleValueA = this.formatColor(styleValueA);
styleValueB = this.formatColor(styleValueB);
}
else;
if (styleValueA != styleValueB)
return false;
}
}
......
......@@ -24,29 +24,29 @@ test( 'AutoTypeSetButton/AutoTypeSetPicker', function() {
if(inputName=="textAlign"||inputName=="imageBlockLine"){
equal(AutoPickerBodyInput[i].checked,editor.options.autotypeset[inputName]!= null,inputName+":"+editor.options.autotypeset[inputName]);
}
else if(inputName=="textAlignValue"||inputName=="imageBlockLineValue"){
equal(AutoPickerBodyInput[i].checked,editor.options.autotypeset[inputName.replace('Value','')]==AutoPickerBodyInput[i].value,inputName+":"+editor.options.autotypeset[inputName]);
else if(/textAlignValue\d/.test(inputName)||/imageBlockLineValue\d/.test(inputName)){
equal(AutoPickerBodyInput[i].checked,editor.options.autotypeset[inputName.replace(new RegExp('Value\\d',"g"),'')]==AutoPickerBodyInput[i].value,inputName+":"+editor.options.autotypeset[inputName]);
}
else{
equal(AutoPickerBodyInput[i].checked,editor.options.autotypeset[inputName],inputName+":"+editor.options.autotypeset[inputName]);
}
}
//更改两个input 的选择
//更改两个input 的选择
var flagChecked = document.getElementsByClassName("edui-autotypesetpicker-body")[0].getElementsByTagName("input")[0].checked ;
document.getElementsByClassName("edui-autotypesetpicker-body")[0].getElementsByTagName("input")[0].checked = !flagChecked;
document.getElementById("imageBlockLineValue").childNodes[2].checked = true;
//关闭对话框再重新打开,检查更改的input内容是否仍然有效
document.getElementById("imageBlockLineValue"+editor.uid).childNodes[2].checked = true;
// //关闭对话框再重新打开,检查更改的input内容是否仍然有效
autotypesetButton.popup.hide();
equal(autotypesetButton.popup._hidden,true ,'窗口关闭');
autotypesetButton.showPopup();
equal(document.getElementsByClassName("edui-autotypesetpicker-body")[0].getElementsByTagName("input")[0].checked,!flagChecked,'检查更改的input内容');
equal(document.getElementById("imageBlockLineValue").childNodes[2].checked,true,'检查更改的input内容');
equal(document.getElementById("imageBlockLineValue").childNodes[1].checked,null,'检查更改的input内容');
equal(document.getElementById("imageBlockLineValue"+editor.uid).childNodes[2].checked,true,'检查更改的input内容');
equal(document.getElementById("imageBlockLineValue"+editor.uid).childNodes[1].checked,null,'检查更改的input内容');
autotypesetButton.popup.hide();
start();
});
stop();
});
stop();
} );
\ No newline at end of file
......@@ -67,25 +67,28 @@ test( "Dialog国际化", function () {
var r = editor.selection.getRange();
var dom = $( '#'+document.getElementsByClassName("edui-for-insertimage")[0].id+'_body' )[0];
ua.click( dom );
var dialog = editor.ui._dialogs['insertimageDialog'];
ok(dialog.title===editor.getLang("labelMap.insertimage"),"dialog的标题是否一致");
ok(dialog.closeDialog === editor.getLang("closeDialog"),"关闭dialog的title是否一致");
ok(dialog.buttons[0].label === editor.getLang("ok") && dialog.buttons[1].label === editor.getLang("cancel"),"确认取消按钮是否一致");
setTimeout( function () {
var dialogDoc = document.getElementById(dialog.id + "_iframe").contentWindow.document;
var ids = editor.getLang("insertimage.static");
for(var i in ids){
if(i==="imgSearchTxt"){
equal(dialogDoc.getElementById(i).value,ids[i].value,"图片搜索文字是否一致")
}
if(i==="imgSearchBtn"){
equal(dialogDoc.getElementById(i).value,ids[i].value,"图片搜索按钮文字是否一致")
setTimeout(function(){
var dialog = editor.ui._dialogs['insertimageDialog'];
ok(dialog.title===editor.getLang("labelMap.insertimage"),"dialog的标题是否一致");
ok(dialog.closeDialog === editor.getLang("closeDialog"),"关闭dialog的title是否一致");
ok(dialog.buttons[0].label === editor.getLang("ok") && dialog.buttons[1].label === editor.getLang("cancel"),"确认取消按钮是否一致");
setTimeout( function () {
var dialogDoc = document.getElementById(dialog.id + "_iframe").contentWindow.document;
var ids = editor.getLang("insertimage.static");
for(var i in ids){
if(i==="imgSearchTxt"){
equal(dialogDoc.getElementById(i).value,ids[i].value,"图片搜索文字是否一致")
}
if(i==="imgSearchBtn"){
equal(dialogDoc.getElementById(i).value,ids[i].value,"图片搜索按钮文字是否一致")
}
}
}
ua.click(document.getElementById(dialog.closeButton.id+"_body"));
var newRange = editor.selection.getRange();
ok( r.startContainer === newRange.startContainer, "dialog开闭前后选区是否一致" );
start();
}, 1500 )
ua.click(document.getElementById(dialog.closeButton.id+"_body"));
var newRange = editor.selection.getRange();
ok( r.startContainer === newRange.startContainer, "dialog开闭前后选区是否一致" );
start();
}, 1500 )
},100);
} )
} );
\ No newline at end of file
......@@ -92,7 +92,7 @@ test( '判断render有内容时,显示render内容(script)', function() {
sc3.id="sc3";
sc3.type="text/plain";
// if(sc3.text)
sc3.text= 'renderinnerhtml';
sc3.text= 'renderinnerhtml';
// else
// sc3.textContent='renderinnerhtml';
document.body.appendChild(sc3);
......@@ -107,7 +107,7 @@ test( '判断render有内容时,显示render内容(script)', function() {
} );
test( 'render没有内容时,显示initialContent', function() {
var ue4 = new baidu.editor.ui.Editor();
var ue4 = new baidu.editor.ui.Editor({initialContent:'<br>'});
var sc4 = document.createElement("script");
sc4.id="sc4";
document.body.appendChild(sc4);
......@@ -118,7 +118,7 @@ test( 'render没有内容时,显示initialContent', function() {
sc4 = document.getElementById('sc4');
sc4.parentNode.removeChild(sc4);
start();
});
});
} );
test('判断dialogs对象名包含"Dialog"字符', function(){
......
......@@ -66,18 +66,20 @@
function init(){
var img = editor.selection.getRange().getClosedNode();
if(img && /api[.]map[.]baidu[.]com/ig.test(img.getAttribute("src"))){
var url = img.getAttribute("src"),centers;
centers = getPars(url,"center").split(",");
point = new BMap.Point(Number(centers[0]),Number(centers[1]));
var url = img.getAttribute("src"),
centerPos = getPars(url,"center").split(","),
markerPos = getPars(url, "markers").split(",");
point = new BMap.Point(Number(centerPos[0]),Number(centerPos[1]));
marker = new BMap.Marker(new BMap.Point(Number(markerPos[0]), Number(markerPos[1])));
map.addControl(new BMap.NavigationControl());
map.centerAndZoom(point, Number(getPars(url,"zoom")));
imgcss = img.style.cssText;
}else{
point = new BMap.Point(116.404, 39.915); // 创建点坐标
marker = new BMap.Marker(point);
map.addControl(new BMap.NavigationControl());
map.centerAndZoom(point, 10); // 初始化地图,设置中心点坐标和地图级别。
}
marker = new BMap.Marker(point);
marker.enableDragging();
map.addOverlay(marker);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册