📄 kindeditor.js
字号:
} else { obj.formDiv.style.height = height + 'px'; obj.iframe.style.height = height + 'px'; obj.newTextarea.style.width = '100%'; obj.newTextarea.style.height = height + 'px'; } }, getData : function(id, filterMode) { var data; filterMode = (typeof filterMode == "undefined") ? true : filterMode; if (KE.g[id].wyswygMode) { if (filterMode) { data = KE.util.outputHtml(id, KE.g[id].iframeDoc.body); } else { data = KE.g[id].iframeDoc.body.innerHTML; } } else { data = KE.g[id].newTextarea.value; } return data; }, setData : function(id) { var data = this.getData(id, KE.g[id].filterMode); KE.g[id].srcTextarea.value = data; }, getPureData : function(id) { var data = this.getData(id, false); data = data.replace(/<br[\s\/]{0,2}>/ig, "\r\n"); data = data.replace(/<.*?>/ig, ""); return data; }, setPureData : function(id) { var data = this.getPureData(id); KE.g[id].srcTextarea.value = data; }, focus : function(id) { if (KE.g[id].wyswygMode) { KE.g[id].iframeWin.focus(); } else { KE.g[id].newTextarea.focus(); } }, click : function(id, cmd) { KE.layout.hide(id); KE.util.focus(id); KE.plugin[cmd].click(id); }, selection : function(id) { var win = KE.g[id].iframeWin; var doc = KE.g[id].iframeDoc; var sel = win.getSelection ? win.getSelection() : doc.selection; var range; try { if (sel.rangeCount > 0) { range = sel.getRangeAt(0); } else { range = sel.createRange ? sel.createRange() : doc.createRange(); } } catch(e) {} if (!range) { range = (KE.browser == 'IE') ? doc.body.createTextRange() : doc.createRange(); } KE.g[id].selection = sel; KE.g[id].range = range; }, select : function(id) { if (KE.browser == 'IE') KE.g[id].range.select(); }, pToBr : function(id) { if(KE.browser == 'IE') { KE.event.add(KE.g[id].iframeDoc, 'keydown', function(e) { if (e.keyCode == 13) { KE.util.selection(id); if(KE.g[id].range.parentElement().tagName != 'LI') { KE.util.insertHtml(id, '<br />'); return false; } } }); } }, execCommand : function(id, cmd, value) { try { KE.g[id].iframeDoc.execCommand(cmd, false, value); } catch(e) {} KE.history.add(id, false); }, insertHtml : function(id, html) { if (html == '') return; KE.util.select(id); if (KE.browser == 'IE') { if (KE.g[id].selection.type.toLowerCase() == 'control') { KE.g[id].range.item(0).outerHTML = html; } else { KE.g[id].range.pasteHTML(html); } KE.history.add(id, false); } else { this.execCommand(id, 'inserthtml', html); } }, removeDomain : function(id, url) { for (var i = 0; i < KE.g[id].siteDomains.length; i++) { var domain = "http://" + KE.g[id].siteDomains[i]; if (url.indexOf(domain) == 0) { url = url.substr(domain.length); } } return url; }, outputHtml : function(id, element) { var htmlTags = KE.g[id].htmlTags; var htmlList = []; var startTags = []; var setStartTag = function(tagName, attrStr, styleStr, endFlag) { var html = ''; html += '<' + tagName; if (attrStr) html += attrStr; if (styleStr) html += ' style="' + styleStr + '"'; html += endFlag ? ' />' : '>'; if (KE.browser == 'IE' && endFlag && KE.util.inArray(tagName, ['br', 'hr'])) html += "\n"; htmlList.push(html); if (!endFlag) startTags.push(tagName); }; var setEndTag = function() { if (startTags.length > 0) { var endTag = startTags.pop(); var html = '</' + endTag + '>'; if (KE.browser == 'IE' && KE.util.inArray(endTag, ['p', 'div', 'table', 'ol', 'ul'])) html += "\n"; htmlList.push(html); } }; var scanNodes = function(el) { var nodes = el.childNodes; for (var i = 0, len = nodes.length; i < len; i++) { var node = nodes[i]; switch (node.nodeType) { case 1: var tagName = node.tagName.toLowerCase(); if (typeof htmlTags[tagName] != 'undefined') { var attrStr = ''; var styleStr = ''; var attrList = htmlTags[tagName]; var endFlag = false; for (var j = 0, l = attrList.length; j < l; j++) { var attr = attrList[j]; if (attr == '/') endFlag = true; else if (attr.charAt(0) == '.') { var key = attr.substr(1); var arr = key.split('-'); var jsKey = ''; for (var k = 0, length = arr.length; k < length; k++) { jsKey += (k > 0) ? arr[k].charAt(0).toUpperCase() + arr[k].substr(1) : arr[k]; } if (key == 'border') { if (node.style.border) { styleStr += 'border:' + node.style.border + ';'; } else if (node.style.borderWidth && node.style.borderStyle && node.style.borderColor) { styleStr += 'border:' + node.style.borderWidth + ' ' + node.style.borderStyle + ' ' + node.style.borderColor + ';'; } } else if (key == 'margin') { if (node.style.margin) { styleStr += 'margin:' + node.style.margin + ';'; } else { if (node.style.marginLeft) styleStr += 'margin-left:' + node.style.marginLeft + ';'; if (node.style.marginRight) styleStr += 'margin-right:' + node.style.marginRight + ';'; if (node.style.marginTop) styleStr += 'margin-top:' + node.style.marginTop + ';'; if (node.style.marginBottom) styleStr += 'margin-bottom:' + node.style.marginBottom + ';'; } } else if (key == 'padding') { if (node.style.padding) { styleStr += 'padding:' + node.style.padding + ';'; } else { if (node.style.paddingLeft) styleStr += 'padding-left:' + node.style.paddingLeft + ';'; if (node.style.paddingRight) styleStr += 'padding-right:' + node.style.paddingRight + ';'; if (node.style.paddingTop) styleStr += 'padding-top:' + node.style.paddingTop + ';'; if (node.style.paddingBottom) styleStr += 'padding-bottom:' + node.style.paddingBottom + ';'; } } else { if (node.style[jsKey]) styleStr += key + ':' + node.style[jsKey] + ';'; } } else { var val = node.getAttribute(attr); if (val != null && val !== '') { if (typeof val == 'string' && val.match(/^javascript:/)) val = ''; attrStr += ' ' + attr + '="' + val + '"'; } } } setStartTag(tagName, attrStr, styleStr, endFlag); } if (node.hasChildNodes()) { scanNodes(node); } else { if (startTags.length > 0) { var prevHtml = htmlList[htmlList.length - 1]; if (prevHtml.match(/^<p|^<div/) != null) { htmlList.push(" "); setEndTag(); } } } break; case 3: htmlList.push(KE.util.escape(node.nodeValue)); break; default: break; } } setEndTag(); }; scanNodes(element); return htmlList.join(''); }};KE.layout = { show : function(id, div) { KE.layout.hide(id); KE.g[id].hideDiv.appendChild(div); KE.g[id].hideDiv.style.display = 'block'; KE.g[id].layoutDiv = div; }, hide : function(id) { try { KE.g[id].hideDiv.removeChild(KE.g[id].layoutDiv); } catch (e) {} KE.g[id].hideDiv.style.display = 'none'; KE.g[id].maskDiv.style.display = 'none'; KE.util.focus(id); }, make : function(id) { var div = KE.$$('div'); div.style.position = 'absolute'; div.style.zIndex = 19811214; return div; }};KE.menu = function(arg){ this.arg = arg; var div = KE.layout.make(arg.id); div.className = 'ke-menu'; var obj = KE.g[arg.id].toolbarIcon[arg.cmd]; var pos = KE.util.getElementPos(obj); div.style.top = pos.y + obj.offsetHeight + 'px'; div.style.left = pos.x + 'px'; this.div = div; this.add = function(html, event) { var cDiv = KE.$$('div'); cDiv.className = 'ke-menu-noselected'; cDiv.style.width = this.arg.width; cDiv.onmouseover = function() { this.className = 'ke-menu-selected'; } cDiv.onmouseout = function() { this.className = 'ke-menu-noselected'; } cDiv.onclick = event; cDiv.innerHTML = html; this.append(cDiv); }; this.append = function(el) { this.div.appendChild(el); }; this.insert = function(html) { this.div.innerHTML = html; }; this.show = function() { KE.layout.show(this.arg.id, this.div); }; this.picker = function() { var colorTable = KE.lang['colorTable']; var table = KE.$$('table'); table.cellPadding = 0; table.cellSpacing = 0; table.border = 0; table.style.margin = 0; table.style.padding = 0; table.style.borderCollapse = 'separate'; for (var i = 0; i < colorTable.length; i++) { var row = table.insertRow(i); for (var j = 0; j < colorTable[i].length; j++) { var cell = row.insertCell(j); cell.className = 'ke-picker-cell'; cell.style.backgroundColor = colorTable[i][j]; cell.title = colorTable[i][j]; cell.onmouseover = function() {this.style.borderColor = '#000000'; } cell.onmouseout = function() {this.style.borderColor = '#F0F0EE'; } cell.onclick = new Function('KE.plugin["' + this.arg.cmd + '"].exec("' + this.arg.id + '", "' + colorTable[i][j] + '")'); cell.innerHTML = ' '; } } this.append(table); this.show(); };};KE.dialog = function(arg){ this.arg = arg; this.topHeight = 20; this.bottomHeight = 76; this.getPos = function() { var arg = this.arg; var id = this.arg.id; var pos = KE.util.getElementPos(KE.g[id].container); var height = arg.height + this.topHeight + this.bottomHeight; var xDiff = Math.round(parseInt(KE.g[id].container.style.width) / 2) - Math.round(arg.width / 2); var yDiff = Math.round(parseInt(KE.g[id].container.style.height) / 2) - Math.round(height / 2); var x = xDiff < 0 ? pos.x : pos.x + xDiff; var y = yDiff < 0 ? pos.y : pos.y + yDiff; return {'x' : x, 'y' : y}; }; this.show = function() { var arg = this.arg; var id = arg.id; var div = KE.layout.make(arg.id); div.className = 'ke-dialog'; var pos = this.getPos(); div.style.width = (arg.width + this.topHeight) + 'px'; div.style.height = (arg.height + this.bottomHeight) + 'px'; div.style.top = pos.y + 'px'; div.style.left = pos.x + 'px'; var titleDiv = KE.$$('div'); titleDiv.className = 'ke-dialog-title'; titleDiv.innerHTML = arg.title; var img = KE.$$('img'); img.src = KE.g[id].skinsPath + 'spacer.gif'; var url = KE.g[id].skinsPath + KE.g[id].skinType + '.gif'; img.style.backgroundImage = "url(" + url + ")"; img.className = "ke-toolbar-close"; img.alt = KE.lang['close']; img.title = KE.lang['close'];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -