Blame view

public/assets/addons/nkeditor/plugins/clearhtml/clearhtml.js 1.13 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  /*******************************************************************************
  * KindEditor - WYSIWYG HTML Editor for Internet
  * Copyright (C) 2006-2011 kindsoft.net
  *
  * @author Roddy <luolonghao@gmail.com>
  * @site http://www.kindsoft.net/
  * @licence http://www.kindsoft.net/license.php
  *******************************************************************************/
  
  KindEditor.plugin('clearhtml', function(K) {
  	var self = this, name = 'clearhtml';
  	self.clickToolbar(name, function() {
  		self.focus();
  		var html = self.html();
  		html = html.replace(/(<script[^>]*>)([\s\S]*?)(<\/script>)/ig, '');
  		html = html.replace(/(<style[^>]*>)([\s\S]*?)(<\/style>)/ig, '');
  		html = K.formatHtml(html, {
  			a : ['href', 'target'],
  			embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
  			img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height'],
  			table : ['border'],
  			'td,th' : ['rowspan', 'colspan'],
  			'div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : []
  		});
  		self.html(html);
  		self.cmd.selection(true);
  		self.addBookmark();
  	});
  });