/******************************************************************************* * KindEditor - WYSIWYG HTML Editor for Internet * Copyright (C) 2006-2011 kindsoft.net * * @author Roddy * @site http://www.kindsoft.net/ * @licence http://www.kindsoft.net/license.php *******************************************************************************/ KindEditor.plugin('preview', function(K) { var self = this, name = 'preview', undefined; self.clickToolbar(name, function() { var lang = self.lang(name + '.'), width = document.documentElement.clientWidth * 0.9, height = document.documentElement.clientHeight - 160, html = '
' + '' + '
', dialog = self.createDialog({ name : name, width : width, title : self.lang(name), body : html }), iframe = K('iframe', dialog.div), doc = K.iframeDoc(iframe); doc.open(); var cssPath = self.options.cssPath; var jsPath = self.options.jsPath; var arr = [ '', '', //'', ''); // 加载 css if (!K.isArray(cssPath)) { cssPath = [cssPath]; } if (K.inArray(self.options.pluginsPath+'code/prism.css', cssPath) < 0) { cssPath.push(self.options.pluginsPath+'code/prism.css'); } K.each(cssPath, function(i, path) { if (path) { arr.push(''); } }); if (self.options.cssData) { arr.push(''); } arr.push(''); // 获取编辑器内容 arr.push(self.fullHtml()); // 加载脚本 if (!K.isArray(jsPath)) { jsPath = [jsPath]; } // 加载代码高亮的脚本 if (K.inArray(self.options.pluginsPath+'code/prism.js', jsPath) < 0) { jsPath.push(self.options.pluginsPath+'code/prism.js'); } K.each(jsPath, function(i, path) { if (path) { arr.push(''); } }); arr.push(''); doc.write(arr.join('\n')); doc.close(); K(doc.body).css('background-color', '#FFF'); iframe[0].contentWindow.focus(); }); });