clearhtml.js 1.2 KB

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