pastetext.js 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. tinyMCEPopup.requireLangPack();
  2. var PasteTextDialog = {
  3. init : function() {
  4. this.resize();
  5. },
  6. insert : function() {
  7. var h = tinyMCEPopup.dom.encode(document.getElementById('content').value), lines;
  8. // Convert linebreaks into paragraphs
  9. if (document.getElementById('linebreaks').checked) {
  10. lines = h.split(/\r?\n/);
  11. if (lines.length > 1) {
  12. h = '';
  13. tinymce.each(lines, function(row) {
  14. h += '<p>' + row + '</p>';
  15. });
  16. }
  17. }
  18. tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, {content : h});
  19. tinyMCEPopup.close();
  20. },
  21. resize : function() {
  22. var vp = tinyMCEPopup.dom.getViewPort(window), el;
  23. el = document.getElementById('content');
  24. el.style.width = (vp.w - 20) + 'px';
  25. el.style.height = (vp.h - 90) + 'px';
  26. }
  27. };
  28. tinyMCEPopup.onInit.add(PasteTextDialog.init, PasteTextDialog);