wordpaste.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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('wordpaste', function(K) {
  10. var self = this, name = 'wordpaste';
  11. self.clickToolbar(name, function() {
  12. var lang = self.lang(name + '.'),
  13. html = '<div style="padding:10px 20px;">' +
  14. '<div style="margin-bottom:10px;">' + lang.comment + '</div>' +
  15. '<iframe class="ke-textarea" frameborder="0" style="width:408px;height:260px;"></iframe>' +
  16. '</div>',
  17. dialog = self.createDialog({
  18. name : name,
  19. width : 450,
  20. title : self.lang(name),
  21. body : html,
  22. yesBtn : {
  23. name : self.lang('yes'),
  24. click : function(e) {
  25. var str = doc.body.innerHTML;
  26. str = K.clearMsWord(str, self.filterMode ? self.htmlTags : K.options.htmlTags);
  27. self.insertHtml(str).hideDialog().focus();
  28. }
  29. }
  30. }),
  31. div = dialog.div,
  32. iframe = K('iframe', div),
  33. doc = K.iframeDoc(iframe);
  34. if (!K.IE) {
  35. doc.designMode = 'on';
  36. }
  37. doc.open();
  38. doc.write('<!doctype html><html><head><title>WordPaste</title></head>');
  39. doc.write('<body style="background-color:#FFF;font-size:12px;margin:2px;">');
  40. if (!K.IE) {
  41. doc.write('<br />');
  42. }
  43. doc.write('</body></html>');
  44. doc.close();
  45. if (K.IE) {
  46. doc.body.contentEditable = 'true';
  47. }
  48. iframe[0].contentWindow.focus();
  49. });
  50. });