Skip to content

Commit

Permalink
Merge pull request #55 from dmitric/master
Browse files Browse the repository at this point in the history
Wrap pasted text in p elements
  • Loading branch information
daviferreira committed Oct 8, 2013
2 parents b4d71d8 + 415d7de commit 48f49cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,16 @@ function MediumEditor(elements, options) {
}
var i,
pasteWrapper = function (e) {
var paragraphs, formattedText, p;
e.target.classList.remove('medium-editor-placeholder');
if (e.clipboardData && e.clipboardData.getData) {
e.preventDefault();
document.execCommand('insertHTML', false, e.clipboardData.getData('text/plain').replace(/[\r\n]/g, '<br>'));
paragraphs = e.clipboardData.getData('text/plain').split(/[\r\n]/g);
formattedText = "";
for (p = 0; p < paragraphs.length; p += 1) {
formattedText += "<p>" + paragraphs[p] + "</p>";
}
document.execCommand('insertHTML', false, formattedText);
}
};
for (i = 0; i < this.elements.length; i += 1) {
Expand Down
Loading

0 comments on commit 48f49cc

Please sign in to comment.