Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_14980201
ueditor
提交
1507b154
U
ueditor
项目概览
qq_14980201
/
ueditor
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
ueditor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1507b154
编写于
3月 04, 2013
作者:
L
luqiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【test】整理用例plugins/image
上级
4e7b6ebb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
145 addition
and
153 deletion
+145
-153
_test/plugins/image.js
_test/plugins/image.js
+145
-153
未找到文件。
_test/plugins/image.js
浏览文件 @
1507b154
...
...
@@ -6,190 +6,182 @@ module( 'plugins.image' );
* 表格中插入图像
*/
test
(
'
插入新图像
'
,
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
:
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
width
:
50
,
height
:
51
}
);
ua
.
manualDeleteFillData
(
editor
.
body
);
var
img
=
body
.
getElementsByTagName
(
'
img
'
)[
0
];
equal
(
img
.
getAttribute
(
'
src
'
),
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
'
比较src
'
);
equal
(
img
.
getAttribute
(
'
width
'
),
'
50
'
,
'
比较width
'
);
equal
(
img
.
getAttribute
(
'
height
'
),
'
51
'
,
'
比较height
'
);
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
:
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
width
:
50
,
height
:
51
}
);
ua
.
manualDeleteFillData
(
editor
.
body
);
var
img
=
body
.
getElementsByTagName
(
'
img
'
)[
0
];
equal
(
img
.
getAttribute
(
'
src
'
),
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
'
比较src
'
);
equal
(
img
.
getAttribute
(
'
width
'
),
'
50
'
,
'
比较width
'
);
equal
(
img
.
getAttribute
(
'
height
'
),
'
51
'
,
'
比较height
'
);
}
);
/*trace 1490 不设宽高,插入图片*/
test
(
'
trace 1490 不设宽高,插入图片
'
,
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
:
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
}
);
ua
.
manualDeleteFillData
(
editor
.
body
);
var
img
=
body
.
getElementsByTagName
(
'
img
'
)[
0
];
equal
(
img
.
getAttribute
(
'
src
'
),
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
'
比较src
'
);
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
:
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
}
);
ua
.
manualDeleteFillData
(
editor
.
body
);
var
img
=
body
.
getElementsByTagName
(
'
img
'
)[
0
];
equal
(
img
.
getAttribute
(
'
src
'
),
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
'
比较src
'
);
}
);
test
(
'
插入对齐方式为居中对齐的图像,新建一个p,在p上设置居中对齐
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello</p>
'
);
range
.
setStart
(
body
.
firstChild
,
0
).
collapse
(
1
).
select
();
editor
.
execCommand
(
'
insertimage
'
,
{
src
:
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
width
:
50
,
height
:
51
,
floatStyle
:
'
center
'
}
);
ua
.
manualDeleteFillData
(
editor
.
body
);
var
img
=
body
.
getElementsByTagName
(
'
img
'
)[
0
];
equal
(
body
.
childNodes
.
length
,
2
,
'
2个p
'
);
var
p
=
body
.
firstChild
;
equal
(
p
.
style
[
'
textAlign
'
],
'
center
'
,
'
居中对齐
'
);
//1.2版本在FF中,hello前有不可见字符
ok
(
p
.
nextSibling
.
innerHTML
.
indexOf
(
'
hello
'
)
>
-
1
,
'
第二个p里面是hello
'
);
if
(
baidu
.
editor
.
browser
.
ie
)
equal
(
img
.
style
[
'
styleFloat
'
],
''
,
'
float为空
'
);
else
equal
(
img
.
style
[
'
cssFloat
'
],
''
,
'
float为空
'
);
equal
(
img
.
getAttribute
(
'
src
'
),
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
'
比较src
'
);
equal
(
img
.
getAttribute
(
'
width
'
),
'
50
'
,
'
比较width
'
);
equal
(
img
.
getAttribute
(
'
height
'
),
'
51
'
,
'
比较height
'
);
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello</p>
'
);
range
.
setStart
(
body
.
firstChild
,
0
).
collapse
(
1
).
select
();
editor
.
execCommand
(
'
insertimage
'
,
{
src
:
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
width
:
50
,
height
:
51
,
floatStyle
:
'
center
'
}
);
ua
.
manualDeleteFillData
(
editor
.
body
);
var
img
=
body
.
getElementsByTagName
(
'
img
'
)[
0
];
equal
(
body
.
childNodes
.
length
,
2
,
'
2个p
'
);
var
p
=
body
.
firstChild
;
equal
(
p
.
style
[
'
textAlign
'
],
'
center
'
,
'
居中对齐
'
);
ok
(
p
.
nextSibling
.
innerHTML
.
indexOf
(
'
hello
'
)
>
-
1
,
'
第二个p里面是hello
'
);
//1.2版本在FF中,hello前有不可见字符
if
(
baidu
.
editor
.
browser
.
ie
)
equal
(
img
.
style
[
'
styleFloat
'
],
''
,
'
float为空
'
);
else
equal
(
img
.
style
[
'
cssFloat
'
],
''
,
'
float为空
'
);
equal
(
img
.
getAttribute
(
'
src
'
),
'
http://img.baidu.com/hi/jx2/j_0001.gif
'
,
'
比较src
'
);
equal
(
img
.
getAttribute
(
'
width
'
),
'
50
'
,
'
比较width
'
);
equal
(
img
.
getAttribute
(
'
height
'
),
'
51
'
,
'
比较height
'
);
}
);
test
(
'
修改已有图片的属性
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p><img src="http://img.baidu.com/hi/jx2/j_0004.gif" >hello<img src="http://img.baidu.com/hi/jx2/j_0053.gif" ></p>
'
);
range
.
selectNode
(
body
.
firstChild
.
firstChild
).
select
();
/*加_src这个参数,否则结果不对,在image.html中也是加了这个参数的*/
editor
.
execCommand
(
'
insertimage
'
,
{
src
:
'
http://img.baidu.com/hi/jx2/j_0018.gif
'
,
_src
:
"
http://img.baidu.com/hi/jx2/j_0018.gif
"
}
);
equal
(
ua
.
getChildHTML
(
body
.
firstChild
),
'
<img src="http://img.baidu.com/hi/jx2/j_0018.gif" _src=
\
"http://img.baidu.com/hi/jx2/j_0018.gif
\
">hello<img src="http://img.baidu.com/hi/jx2/j_0053.gif" _src=
\
"http://img.baidu.com/hi/jx2/j_0053.gif
\
">
'
,
'
检查插入的图像地址
'
);
equal
(
body
.
firstChild
.
childNodes
.
length
,
3
,
'
2个img孩子
'
);
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p><img src="http://img.baidu.com/hi/jx2/j_0004.gif" >hello<img src="http://img.baidu.com/hi/jx2/j_0053.gif" ></p>
'
);
range
.
selectNode
(
body
.
firstChild
.
firstChild
).
select
();
editor
.
execCommand
(
'
insertimage
'
,
{
src
:
'
http://img.baidu.com/hi/jx2/j_0018.gif
'
}
);
equal
(
ua
.
getChildHTML
(
body
.
firstChild
),
'
<img src="http://img.baidu.com/hi/jx2/j_0018.gif">hello<img src="http://img.baidu.com/hi/jx2/j_0053.gif">
'
,
'
检查插入的图像地址
'
);
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
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello1</p><p>hello2<img src="http://img.baidu.com/hi/jx2/j_0004.gif"></p>
'
);
setTimeout
(
function
(){
range
.
setStart
(
body
.
firstChild
.
firstChild
,
2
).
setEnd
(
body
.
lastChild
,
2
).
select
();
editor
.
execCommand
(
'
insertimage
'
,
{
src
:
'
http://img.baidu.com/hi/jx2/j_0016.gif
'
,
width
:
'
100
'
,
height
:
'
100
'
}
);
ua
.
manualDeleteFillData
(
editor
.
body
);
equal
(
body
.
childNodes
.
length
,
1
,
'
只有一个p
'
);
ua
.
clearWhiteNode
(
body
.
firstChild
);
var
img
=
body
.
firstChild
.
lastChild
;
equal
(
img
.
getAttribute
(
'
src
'
),
'
http://img.baidu.com/hi/jx2/j_0016.gif
'
,
'
比较src
'
);
equal
(
img
.
getAttribute
(
'
width
'
),
'
100
'
,
'
比较width
'
);
equal
(
img
.
getAttribute
(
'
height
'
),
'
100
'
,
'
比较height
'
);
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
();
},
50
);
};
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
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello1</p><p>hello2<img src="http://img.baidu.com/hi/jx2/j_0004.gif"></p>
'
);
setTimeout
(
function
(){
range
.
setStart
(
body
.
firstChild
.
firstChild
,
2
).
setEnd
(
body
.
lastChild
,
2
).
select
();
editor
.
execCommand
(
'
insertimage
'
,
{
src
:
'
http://img.baidu.com/hi/jx2/j_0016.gif
'
,
width
:
'
100
'
,
height
:
'
100
'
}
);
ua
.
manualDeleteFillData
(
editor
.
body
);
equal
(
body
.
childNodes
.
length
,
1
,
'
只有一个p
'
);
ua
.
clearWhiteNode
(
body
.
firstChild
);
var
img
=
body
.
firstChild
.
lastChild
;
equal
(
img
.
getAttribute
(
'
src
'
),
'
http://img.baidu.com/hi/jx2/j_0016.gif
'
,
'
比较src
'
);
equal
(
img
.
getAttribute
(
'
width
'
),
'
100
'
,
'
比较width
'
);
equal
(
img
.
getAttribute
(
'
height
'
),
'
100
'
,
'
比较height
'
);
start
();
},
50
);
stop
();
}
);
test
(
'
图像设置左右浮动
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello1</p><p>hello2<img src="http://img.baidu.com/hi/jx2/j_0004.gif"></p>
'
);
range
.
selectNode
(
body
.
lastChild
.
lastChild
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
left
'
);
equal
(
body
.
getElementsByTagName
(
'
img
'
)[
0
].
style
[
'
cssFloat
'
]
||
body
.
getElementsByTagName
(
'
img
'
)[
0
].
style
[
'
styleFloat
'
],
'
left
'
,
'
左浮动
'
);
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello1</p><p>hello2<img src="http://img.baidu.com/hi/jx2/j_0004.gif"></p>
'
);
range
.
selectNode
(
body
.
lastChild
.
lastChild
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
left
'
);
equal
(
body
.
getElementsByTagName
(
'
img
'
)[
0
].
style
[
'
cssFloat
'
]
||
body
.
getElementsByTagName
(
'
img
'
)[
0
].
style
[
'
styleFloat
'
],
'
left
'
,
'
左浮动
'
);
// equal( body.getElementsByTagName( 'img' )[0].style['float'], 'left', '左浮动' );
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
left
'
);
editor
.
execCommand
(
'
imagefloat
'
,
'
right
'
);
equal
(
body
.
getElementsByTagName
(
'
img
'
)[
0
].
style
[
'
cssFloat
'
]
||
body
.
getElementsByTagName
(
'
img
'
)[
0
].
style
[
'
styleFloat
'
],
'
right
'
,
'
右浮动
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
right
'
);
equal
(
editor
.
queryCommandState
(
'
imagefloat
'
),
0
,
'
图片被选中,因此图片菜单高亮
'
);
range
.
setStart
(
body
.
firstChild
,
0
).
collapse
(
1
).
select
();
equal
(
editor
.
queryCommandState
(
'
imagefloat
'
),
-
1
,
'
光标闭合,因此图片菜单高不高亮
'
);
equal
(
editor
.
queryCommandValue
(
'
justify
'
),
'
left
'
,
'
段落的对齐方式为左对齐
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
none
'
,
'
图片对齐方式在闭合情况获取为空
'
)
range
.
selectNode
(
body
.
firstChild
.
firstChild
).
select
();
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
none
'
,
'
选中文本,因此图片菜单高不高亮
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
left
'
);
editor
.
execCommand
(
'
imagefloat
'
,
'
right
'
);
equal
(
body
.
getElementsByTagName
(
'
img
'
)[
0
].
style
[
'
cssFloat
'
]
||
body
.
getElementsByTagName
(
'
img
'
)[
0
].
style
[
'
styleFloat
'
],
'
right
'
,
'
右浮动
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
right
'
);
equal
(
editor
.
queryCommandState
(
'
imagefloat
'
),
0
,
'
图片被选中,因此图片菜单高亮
'
);
range
.
setStart
(
body
.
firstChild
,
0
).
collapse
(
1
).
select
();
equal
(
editor
.
queryCommandState
(
'
imagefloat
'
),
-
1
,
'
光标闭合,因此图片菜单高不高亮
'
);
equal
(
editor
.
queryCommandValue
(
'
justify
'
),
'
left
'
,
'
段落的对齐方式为左对齐
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
none
'
,
'
图片对齐方式在闭合情况获取为空
'
)
range
.
selectNode
(
body
.
firstChild
.
firstChild
).
select
();
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
none
'
,
'
选中文本,因此图片菜单高不高亮
'
);
}
);
test
(
'
左浮动变为默认的样式和居中
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello1</p><p>hello2<img src="http://img.baidu.com/hi/jx2/j_0004.gif" style="float:left"></p>
'
);
range
.
selectNode
(
body
.
lastChild
.
lastChild
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
none
'
);
equal
(
ua
.
getFloatStyle
(
body
.
getElementsByTagName
(
'
img
'
)[
0
]
),
'
none
'
,
'
没有浮动方式
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
none
'
);
$
(
body
.
getElementsByTagName
(
'
img
'
)[
0
]
).
css
(
'
float
'
);
range
.
selectNode
(
body
.
getElementsByTagName
(
'
img
'
)[
0
]
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
center
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
center
'
);
equal
(
body
.
childNodes
.
length
,
3
,
'
3个p,image被切出一个p出来了
'
);
var
p
=
body
.
childNodes
[
2
];
equal
(
p
.
tagName
.
toLowerCase
(),
'
p
'
,
'
第2个是p
'
);
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello1</p><p>hello2<img src="http://img.baidu.com/hi/jx2/j_0004.gif" style="float:left"></p>
'
);
range
.
selectNode
(
body
.
lastChild
.
lastChild
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
none
'
);
equal
(
ua
.
getFloatStyle
(
body
.
getElementsByTagName
(
'
img
'
)[
0
]
),
''
,
'
没有浮动方式
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
none
'
);
$
(
body
.
getElementsByTagName
(
'
img
'
)[
0
]
).
css
(
'
float
'
);
range
.
selectNode
(
body
.
getElementsByTagName
(
'
img
'
)[
0
]
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
center
'
);
equal
(
editor
.
queryCommandValue
(
'
imagefloat
'
),
'
center
'
);
equal
(
body
.
childNodes
.
length
,
3
,
'
3个p,image被切出一个p出来了
'
);
var
p
=
body
.
childNodes
[
2
];
equal
(
p
.
tagName
.
toLowerCase
(),
'
p
'
,
'
第2个是p
'
);
equal
(
p
.
firstChild
.
tagName
.
toLowerCase
(),
'
img
'
,
'
p的孩子为image
'
);
equal
(
ua
.
getFloatStyle
(
p
.
firstChild
),
''
,
'
image对齐方式float为空
'
);
equal
(
editor
.
queryCommandValue
(
'
justify
'
),
'
center
'
,
'
段落的对齐方式为居中
'
);
}
);
test
(
'
带有超链接的图片
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello1</p><p>hello2<a href="www.baidu.com"><img src="http://img.baidu.com/hi/jx2/j_0004.gif" style="float:left"></a></p>
'
);
range
.
selectNode
(
body
.
lastChild
.
lastChild
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
center
'
);
var
p
=
body
.
childNodes
[
2
];
equal
(
p
.
firstChild
.
tagName
.
toLowerCase
(),
'
a
'
,
'
p的孩子为a
'
);
equal
(
ua
.
getFloatStyle
(
p
.
firstChild
),
''
,
'
image对齐方式float为空
'
);
equal
(
editor
.
queryCommandValue
(
'
justify
'
),
'
center
'
,
'
段落的对齐方式为居中
'
);
editor
.
execCommand
(
'
imagefloat
'
,
'
left
'
);
equal
(
p
.
firstChild
.
tagName
.
toLowerCase
(),
'
a
'
,
'
p的孩子为a
'
);
equal
(
ua
.
getFloatStyle
(
p
.
firstChild
.
firstChild
),
'
left
'
,
'
image对齐方式float为left
'
);
editor
.
execCommand
(
'
imagefloat
'
,
'
none
'
);
equal
(
p
.
firstChild
.
tagName
.
toLowerCase
(),
'
a
'
,
'
p的孩子为a
'
);
equal
(
ua
.
getFloatStyle
(
p
.
firstChild
.
firstChild
),
'
none
'
,
'
image对齐方式float为空
'
);
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello1</p><p>hello2<a href="www.baidu.com"><img src="http://img.baidu.com/hi/jx2/j_0004.gif" style="float:left"></a></p>
'
);
range
.
selectNode
(
body
.
lastChild
.
lastChild
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
center
'
);
var
p
=
body
.
childNodes
[
2
];
equal
(
p
.
firstChild
.
tagName
.
toLowerCase
(),
'
a
'
,
'
p的孩子为a
'
);
equal
(
ua
.
getFloatStyle
(
p
.
firstChild
),
''
,
'
image对齐方式float为空
'
);
equal
(
editor
.
queryCommandValue
(
'
justify
'
),
'
center
'
,
'
段落的对齐方式为居中
'
);
editor
.
execCommand
(
'
imagefloat
'
,
'
left
'
);
equal
(
p
.
firstChild
.
tagName
.
toLowerCase
(),
'
a
'
,
'
p的孩子为a
'
);
equal
(
ua
.
getFloatStyle
(
p
.
firstChild
.
firstChild
),
'
left
'
,
'
image对齐方式float为left
'
);
editor
.
execCommand
(
'
imagefloat
'
,
'
none
'
);
equal
(
p
.
firstChild
.
tagName
.
toLowerCase
(),
'
a
'
,
'
p的孩子为a
'
);
equal
(
ua
.
getFloatStyle
(
p
.
firstChild
.
firstChild
),
'
'
,
'
image对齐方式float为空
'
);
}
);
test
(
'
默认样式切换到居中再切换回默认,会把居中导致的3个p合并
'
,
function
()
{
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello2<a href="www.baidu.com"><img src="http://img.baidu.com/hi/jx2/j_0004.gif" style="float:left"></a>hello3</p>
'
);
var
editor
=
te
.
obj
[
0
];
var
range
=
te
.
obj
[
1
];
var
body
=
editor
.
body
;
editor
.
setContent
(
'
<p>hello2<a href="www.baidu.com"><img src="http://img.baidu.com/hi/jx2/j_0004.gif" style="float:left"></a>hello3</p>
'
);
setTimeout
(
function
()
{
range
.
selectNode
(
body
.
getElementsByTagName
(
'
a
'
)[
0
]
).
select
();
editor
.
execCommand
(
'
imagefloat
'
,
'
center
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录