Skip to content

Commit

Permalink
Squashed 'libs/editor/' changes from b012dc8..a2a6a7c
Browse files Browse the repository at this point in the history
a2a6a7c 1.2 version bump
592ea7e Merge pull request #422 from wordpress-mobile/issue/421-clear-failed-videos
8b2453f Merge branch 'develop' into issue/421-clear-failed-videos
c5f3e9c Merge pull request #420 from wordpress-mobile/issue/409-cursor-under-media
4851a46 Merge branch 'develop' into issue/409-cursor-under-media
3a88793 Fixed matching for media at the end of posts to work on API18 and below
5850256 Add an empty paragraph after media items at the end of posts when converting from HTML

git-subtree-dir: libs/editor
git-subtree-split: a2a6a7cf311a1ff5c87dee85625d088c0ceb00b7
  • Loading branch information
maxme committed Jun 20, 2016
1 parent 1cf141b commit 49ac398
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions WordPressEditor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
buildToolsVersion "23.0.3"

defaultConfig {
versionCode 11
versionName "1.1"
versionCode 12
versionName "1.2"
minSdkVersion 16
targetSdkVersion 23
}
Expand Down
4 changes: 4 additions & 0 deletions libs/editor-common/assets/editor-utils-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Formatter.convertPToDiv = function(html) {
mutatedHTML = mutatedHTML.replace(/(<img [^<>]*>|<\/a>|<\/video>|<\/span>)<br \/>/igm,
function replaceBrWithDivs(match) { return match.substr(0, match.length - 6) + '</div><div>'; });

// Append paragraph-wrapped break tag under media at the end of a post
mutatedHTML = mutatedHTML.replace(/(<img [^<>]*>|<\/a>|<\/video>|<\/span>)[^<>]*<\/div>\s$/igm,
function replaceBrWithDivs(match) { return match + '<div><br></div>'; });

return mutatedHTML;
}

Expand Down
6 changes: 3 additions & 3 deletions libs/editor-common/assets/test/test-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function testMediaParagraphWrapping(mediaType, htmlModeMediaHtml, visualModeMedi
assert.equal('<p>' + visualModeMediaHtml + '</p>\n', visualFormattingApplied);

var convertedToDivs = formatter.convertPToDiv(visualFormattingApplied).replace(/\n/g, '');
assert.equal('<div>' + visualModeMediaHtml + '</div>', convertedToDivs);
assert.equal('<div>' + visualModeMediaHtml + '</div><div><br></div>', convertedToDivs);
});

it('with paragraphs above and below', function () {
Expand Down Expand Up @@ -106,7 +106,7 @@ function testMediaParagraphWrapping(mediaType, htmlModeMediaHtml, visualModeMedi
assert.equal('<p>Line 1</p>\n<p>' + visualModeMediaHtml + '</p>\n', visualFormattingApplied);

var convertedToDivs = formatter.convertPToDiv(visualFormattingApplied).replace(/\n/g, '');
assert.equal('<div>Line 1</div><div>' + visualModeMediaHtml + '</div>', convertedToDivs);
assert.equal('<div>Line 1</div><div>' + visualModeMediaHtml + '</div><div><br></div>', convertedToDivs);
});

it('end of post, with line break above', function () {
Expand All @@ -116,7 +116,7 @@ function testMediaParagraphWrapping(mediaType, htmlModeMediaHtml, visualModeMedi
assert.equal('<p>Line 1<br \/>\n' + visualModeMediaHtml + '</p>\n', visualFormattingApplied);

var convertedToDivs = formatter.convertPToDiv(visualFormattingApplied).replace(/\n/g, '');
assert.equal('<div>Line 1</div><div>' + visualModeMediaHtml + '</div>', convertedToDivs);
assert.equal('<div>Line 1</div><div>' + visualModeMediaHtml + '</div><div><br></div>', convertedToDivs);
});
});
}

0 comments on commit 49ac398

Please sign in to comment.