提交 6c943723 编写于 作者: C campaign

Merge remote-tracking branch 'origin/dev-1.2.5' into dev-1.2.5

......@@ -64,11 +64,11 @@ var utils = UE.utils = {
}
return t;
},
extend2 : function(t){
extend2:function (t) {
var a = arguments;
for ( var i=1; i<a.length; i++ ) {
for (var i = 1; i < a.length; i++) {
var x = a[i];
for ( var k in x ) {
for (var k in x) {
if (!t.hasOwnProperty(k)) {
t[k] = x[k];
}
......@@ -152,8 +152,8 @@ var utils = UE.utils = {
indexOf:function (array, item, start) {
var index = -1;
start = this.isNumber(start) ? start : 0;
this.each(array,function(v,i){
if(i >= start && v === item){
this.each(array, function (v, i) {
if (i >= start && v === item) {
index = i;
return false;
}
......@@ -209,10 +209,10 @@ var utils = UE.utils = {
* UE.utils.unhtml(html,/[<>]/g) ==> &lt;body&gt;You say:"你好!Baidu & UEditor!"&lt;/body&gt;
*/
unhtml:function (str, reg) {
return str ? str.replace(reg || /[&<">](?:(amp|lt|quot|gt);)?/g, function (a,b) {
if(b){
return str ? str.replace(reg || /[&<">](?:(amp|lt|quot|gt);)?/g, function (a, b) {
if (b) {
return a;
}else{
} else {
return {
'<':'&lt;',
'&':'&amp;',
......@@ -273,40 +273,42 @@ var utils = UE.utils = {
*/
loadFile:function () {
var tmpList = [];
function getItem(doc,obj){
try{
for(var i= 0,ci;ci=tmpList[i++];){
if(ci.doc === doc && ci.url == (obj.src || obj.href)){
function getItem(doc, obj) {
try {
for (var i = 0, ci; ci = tmpList[i++];) {
if (ci.doc === doc && ci.url == (obj.src || obj.href)) {
return ci;
}
}
}catch(e){
} catch (e) {
return null;
}
}
return function (doc, obj, fn) {
var item = getItem(doc,obj);
var item = getItem(doc, obj);
if (item) {
if(item.ready){
if (item.ready) {
fn && fn();
}else{
} else {
item.funs.push(fn)
}
return;
}
tmpList.push({
doc:doc,
url:obj.src||obj.href,
url:obj.src || obj.href,
funs:[fn]
});
if (!doc.body) {
var html = [];
for(var p in obj){
if(p == 'tag')continue;
for (var p in obj) {
if (p == 'tag')continue;
html.push(p + '="' + obj[p] + '"')
}
doc.write('<' + obj.tag + ' ' + html.join(' ') + ' ></'+obj.tag+'>');
doc.write('<' + obj.tag + ' ' + html.join(' ') + ' ></' + obj.tag + '>');
return;
}
if (obj.id && doc.getElementById(obj.id)) {
......@@ -319,7 +321,7 @@ var utils = UE.utils = {
}
element.onload = element.onreadystatechange = function () {
if (!this.readyState || /loaded|complete/.test(this.readyState)) {
item = getItem(doc,obj);
item = getItem(doc, obj);
if (item.funs.length > 0) {
item.ready = 1;
for (var fi; fi = item.funs.pop();) {
......@@ -329,8 +331,8 @@ var utils = UE.utils = {
element.onload = element.onreadystatechange = null;
}
};
element.onerror = function(){
throw Error('The load '+(obj.href||obj.src)+' fails,check the url settings of file editor_config.js ')
element.onerror = function () {
throw Error('The load ' + (obj.href || obj.src) + ' fails,check the url settings of file editor_config.js ')
};
doc.getElementsByTagName("head")[0].appendChild(element);
}
......@@ -450,23 +452,23 @@ var utils = UE.utils = {
* @grammar UE.utils.transUnitToPx('20pt') => '27px'
* @grammar UE.utils.transUnitToPx('0pt') => '0'
*/
transUnitToPx : function(val){
if(!/(pt|cm)/.test(val)){
transUnitToPx:function (val) {
if (!/(pt|cm)/.test(val)) {
return val
}
var unit;
val.replace(/([\d.]+)(\w+)/,function(str,v,u){
val.replace(/([\d.]+)(\w+)/, function (str, v, u) {
val = v;
unit = u;
});
switch(unit){
switch (unit) {
case 'cm':
val = parseFloat(val) * 25;
break;
case 'pt':
val = Math.round(parseFloat(val) * 96 / 72);
}
return val + (val?'px':'');
return val + (val ? 'px' : '');
},
/**
* DomReady方法,回调函数将在dom树ready完成后执行
......@@ -480,16 +482,17 @@ var utils = UE.utils = {
function doReady(doc) {
//确保onready只执行一次
doc.isReady = true;
for (var ci; ci = fnArr.pop();ci()){}
for (var ci; ci = fnArr.pop(); ci()) {
}
}
return function (onready,win) {
return function (onready, win) {
win = win || window;
var doc = win.document;
onready && fnArr.push(onready);
if (doc.readyState === "complete") {
doReady(doc);
}else{
} else {
doc.isReady && doReady(doc);
if (browser.ie) {
(function () {
......@@ -502,7 +505,7 @@ var utils = UE.utils = {
}
doReady(doc);
})();
win.attachEvent('onload', function(){
win.attachEvent('onload', function () {
doReady(doc)
});
} else {
......@@ -510,7 +513,9 @@ var utils = UE.utils = {
doc.removeEventListener("DOMContentLoaded", arguments.callee, false);
doReady(doc);
}, false);
win.addEventListener('load', function(){doReady(doc)}, false);
win.addEventListener('load', function () {
doReady(doc)
}, false);
}
}
......@@ -524,48 +529,61 @@ var utils = UE.utils = {
* @grammar UE.utils.cssRule('body') =>样式的字符串 //取得key值为body的样式的内容,如果没有找到key值先关的样式将返回空,例如刚才那个背景颜色,将返回 body{background:#ccc}
* @grammar UE.utils.cssRule('body','') =>null //清空给定的key值的背景颜色
*/
cssRule : browser.ie ? function(key,style,doc){
var indexList,index;
doc = doc || document;
if(doc.indexList){
indexList = doc.indexList;
}else{
indexList = doc.indexList = {};
}
var sheetStyle;
if(!indexList[key]){
if(style === undefined){
return ''
}
sheetStyle = doc.createStyleSheet('',index = doc.styleSheets.length);
indexList[key] = index;
}else{
sheetStyle = doc.styleSheets[indexList[key]];
cssRule:browser.ie ? function (key, style, doc) {
var indexList, index;
doc = doc || document;
if (doc.indexList) {
indexList = doc.indexList;
} else {
indexList = doc.indexList = {};
}
var sheetStyle;
if (!indexList[key]) {
if (style === undefined) {
return ''
}
if(style === undefined){
return sheetStyle.cssText
sheetStyle = doc.createStyleSheet('', index = doc.styleSheets.length);
indexList[key] = index;
} else {
sheetStyle = doc.styleSheets[indexList[key]];
}
if (style === undefined) {
return sheetStyle.cssText
}
sheetStyle.cssText = style || ''
} : function (key, style, doc) {
doc = doc || document;
var head = doc.getElementsByTagName('head')[0], node;
if (!(node = doc.getElementById(key))) {
if (style === undefined) {
return ''
}
sheetStyle.cssText = style || ''
}:function(key,style,doc){
doc = doc || document;
var head = doc.getElementsByTagName('head')[0],node;
if(!(node = doc.getElementById(key))){
if(style === undefined){
return ''
node = doc.createElement('style');
node.id = key;
head.appendChild(node)
}
if (style === undefined) {
return node.innerHTML
}
if (style !== '') {
node.innerHTML = style;
} else {
head.removeChild(node)
}
},
sort:function(array,compareFn){
compareFn = compareFn || function(item1, item2){ return item1.localeCompare(item2);};
for(var i= 0,len = array.length; i<len; i++){
for(var j = i,length = array.length; j<length; j++){
if(compareFn(array[i], array[j]) > 0){
var t = array[i];
array[i] = array[j];
array[j] = t;
}
node = doc.createElement('style');
node.id = key;
head.appendChild(node)
}
if(style === undefined){
return node.innerHTML
}
if(style !== ''){
node.innerHTML = style;
}else{
head.removeChild(node)
}
}
return array;
}
};
/**
......@@ -588,8 +606,8 @@ var utils = UE.utils = {
* @name isNumber
* @grammar UE.utils.isNumber(obj) => true|false
*/
utils.each(['String','Function','Array','Number','RegExp','Object'],function(v){
UE.utils['is' + v] = function(obj){
utils.each(['String', 'Function', 'Array', 'Number', 'RegExp', 'Object'], function (v) {
UE.utils['is' + v] = function (obj) {
return Object.prototype.toString.apply(obj) == '[object ' + v + ']';
}
});
\ No newline at end of file
......@@ -70,41 +70,6 @@ UE.plugins['contextmenu'] = function () {
label:lang.inserttable,
cmdName:'inserttable'
},
{
label:"清除表格背景",
cmdName:"cleartablebackground",
exec:function(){
this.execCommand("cleartablebackground");
}
},
{
label:"整个表格隔行变色",
cmdName:"settablebackground",
exec:function(){
this.execCommand("settablebackground",{repeat:true,colorList:["#bbb","#ccc"]},true);
}
},
{
label:"三色渐变",
cmdName:"settablebackground",
exec:function(){
this.execCommand("settablebackground",{repeat:true,colorList:["#aaa","#bbb","#ccc"]});
}
},
{
label:"隔行变色",
cmdName:"settablebackground",
exec:function(){
this.execCommand("settablebackground",{repeat:true,colorList:["#bbb","#ccc"]});
}
},
{
label:"红蓝相间",
cmdName:"settablebackground",
exec:function(){
this.execCommand("settablebackground",{repeat:true,colorList:["red","blue"]});
}
},
{
label:lang.deletetable,
cmdName:'deletetable'
......@@ -238,8 +203,10 @@ UE.plugins['contextmenu'] = function () {
cmdName:'sorttable',
exec:function(){
this.execCommand("sorttable",function(td1,td2){
var value1 = parseInt(td1.innerHTML,10),
value2 = parseInt(td2.innerHTML,10);
var value1 = td1.innerHTML.match(/\d+/),
value2 = td2.innerHTML.match(/\d+/);
if(value1) value1 = +value1[0];
if(value2) value2 = +value2[0];
return (value1||0) - (value2||0);
});
}
......@@ -249,14 +216,64 @@ UE.plugins['contextmenu'] = function () {
cmdName:'sorttable',
exec:function(){
this.execCommand("sorttable",function(td1,td2){
var value1 = parseInt(td1.innerHTML,10),
value2 = parseInt(td2.innerHTML,10);
var value1 = td1.innerHTML.match(/\d+/),
value2 = td2.innerHTML.match(/\d+/);
if(value1) value1 = +value1[0];
if(value2) value2 = +value2[0];
return (value2||0) - (value1||0);
});
}
}
]
},
{
group:"边框底纹",
icon:'borderBack',
subMenu:[
{
label:"表格隔行变色",
cmdName:"interlacetable",
exec:function(){
this.execCommand("interlacetable");
}
},
{
label:"取消表格隔行变色",
cmdName:"uninterlacetable",
exec:function(){
this.execCommand("uninterlacetable");
}
},
{
label:"选区背景隔行",
cmdName:"settablebackground",
exec:function(){
this.execCommand("settablebackground",{repeat:true,colorList:["#bbb","#ccc"]});
}
},
{
label:"取消选区背景",
cmdName:"cleartablebackground",
exec:function(){
this.execCommand("cleartablebackground");
}
},
{
label:"红蓝相间",
cmdName:"settablebackground",
exec:function(){
this.execCommand("settablebackground",{repeat:true,colorList:["red","blue"]});
}
},
{
label:"三色渐变",
cmdName:"settablebackground",
exec:function(){
this.execCommand("settablebackground",{repeat:true,colorList:["#aaa","#bbb","#ccc"]});
}
}
]
},
{
group:lang.aligntd,
icon:'aligntd',
......@@ -415,6 +432,8 @@ UE.plugins['contextmenu'] = function () {
return me.getLang("contextMenu.aligntable");
case "tablesort":
return "表格排序";
case "borderBack":
return "边框底纹";
default :
return '';
}
......
......@@ -48,7 +48,7 @@ UE.plugins['table'] = function () {
'tdvalign':'top',
'cursorpath':me.options.UEDITOR_HOME_URL + "themes/default/images/cursor_",
'tableDragable':false,
'classList':[".back1",".back2"]
'classList':["back1","back2"]
});
me.getUETable = getUETable;
var commands = {
......@@ -75,6 +75,7 @@ UE.plugins['table'] = function () {
"adaptbywindow":1,
"adaptbycustomer":1,
"insertparagraph":1,
"insertparagraphbeforetable":1,
"averagedistributecol":1,
"averagedistributerow":1
};
......@@ -172,12 +173,11 @@ UE.plugins['table'] = function () {
if ((evt.ctrlKey || evt.metaKey) && evt.keyCode == '67') {
tableCopyList = null;
table = getUETableBySelected(me);
if (table) {
var tds = table.selectedTds,
ut = getUETable(table);
isFullCol = table.isFullCol();
isFullRow = table.isFullRow();
var ut = getUETableBySelected(me);
if (ut) {
var tds = ut.selectedTds;
isFullCol = ut.isFullCol();
isFullRow = ut.isFullRow();
tableCopyList = [
[ut.cloneCell(tds[0])]
];
......@@ -192,6 +192,10 @@ UE.plugins['table'] = function () {
}
}
});
me.addListener("tablehasdeleted",function(){
toggleDraggableState(this, false, "", null);
if (dragButton)domUtils.remove(dragButton);
});
me.addListener('beforepaste', function (cmd, html) {
var me = this;
......@@ -290,7 +294,7 @@ UE.plugins['table'] = function () {
for (var i = 0, ci; ci = tableCopyList[i++];) {
var tr = table.insertRow(table.rows.length);
for (var j = 0, cj; cj = ci[j++];) {
cloneTd = ut.cloneCell(cj);
cloneTd = UT.cloneCell(cj);
domUtils.removeAttributes(cloneTd, ['class']);
tr.appendChild(cloneTd)
}
......@@ -514,11 +518,28 @@ UE.plugins['table'] = function () {
toggleDraggableState(me, false, "", null);
}
});
me.addListener("interlacetable",function(type,table){
var rows = table.rows,
len;
me.addListener("interlacetable",function(type,table,classList){
if(!table) return;
var me = this,
rows = table.rows,
len = rows.length,
getClass = function(list,index,repeat){
return list[index] ? list[index] : repeat ? list[index % list.length]: "";
};
for(var i = 0;i<len;i++){
rows[i].className = getClass( classList|| me.options.classList,i,true);
}
});
me.addListener("uninterlacetable",function(type,table){
if(!table) return;
var me = this,
rows = table.rows,
len = rows.length;
for(var i = 0;i<len;i++){
rows[i].className = "";
}
});
me.addListener("mousedown", mouseDownEvent);
......
......@@ -103,8 +103,8 @@
rng.setStart(next, 0)
}
rng.setCursor(false, true)
toggleDragableState(this, false, "", null);
if (dragButton)domUtils.remove(dragButton);
this.fireEvent("tablehasdeleted")
}
}
......@@ -289,8 +289,10 @@
execCommand:function () {
var rng = this.selection.getRange(),
bk = rng.createBookmark(true);
var cell = getTableItemsByRange(this).cell,
ut = getUETable(cell),
var tableItems = getTableItemsByRange(this),
cell = tableItems.cell,
table = tableItems.table,
ut = getUETable(table),
cellInfo = ut.getCellInfo(cell);
//ut.insertRow(!ut.selectedTds.length ? cellInfo.rowIndex:ut.cellsRange.beginRowIndex,'');
if (!ut.selectedTds.length) {
......@@ -302,6 +304,7 @@
}
}
rng.moveToBookmark(bk).select();
if(table.getAttribute("interlaced")==="enabled")this.fireEvent("interlacetable",table);
}
};
//后插入行
......@@ -314,8 +317,10 @@
execCommand:function () {
var rng = this.selection.getRange(),
bk = rng.createBookmark(true);
var cell = getTableItemsByRange(this).cell,
ut = getUETable(cell),
var tableItems = getTableItemsByRange(this),
cell = tableItems.cell,
table = tableItems.table,
ut = getUETable(table),
cellInfo = ut.getCellInfo(cell);
//ut.insertRow(!ut.selectedTds.length? cellInfo.rowIndex + cellInfo.rowSpan : ut.cellsRange.endRowIndex + 1,'');
if (!ut.selectedTds.length) {
......@@ -327,6 +332,7 @@
}
}
rng.moveToBookmark(bk).select();
if(table.getAttribute("interlaced")==="enabled")this.fireEvent("interlacetable",table);
}
};
UE.commands["deleterow"] = {
......@@ -366,6 +372,7 @@
if (newCell) rng.selectNodeContents(newCell).setCursor(false, true);
}
}
if(table.getAttribute("interlaced")==="enabled")this.fireEvent("interlacetable",table);
}
};
UE.commands["insertcol"] = {
......@@ -764,13 +771,8 @@
tableItems = getTableItemsByRange(me),
cell = tableItems.cell,
ut = getUETable(tableItems.table),
cellIndex = ut.getCellInfo(cell).cellIndex,
cells = ut.getSameEndPosCells(cell, "x");
if (cells.length < ut.rowsNum) {
this.fireEvent("tableForbidSort");
return;
}
ut.sortTable(cellIndex, fn);
cellInfo = ut.getCellInfo(cell);
ut.sortTable(cellInfo.cellIndex, fn);
range.moveToBookmark(bk).select();
}
};
......@@ -786,22 +788,25 @@
};
UE.commands["settablebackground"] = {
queryCommandState:function () {
return getTableItemsByRange(this).table ? 0 : -1;
return getSelectedArr(this).length>1?0:-1;
},
execCommand:function (cmd, value, allCells) {
execCommand:function (cmd, value) {
var table, cells, ut;
if (allCells) {
table = getTableItemsByRange(this).table;
cells = table.getElementsByTagName("td");
} else {
cells = getSelectedArr(this);
}
cells = getSelectedArr(this);
ut = getUETable(cells[0]);
ut.setBackground(cells, value);
}
};
UE.commands["cleartablebackground"] = {
queryCommandState:function(){
var cells = getSelectedArr(this);
if(!cells.length)return -1;
for(var i= 0,cell;cell = cells[i++];){
if(cell.style.backgroundColor!=="") return 0;
}
return -1;
},
execCommand:function () {
var cells = getSelectedArr(this),
ut = getUETable(cells[0]);
......@@ -809,11 +814,26 @@
}
};
UE.commands["interlacedtable"] = UE.commands["uninterlacedtable"] = {
execCommand:function (cmd) {
UE.commands["interlacetable"] = UE.commands["uninterlacetable"] = {
queryCommandState:function(cmd){
var table = getTableItemsByRange(this).table;
table.setAttribute("interlaced", cmd == "interlacedtable" ? "enabled" : "disabled");
this.fireEvent("interlacetable",table);
if(!table) return -1;
var interlaced = table.getAttribute("interlaced");
if(cmd =="interlacetable"){
return /*(interlaced === "enabled") ? -1:*/0;
}else{
return (!interlaced||interlaced === "disabled") ? -1:0;
}
},
execCommand:function (cmd,classList) {
var table = getTableItemsByRange(this).table;
if( cmd == "interlacetable" ){
table.setAttribute("interlaced","enabled");
this.fireEvent("interlacetable",table,classList);
}else{
table.setAttribute("interlaced","disabled");
this.fireEvent("uninterlacetable",table);
}
}
};
......
......@@ -126,6 +126,26 @@
return tdOrTable.ueTable;
};
UETable.cloneCell = function(cell,ignoreMerge){
if (!cell || utils.isString(cell)) {
return this.table.ownerDocument.createElement(cell || 'td');
}
var flag = domUtils.hasClass(cell, "selectTdClass");
flag && domUtils.removeClasses(cell, "selectTdClass");
var tmpCell = cell.cloneNode(true);
if (ignoreMerge) {
tmpCell.rowSpan = tmpCell.colSpan = 1;
}
tmpCell.style.borderLeftStyle = "";
tmpCell.style.borderTopStyle = "";
tmpCell.style.borderLeftColor = cell.style.borderRightColor;
tmpCell.style.borderLeftWidth = cell.style.borderRightWidth;
tmpCell.style.borderTopColor = cell.style.borderBottomColor;
tmpCell.style.borderTopWidth = cell.style.borderBottomWidth;
flag && domUtils.addClass(cell, "selectTdClass");
return tmpCell;
}
UETable.prototype = {
getMaxRows:function () {
var rows = this.table.rows, maxLen = 1;
......@@ -261,25 +281,7 @@
setCellContent:function (cell, content) {
cell.innerHTML = content || (browser.ie ? domUtils.fillChar : "<br />");
},
cloneCell:function (cell, ignoreMerge) {
if (!cell || utils.isString(cell)) {
return this.table.ownerDocument.createElement(cell || 'td');
}
var flag = domUtils.hasClass(cell, "selectTdClass");
flag && domUtils.removeClasses(cell, "selectTdClass");
var tmpCell = cell.cloneNode(true);
if (ignoreMerge) {
tmpCell.rowSpan = tmpCell.colSpan = 1;
}
tmpCell.style.borderLeftStyle = "";
tmpCell.style.borderTopStyle = "";
tmpCell.style.borderLeftColor = cell.style.borderRightColor;
tmpCell.style.borderLeftWidth = cell.style.borderRightWidth;
tmpCell.style.borderTopColor = cell.style.borderBottomColor;
tmpCell.style.borderTopWidth = cell.style.borderBottomWidth;
flag && domUtils.addClass(cell, "selectTdClass");
return tmpCell;
},
cloneCell:UETable.cloneCell,
/**
* 获取跟当前单元格的右边竖线为左边的所有未合并单元格
*/
......@@ -505,8 +507,6 @@
endColIndex = Math.max(cellAInfo.colIndex + cellAInfo.colSpan - 1, cellBInfo.colIndex + cellBInfo.colSpan - 1);
return checkRange(beginRowIndex, beginColIndex, endRowIndex, endColIndex);
} catch (e) {
if (debug) throw e;
}
......@@ -811,6 +811,13 @@
tableRow.insertBefore(th, cell);
domUtils.remove(cell)
}
}else{
if (cell.tagName == 'TH') {
var td = cell.ownerDocument.createElement("td");
td.appendChild(cell.firstChild);
tableRow.insertBefore(td, cell);
domUtils.remove(cell)
}
}
}
......@@ -1012,20 +1019,34 @@
range = this.getCellsRange(tds[0], tds[tds.length - 1]);
this.setSelected(range);
},
sortTable:function(sortByCellIndex,compareFn){
sortTable:function (sortByCellIndex, compareFn) {
var table = this.table,
rows = table.rows,
trArray = [],
flag = rows[0].cells[0].tagName === "TH";
for (var i = 0, len = rows.length; i < len; i++) {
trArray[i] = rows[i];
flag = rows[0].cells[0].tagName === "TH",
lastRowIndex = 0;
if(this.selectedTds.length){
var range = this.cellsRange,
len = range.endRowIndex + 1;
for (var i = range.beginRowIndex; i < len; i++) {
trArray[i] = rows[i];
}
trArray.splice(0,range.beginRowIndex);
lastRowIndex = (range.endRowIndex +1) === this.rowsNum ? 0 : range.endRowIndex +1;
}else{
for (var i = 0,len = rows.length; i < len; i++) {
trArray[i] = rows[i];
}
}
//th不参与排序
flag && trArray.splice(0,1);
trArray.sort(function (tr1, tr2) {
return compareFn ? (typeof compareFn === "number" ? compareFn : compareFn.call(this,tr1.cells[sortByCellIndex], tr2.cells[sortByCellIndex])) : function () {
var value1 = tr1.cells[sortByCellIndex].innerHTML,
value2 = tr2.cells[sortByCellIndex].innerHTML;
flag && trArray.splice(0, 1);
trArray = utils.sort(trArray,function (tr1, tr2) {
var txt = function(node){
return node.innerText||node.textContent;
};
return compareFn ? (typeof compareFn === "number" ? compareFn : compareFn.call(this, tr1.cells[sortByCellIndex], tr2.cells[sortByCellIndex])) : function () {
var value1 = txt(tr1.cells[sortByCellIndex]),
value2 = txt(tr2.cells[sortByCellIndex]);
return value1.localeCompare(value2);
}();
});
......@@ -1033,32 +1054,37 @@
for (var j = 0, len = trArray.length; j < len; j++) {
fragment.appendChild(trArray[j]);
}
table.getElementsByTagName("tbody")[0].appendChild(fragment);
var tbody = table.getElementsByTagName("tbody")[0];
if(!lastRowIndex){
tbody.appendChild(fragment);
}else{
tbody.insertBefore(fragment,rows[lastRowIndex- range.endRowIndex + range.beginRowIndex - 1])
}
},
setBackground:function(cells,value){
if(typeof value ==="string"){
utils.each(cells,function(cell){
setBackground:function (cells, value) {
if (typeof value === "string") {
utils.each(cells, function (cell) {
cell.style.backgroundColor = value;
})
}else if(typeof value === "object"){
} else if (typeof value === "object") {
value = utils.extend({
repeat:true,
colorList:["#ddd","#fff"]
},value);
colorList:["#ddd", "#fff"]
}, value);
var rowIndex = this.getCellInfo(cells[0]).rowIndex,
count = 0,
colors = value.colorList,
getColor = function(list,index,repeat){
return list[index] ? list[index] : repeat ? list[index % list.length]: "";
getColor = function (list, index, repeat) {
return list[index] ? list[index] : repeat ? list[index % list.length] : "";
};
for(var i = 0,cell;cell= cells[i++];){
for (var i = 0, cell; cell = cells[i++];) {
var cellInfo = this.getCellInfo(cell);
cell.style.backgroundColor = getColor(colors,((rowIndex + count) == cellInfo.rowIndex) ? count : ++count, value.repeat);
cell.style.backgroundColor = getColor(colors, ((rowIndex + count) == cellInfo.rowIndex) ? count : ++count, value.repeat);
}
}
},
removeBackground:function(cells){
utils.each(cells,function(cell){
removeBackground:function (cells) {
utils.each(cells, function (cell) {
cell.style.backgroundColor = "";
})
}
......
/**
* Created by JetBrains PhpStorm.
* User: dongyancen
* Date: 12-9-17
* Time: 下午2:19
* To change this template use File | Settings | File Templates.
*/
module( 'plugins.attachment' );
test( '检查高亮', function() {
var editor = te.obj[0];
editor.focus();
equal( editor.queryCommandState( 'attachment' ), 0, 'check attachment state' );
} );
\ No newline at end of file
......@@ -2,151 +2,135 @@ module( "plugins.blockquote" );
/*trace 967*/
//这个用例暂不测ie,因为ie中输入回车无效
/*
test( '切换到源码模式再切换回来点引用', function () {
if(!ua.browser.ie){
var editor = te.obj[0];
var body = editor.body;
editor.setContent( 'hello' );
editor.execCommand( 'source' );
var tas = editor.iframe.parentNode.getElementsByTagName( 'textarea' );
tas[tas.length - 1].value = '';
stop();
//source.js中有延时操作
setTimeout( function () {
editor.execCommand( 'source' );
editor.execCommand( 'blockquote' );
// //模拟回车,在引用后回车两段都是引用
setTimeout( function () {
//// //firefox竟然要多触发一次。。什么乱七八糟的bug啊
////// if ( ua.getBrowser() == "firefox" )
////// te.presskey( "enter", "" );
editor.focus();
te.presskey( "enter", "" );
setTimeout( function () {
editor.focus();
setTimeout( function () {
var bq = body.firstChild;
equal( body.childNodes.length, 1, 'body有1个孩子' );
equal( bq.childNodes.length, 2, 'blockquote有2个孩子' );
ok( bq.childNodes[0]&&bq.childNodes[0].tagName.toLowerCase()=='p', '第一个孩子是p' );
ok( bq.childNodes[1]&&bq.childNodes[1].tagName.toLowerCase()=='p', '第二个孩子是p' );
start();
}, 50 );
}, 30 );//
}, 60 );
}, 50 );
}
else
ok(ua.browser.ie,'这个用例暂不测,因为ie中输入回车无效');
} );
*/
//test( '切换到源码模式再切换回来点引用', function () {
// if(!ua.browser.ie){
// var editor = te.obj[0];
// var body = editor.body;
// editor.setContent( 'hello' );
// editor.execCommand( 'source' );
// var tas = editor.iframe.parentNode.getElementsByTagName( 'textarea' );
// tas[tas.length - 1].value = '';
// stop();
// setTimeout( function () { //source.js中有延时操作
// editor.execCommand( 'source' );
// editor.execCommand( 'blockquote' );
// setTimeout( function () { //模拟回车,在引用后回车两段都是引用
// //firefox竟然要多触发一次。。什么乱七八糟的bug啊
// //if ( ua.getBrowser() == "firefox" )
// //te.presskey( "enter", "" );
// debugger;
// editor.focus();
// te.presskey( "enter", "" );
// setTimeout( function () {
// editor.focus();
// setTimeout( function () {
// var bq = body.firstChild;
// equal( body.childNodes.length, 1, 'body有1个孩子' );
// equal( bq.childNodes.length, 2, 'blockquote有2个孩子' );
// ok( bq.childNodes[0]&&bq.childNodes[0].tagName.toLowerCase()=='p', '第一个孩子是p' );
// ok( bq.childNodes[1]&&bq.childNodes[1].tagName.toLowerCase()=='p', '第二个孩子是p' );
// start();
// }, 50 );
// }, 30 );
// }, 60 );
// }, 50 );
// }
// else
// ok(ua.browser.ie,'这个用例暂不测,因为ie中输入回车无效');
//} );
test( '在表格中添加和去除引用', function () {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( 'hello<table><tbody><tr><td>hello</td></tr></tbody></table>' );
var body = editor.body;
/*闭合选取*/
var tds = body.lastChild.getElementsByTagName( 'td' );
range.setStart( tds[0].firstChild, 2 ).collapse( true ).select();
editor.execCommand( 'blockquote' );
equal( body.lastChild.tagName.toLowerCase(), 'blockquote', '引用加到表格外面去了' );
equal( tds[0].firstChild.nodeType, 3, 'td里仍然是文本' );
equal( tds[0].firstChild.data, 'he', 'td里仍然是文本he' );
/*再执行一次引用,会去掉引用*/
range.setStart( tds[0].firstChild, 2 ).collapse( true ).select();
editor.execCommand( 'blockquote' );
//1.2版本table外加了div
ok( body.lastChild.tagName.toLowerCase() != 'blockquote', '引用去掉了' );
/*不闭合选中表格,添加引用*/
range.selectNode( tds[0] ).select();
editor.execCommand( 'blockquote' );
equal( body.lastChild.tagName.toLowerCase(), 'blockquote', '非闭合方式选中添加引用' );
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( 'hello<table><tbody><tr><td>hello</td></tr></tbody></table>' );
var body = editor.body;
var tds = body.lastChild.getElementsByTagName( 'td' );
range.setStart( tds[0].firstChild, 2 ).collapse( true ).select(); /*闭合选取*/
editor.execCommand( 'blockquote' );
equal( body.lastChild.tagName.toLowerCase(), 'blockquote', '引用加到表格外面去了' );
equal( tds[0].firstChild.nodeType, 3, 'td里仍然是文本' );
equal( tds[0].firstChild.data, 'he', 'td里仍然是文本he' );
range.setStart( tds[0].firstChild, 2 ).collapse( true ).select();
editor.execCommand( 'blockquote' ); /*再执行一次引用,会去掉引用*/
ok( body.lastChild.tagName.toLowerCase() != 'blockquote', '引用去掉了' ); //1.2版本table外加了div
range.selectNode( tds[0] ).select(); /*不闭合选中表格,添加引用*/
editor.execCommand( 'blockquote' );
equal( body.lastChild.tagName.toLowerCase(), 'blockquote', '非闭合方式选中添加引用' );
} );
test( '在列表中添加引用', function () {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( 'hello<ol><li><p>hello1</p></li><li><p>hello2</p></li></ol>' );
var body = editor.body;
/*闭合选取*/
var lis = body.lastChild.getElementsByTagName( 'li' );
range.setStart( lis[0].firstChild, 1 ).collapse( 1 ).select();
editor.execCommand( 'blockquote' );
equal( body.lastChild.tagName.toLowerCase(), 'blockquote', '引用加到列表外面去了' );
equal( lis[0].firstChild.nodeType, 1, '列表里套着p' );
equal( lis[0].firstChild.firstChild.data, 'hello1', '列表里仍然是文本hello1' );
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( 'hello<ol><li><p>hello1</p></li><li><p>hello2</p></li></ol>' );
var body = editor.body;
var lis = body.lastChild.getElementsByTagName( 'li' );
range.setStart( lis[0].firstChild, 1 ).collapse( 1 ).select(); /*闭合选取*/
editor.execCommand( 'blockquote' );
equal( body.lastChild.tagName.toLowerCase(), 'blockquote', '引用加到列表外面去了' );
equal( lis[0].firstChild.nodeType, 1, '列表里套着p' );
equal( lis[0].firstChild.firstChild.data, 'hello1', '列表里仍然是文本hello1' );
} );
/*trace 1183*/
test( 'trace1183:选中列表中添加引用,再去掉引用', function () {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( '<p>hello1</p><p>hello2</p>' );
var body = editor.body;
range.setStart( body, 0 ).setEnd( body, 2 ).select();
/*添加列表*/
editor.execCommand( 'insertorderedlist' );
ua.manualDeleteFillData( editor.body );
var ol = body.getElementsByTagName( 'ol' )[0];
var html = ua.getChildHTML( ol );
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( '<p>hello1</p><p>hello2</p>' );
var body = editor.body;
range.setStart( body, 0 ).setEnd( body, 2 ).select();
editor.execCommand( 'insertorderedlist' ); /*添加列表*/
ua.manualDeleteFillData( editor.body );
var ol = body.getElementsByTagName( 'ol' )[0];
var html = ua.getChildHTML( ol );
editor.execCommand( 'blockquote' );
editor.execCommand( 'blockquote' );
ua.manualDeleteFillData( editor.body );
equal( ua.getChildHTML( body.getElementsByTagName( 'ol' )[0] ), html, '引用前后列表没有发生变化' );
equal( body.getElementsByTagName( 'ol' ).length, 1, '只有一个有序列表' );
editor.execCommand( 'blockquote' );
editor.execCommand( 'blockquote' );
ua.manualDeleteFillData( editor.body );
equal( ua.getChildHTML( body.getElementsByTagName( 'ol' )[0] ), html, '引用前后列表没有发生变化' );
equal( body.getElementsByTagName( 'ol' ).length, 1, '只有一个有序列表' );
} );
test( '对段落添加引用和去除引用', function () {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( '<p><strong><em>hello1</em></strong></p><p>hello2 world</p>' );
var body = editor.body;
/*不闭合添加引用*/
range.setStart( body.firstChild, 0 ).setEnd( body.lastChild, 1 ).select();
editor.execCommand( 'blockquote' );
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( '<p><strong><em>hello1</em></strong></p><p>hello2 world</p>' );
var body = editor.body;
range.setStart( body.firstChild, 0 ).setEnd( body.lastChild, 1 ).select(); /*不闭合添加引用*/
editor.execCommand( 'blockquote' );
equal( ua.getChildHTML( body ), '<blockquote><p><strong><em>hello1</em></strong></p><p>hello2&nbsp;world</p></blockquote>', '不闭合添加引用' );
equal( editor.queryCommandState( 'blockquote' ), 1, '引用高亮' );
equal( ua.getChildHTML( body ), '<blockquote><p><strong><em>hello1</em></strong></p><p>hello2&nbsp;world</p></blockquote>', '不闭合添加引用' );
equal( editor.queryCommandState( 'blockquote' ), 1, '引用高亮' );
/*闭合去除引用*/
range.setStart( body.firstChild.lastChild, 0 ).collapse( true ).select();
editor.execCommand( 'blockquote' );
equal( ua.getChildHTML( body ), '<blockquote><p><strong><em>hello1</em></strong></p></blockquote><p>hello2&nbsp;world</p>', '闭合去除引用' );
equal( editor.queryCommandState( 'blockquote' ), 0, '引用不高亮' );
/*非闭合去除引用*/
range.setStart( body.firstChild, 0 ).setEnd( body.lastChild, 1 ).select();
editor.execCommand( 'blockquote' );
equal( ua.getChildHTML( body ), '<p><strong><em>hello1</em></strong></p><p>hello2&nbsp;world</p>' );
equal( editor.queryCommandState( 'blockquote' ), 0, '非闭合去除引用后,引用不高亮' );
/*闭合添加引用*/
range.setStart( body.lastChild, 0 ).collapse( true ).select();
editor.execCommand( 'blockquote' );
equal( ua.getChildHTML( body ), '<p><strong><em>hello1</em></strong></p><blockquote><p>hello2&nbsp;world</p></blockquote>', '闭合添加引用 ' );
} );
range.setStart( body.firstChild.lastChild, 0 ).collapse( true ).select(); /*闭合去除引用*/
editor.execCommand( 'blockquote' );
equal( ua.getChildHTML( body ), '<blockquote><p><strong><em>hello1</em></strong></p></blockquote><p>hello2&nbsp;world</p>', '闭合去除引用' );
equal( editor.queryCommandState( 'blockquote' ), 0, '引用不高亮' );
range.setStart( body.firstChild, 0 ).setEnd( body.lastChild, 1 ).select(); /*非闭合去除引用*/
editor.execCommand( 'blockquote' );
equal( ua.getChildHTML( body ), '<p><strong><em>hello1</em></strong></p><p>hello2&nbsp;world</p>' );
equal( editor.queryCommandState( 'blockquote' ), 0, '非闭合去除引用后,引用不高亮' );
range.setStart( body.lastChild, 0 ).collapse( true ).select(); /*闭合添加引用*/
editor.execCommand( 'blockquote' );
equal( ua.getChildHTML( body ), '<p><strong><em>hello1</em></strong></p><blockquote><p>hello2&nbsp;world</p></blockquote>', '闭合添加引用 ' );
} );
test( 'startContainer为body添加引用', function () {
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( 'hello<ol><li>hello1</li><li>hello2</li></ol>' );
var body = editor.body;
/*不闭合选取*/
range.setStart( body, 0 ).setEnd( body, 2 ).select();
editor.execCommand( 'blockquote' );
// var padding = ua.browser.ie&&ua.browser.ie<9?' style=\" list-paddingleft-2\"':(ua.browser.webkit?' class=\" list-paddingleft-2\"':' style=\" list-paddingleft-2\"');
var padding = ' class=\" list-paddingleft-2\"';
equal( ua.getChildHTML( body ), '<blockquote><p>hello</p><ol'+padding+'><li><p>hello1</p></li><li><p>hello2</p></li></ol></blockquote>', '选中body加引用' );
equal( editor.queryCommandState( 'blockquote' ), 1, '引用高亮' );
/*闭合选取*/
editor.undoManger.undo();
range.setStart( body, 1 ).collapse( true ).select();
equal( editor.queryCommandState( 'blockquote' ), 0, '引用不高亮' );
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent( 'hello<ol><li>hello1</li><li>hello2</li></ol>' );
var body = editor.body;
range.setStart( body, 0 ).setEnd( body, 2 ).select(); /*不闭合选取*/
editor.execCommand( 'blockquote' );
// var padding = ua.browser.ie&&ua.browser.ie<9?' style=\" list-paddingleft-2\"':(ua.browser.webkit?' class=\" list-paddingleft-2\"':' style=\" list-paddingleft-2\"');
var padding = ' class=\" list-paddingleft-2\"';
equal( ua.getChildHTML( body ), '<blockquote><p>hello</p><ol'+padding+'><li><p>hello1</p></li><li><p>hello2</p></li></ol></blockquote>', '选中body加引用' );
equal( editor.queryCommandState( 'blockquote' ), 1, '引用高亮' );
editor.undoManger.undo();
range.setStart( body, 1 ).collapse( true ).select(); /*闭合选取*/
equal( editor.queryCommandState( 'blockquote' ), 0, '引用不高亮' );
} );
//ie 不通过
test('aa标签',function(){
var editor = te.obj[0];
......@@ -163,6 +147,7 @@ test('aa标签',function(){
}
});
/*trace 3284*/
test('列表内引用',function(){
var editor = te.obj[0];
var range = te.obj[1];
......
/**
* Created by JetBrains PhpStorm.
* User: lisisi01
* Date: 12-9-18
* Time: 下午12:33
* To change this template use File | Settings | File Templates.
*/
module('plugins.emotion');
test('选择表情',function(){
var editor=te.obj[0];
editor.focus();
equal(editor.queryCommandState('emotion'),0,'state');
});
\ No newline at end of file
......@@ -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' );
......
/**
* Created by JetBrains PhpStorm.
* User: lisisi01
* Date: 12-9-18
* Time: 下午12:59
* To change this template use File | Settings | File Templates.
*/
module('plugins.map');
test('选择地图',function(){
var editor=te.obj[0];
editor.focus();
equal(editor.queryCommandState('map'),0,'map state');
equal(editor.queryCommandState('gmap'),0,'gmap state');
});
\ No newline at end of file
module('plugins.searchreplace');
/*trace 974,先替换再撤销再全部替换,则不会替换
* ie下会出现的bug*/
test('全部替换',function(){
......@@ -17,66 +16,67 @@ test('全部替换',function(){
equal(editor.body.firstChild.innerHTML,'你好回来');
});
/*trace 917*/
test('替换内容包含查找内容,全部替换',function(){
if(ua.browser.opera)
return;
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('<p>hello回来</p>');
range.setStart(editor.body.firstChild,0).collapse(true).select();
/*searchreplace文件里是一个闭包,闭包中有一个全局变量currentRange,在上一次用例执行结束后仍然会保存这个值,导致下一次用例受影响*/
editor.execCommand('searchreplace',{searchStr:'hello',replaceStr:'hello啊',all:true});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'hello啊回来');
});
///*trace 917*/
//test('替换内容包含查找内容,全部替换',function(){
// if(ua.browser.opera)
// return;
// var editor = te.obj[0];
// var range = te.obj[1];
// editor.setContent('<p>hello回来</p>');
// range.setStart(editor.body.firstChild,0).collapse(true).select();
// debugger;
// /*searchreplace文件里是一个闭包,闭包中有一个全局变量currentRange,在上一次用例执行结束后仍然会保存这个值,导致下一次用例受影响*/
// editor.execCommand('searchreplace',{searchStr:'hello',replaceStr:'hello啊',all:true});
// ua.manualDeleteFillData(editor.body);
// equal(editor.body.firstChild.innerHTML,'hello啊回来');
//});
/*trace 973*/
test('替换内容包含查找内容',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(1).select();
editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:'欢迎啊'});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'欢迎啊回来');
editor.undoManger.undo();
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'欢迎回来');
});
/*trace 1286*/
test('连续2次全部替换',function(){
if(ua.browser.opera)
return;
var editor = te.obj[0];
editor.setContent('<p>欢迎回来</p>');
editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:'欢迎啊',all:true});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'欢迎啊回来');
editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:'欢迎啊',all:true});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'欢迎啊啊回来');
var editor = te.obj[0];
var range = te.obj[1];
editor.setContent('<p>欢迎回来</p>');
range.setStart(editor.body.firstChild,0).collapse(1).select();
editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:'欢迎啊'});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'欢迎啊回来');
editor.undoManger.undo();
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'欢迎回来');
});
//
///*trace 1286*/
//test('连续2次全部替换',function(){
// if(ua.browser.opera)
// return;
// var editor = te.obj[0];
// editor.setContent('<p>欢迎回来</p>');
// editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:'欢迎啊',all:true});
// ua.manualDeleteFillData(editor.body);
// equal(editor.body.firstChild.innerHTML,'欢迎啊回来');
// editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:'欢迎啊',all:true});
// ua.manualDeleteFillData(editor.body);
// equal(editor.body.firstChild.innerHTML,'欢迎啊啊回来');
//});
//
test('替换内容为空',function(){
if(ua.browser.opera)
return;
var editor = te.obj[0];
editor.setContent('<p>欢迎回来</p>');
editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:''});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'回来');
var editor = te.obj[0];
editor.setContent('<p>欢迎回来</p>');
editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:''});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'回来');
});
test('全部替换内容为空',function(){
if(ua.browser.opera)
return;
var editor = te.obj[0];
editor.setContent('<p>欢迎回来 欢迎啊</p>');
editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:'',all:true});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'回来&nbsp;啊');
var editor = te.obj[0];
editor.setContent('<p>欢迎回来 欢迎啊</p>');
editor.execCommand('searchreplace',{searchStr:'欢迎',replaceStr:'',all:true});
ua.manualDeleteFillData(editor.body);
equal(editor.body.firstChild.innerHTML,'回来&nbsp;啊');
});
\ No newline at end of file
......@@ -9,5 +9,5 @@ module( 'plugins.snapscreen' );
test( '检查高亮', function() {
var editor = te.obj[0];
editor.focus();
equal( editor.queryCommandState( 'snapscreen' ), ua.browser.ie?0:-1, 'check snapscreen state' );
equal( editor.queryCommandState( 'snapscreen' ), 0, 'check snapscreen state' );
} );
\ No newline at end of file
/**
* Created by JetBrains PhpStorm.
* User: dongyancen
* Date: 12-9-18
* Time: 下午4:34
* To change this template use File | Settings | File Templates.
*/
module( 'plugins.spechars' );
test( '检查高亮', function() {
var editor = te.obj[0];
editor.focus();
equal( editor.queryCommandState( 'spechars' ), 0, 'check attachment state' );
} );
\ No newline at end of file
/**
* Created with JetBrains PhpStorm.
* User: taoqili
* Date: 13-2-25
* Time: 下午4:40
* To change this template use File | Settings | File Templates.
*/
......@@ -47,4 +47,92 @@ test("getMaxCols",function(){
ut = new UT(table);
maxCols = ut.getMaxCols();
equal(maxCols,6,"最大列数为6");
});
test("getSameEndPosCells",function(){
var table = getTable("<tr><td rowspan='2'>1</td><td>2</td><td>3</td></tr>" +
"<tr><td>2</td><td>3</td></tr>"),
ut = new UT(table);
var cell = table.rows[0].cells[0],
cells1 = ut.getSameEndPosCells(cell,"x"),
cells2 = ut.getSameEndPosCells(cell,"y");
ok(cells1.length == 1, "获取到同样X轴结尾位置的cell1个");
ok(cells2.length == 2, "获取到同样Y轴结尾位置的cell2个");
});
test("getHSideCell",function(){
var table = getTable("<tr><td rowspan='2'>1</td><td>2</td><td>3</td></tr>" +
"<tr><td>2</td><td>3</td></tr>"),
ut = new UT(table);
var rows = table.rows,
cell = rows[1].cells[1],
cell1 = ut.getHSideCell(cell),
cell2 = ut.getHSideCell(cell,true);
equal(cell1,rows[1].cells[0],"左边单元格");
equal(cell2,null,"位于右边缘的单元格无右邻居单元格");
equal(ut.getHSideCell(rows[0][0]),null,"位于左边缘的单元格无左邻居单元格");
});
test("getVSideCell",function(){
var table = getTable("<tr><td rowspan='2'>1</td><td>2</td><td>3</td></tr>" +
"<tr><td>2</td><td>3</td></tr>"),
ut = new UT(table);
var rows = table.rows,
cell = rows[1].cells[1],
cell1 = ut.getVSideCell(cell),
cell2 = ut.getVSideCell(cell,true),
cell3 = ut.getVSideCell(cell,true,true);
equal(cell1,rows[0].cells[2],"上边单元格");
equal(cell2,null,"位于下边缘的单元格无下邻居单元格");
equal(cell3,null,"位于左边缘的单元格无左邻居单元格");
});
test("setCellContent",function(){
var table = getTable("<tr><td rowspan='2'>1</td><td>2</td><td>3</td></tr>" +
"<tr><td>2</td><td>3</td></tr>"),
ut = new UT(table);
var cell = table.rows[0].cells[0];
ut.setCellContent(cell,"这是测试内容");
equal(cell.innerHTML,"这是测试内容","设置了正确的内容");
ut.setCellContent(cell);
equal(cell.innerHTML,browser.ie ? domUtils.fillChar : "<br>");
});
test("cloneCell",function(){
var table = getTable("<tr><td style='border-top-color: red;border-bottom-color: green' rowspan='2'>1</td><td>2</td><td>3</td></tr>" +
"<tr><td class='selectedClass'>2</td><td>3</td></tr>"),
ut = new UT(table);
var cell = ut.cloneCell(table.rows[0].cells[0]);
equal(cell.rowSpan,2,"clone了一个2行一列的单元格");
equal(cell.style.borderTopColor,"green","上边框的颜色将会被下边框取代");
cell = ut.cloneCell(table.rows[0].cells[0],true);
ok(cell.rowSpan,1,"忽略被合并单元格时将会充值单元格的rowspan和colspan为1")
});
test("getCellsRange、getCells",function(){
var table = getTable("<tr><td rowspan='2'>1</td><td>2</td><td>3</td></tr>" +
"<tr><td class='selectedClass'>2</td><td>3</td></tr>"),
ut = new UT(table);
var range = ut.getCellsRange(table.rows[0].cells[1],table.rows[1].cells[0]);
ok(range.beginRowIndex===0 && range.beginColIndex===1 && range.endRowIndex===1 && range.endColIndex===1,"获取到range")
var cells = ut.getCells(range);
ok(cells.length ==2,"获取到2个单元格");
ok(cells[0] == table.rows[0].cells[1],"第一个单元格存在");
});
test("insertRow、deleterRow",function(){
var table = getTable("<tr><td rowspan='2'>1</td><td>2</td><td>3</td></tr>" +
"<tr><td class='selectedClass'>2</td><td>3</td></tr>"),
ut = new UT(table);
var cellPrototype = document.createElement("td");
cellPrototype.innerHTML = "aa";
cellPrototype.setAttribute("vAlign","top");
ut.insertRow(2,cellPrototype);
ok(table.rows.length ===3,"行数变成3行");
ok(table.rows[2].cells[0].getAttribute("vAlign") =="top","新插入的单元格中包含原型单元格中的属性");
});
\ No newline at end of file
......@@ -125,11 +125,14 @@
}
try {
if (config.stopCount == 1) {
setTimeout(function() {
callback.call(testEnvironment);
start();
}, 80);
if (config.stopCount == 1) {
start();
}
}, 100);
}
else{
callback.call(testEnvironment);
......
......@@ -18,6 +18,7 @@
<label><input type="checkbox" id="J_caption" name="style"/><var id="lang_insertTitle"></var></label>
</li>
</ul>
<label><input type="checkbox" id="J_sorttable" name="style"/>使表格内容可排序</label>
<div class="clear"></div>
</div>
<div class="section">
......
......@@ -8,6 +8,7 @@
(function () {
var title = $G("J_title"),
caption = $G("J_caption"),
sorttable = $G("J_sorttable"),
autoSizeContent = $G("J_autoSizeContent"),
autoSizePage = $G("J_autoSizePage"),
tone = $G("J_tone"),
......@@ -37,6 +38,7 @@
domUtils.on(title, "click", me.titleHanler);
domUtils.on(caption, "click", me.captionHanler);
domUtils.on(sorttable, "click", me.sorttableHanler);
domUtils.on(autoSizeContent, "click", me.autoSizeContentHanler);
domUtils.on(autoSizePage, "click", me.autoSizePageHanler);
......@@ -109,6 +111,22 @@
domUtils.remove(domUtils.getElementsByTagName(example, 'caption')[0]);
}
},
sorttableHanler:function(){
var example = $G("J_example"),
row = example.rows[0];
if (sorttable.checked) {
for(var i = 0,cell;cell = row.cells[i++];){
var span = document.createElement("span");
span.innerHTML = "^";
cell.appendChild(span);
}
} else {
var spans = domUtils.getElementsByTagName(example,"span");
utils.each(spans,function(span){
span.parentNode.removeChild(span);
})
}
},
autoSizeContentHanler:function () {
var example = $G("J_example");
example.removeAttribute("width");
......@@ -162,16 +180,19 @@
dialog.onok = function () {
editor.__hasEnterExecCommand = true;
if (title.checked) {
editor.queryCommandState("inserttitle") != -1 && editor.execCommand("inserttitle")
} else {
editor.queryCommandState("deletetitle") != -1 && editor.execCommand("deletetitle");
}
if (caption.checked) {
editor.queryCommandState("insertcaption") != -1 && editor.execCommand("insertcaption")
} else {
editor.queryCommandState("deletecaption") != -1 && editor.execCommand("deletecaption");
var checks = {
title:"inserttitle deletetitle",
caption:"insertcaption deletecaption",
sorttable:"enablesort disablesort"
};
for(var i in checks){
var cmds = checks[i].split(" "),
input = $G("J_" + i);
if(input["checked"]){
editor.queryCommandState(cmds[0])!=-1 &&editor.execCommand(cmds[0]);
}else{
editor.queryCommandState(cmds[1])!=-1 &&editor.execCommand(cmds[1]);
}
}
editor.execCommand("edittable", tone.value);
autoSizeContent.checked ?editor.execCommand('adaptbytext') : "";
......
......@@ -142,7 +142,9 @@
//,imagePopup:true //图片操作的浮层开关,默认打开
//,initialStyle:'body{font-size:18px}' //编辑器内部样式,可以用来改变字体等
,initialStyle:'body{font-size:16px}' +
'.back1{background:#eee;}' +
'.back2{background:#ddd}' //编辑器内部样式,可以用来改变字体等
//,emotionLocalization:false //是否开启表情本地化,默认关闭。若要开启请确保emotion文件夹下包含官网提供的images表情文件夹
......
......@@ -250,7 +250,7 @@
.edui-default .edui-for-edittable .edui-dialog-content {
width: 540px;
_width:590px;
height: 265px;
height: 285px;
}
/*edittip-dialog*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册