From 49ac39827552c17c8d5b65eca236a55961cf6814 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Mon, 20 Jun 2016 17:14:14 +0200 Subject: [PATCH] Squashed 'libs/editor/' changes from b012dc8..a2a6a7c 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 --- WordPressEditor/build.gradle | 4 ++-- libs/editor-common/assets/editor-utils-formatter.js | 4 ++++ libs/editor-common/assets/test/test-formatter.js | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/WordPressEditor/build.gradle b/WordPressEditor/build.gradle index 66cd22622146..7a9d367b73df 100644 --- a/WordPressEditor/build.gradle +++ b/WordPressEditor/build.gradle @@ -22,8 +22,8 @@ android { buildToolsVersion "23.0.3" defaultConfig { - versionCode 11 - versionName "1.1" + versionCode 12 + versionName "1.2" minSdkVersion 16 targetSdkVersion 23 } diff --git a/libs/editor-common/assets/editor-utils-formatter.js b/libs/editor-common/assets/editor-utils-formatter.js index dc4f67764c57..d235aec985d0 100644 --- a/libs/editor-common/assets/editor-utils-formatter.js +++ b/libs/editor-common/assets/editor-utils-formatter.js @@ -22,6 +22,10 @@ Formatter.convertPToDiv = function(html) { mutatedHTML = mutatedHTML.replace(/(]*>|<\/a>|<\/video>|<\/span>)
/igm, function replaceBrWithDivs(match) { return match.substr(0, match.length - 6) + '
'; }); + // Append paragraph-wrapped break tag under media at the end of a post + mutatedHTML = mutatedHTML.replace(/(]*>|<\/a>|<\/video>|<\/span>)[^<>]*<\/div>\s$/igm, + function replaceBrWithDivs(match) { return match + '

'; }); + return mutatedHTML; } diff --git a/libs/editor-common/assets/test/test-formatter.js b/libs/editor-common/assets/test/test-formatter.js index 3bdc8a35f5f9..a59e61ec0f4d 100644 --- a/libs/editor-common/assets/test/test-formatter.js +++ b/libs/editor-common/assets/test/test-formatter.js @@ -56,7 +56,7 @@ function testMediaParagraphWrapping(mediaType, htmlModeMediaHtml, visualModeMedi assert.equal('

' + visualModeMediaHtml + '

\n', visualFormattingApplied); var convertedToDivs = formatter.convertPToDiv(visualFormattingApplied).replace(/\n/g, ''); - assert.equal('
' + visualModeMediaHtml + '
', convertedToDivs); + assert.equal('
' + visualModeMediaHtml + '

', convertedToDivs); }); it('with paragraphs above and below', function () { @@ -106,7 +106,7 @@ function testMediaParagraphWrapping(mediaType, htmlModeMediaHtml, visualModeMedi assert.equal('

Line 1

\n

' + visualModeMediaHtml + '

\n', visualFormattingApplied); var convertedToDivs = formatter.convertPToDiv(visualFormattingApplied).replace(/\n/g, ''); - assert.equal('
Line 1
' + visualModeMediaHtml + '
', convertedToDivs); + assert.equal('
Line 1
' + visualModeMediaHtml + '

', convertedToDivs); }); it('end of post, with line break above', function () { @@ -116,7 +116,7 @@ function testMediaParagraphWrapping(mediaType, htmlModeMediaHtml, visualModeMedi assert.equal('

Line 1
\n' + visualModeMediaHtml + '

\n', visualFormattingApplied); var convertedToDivs = formatter.convertPToDiv(visualFormattingApplied).replace(/\n/g, ''); - assert.equal('
Line 1
' + visualModeMediaHtml + '
', convertedToDivs); + assert.equal('
Line 1
' + visualModeMediaHtml + '

', convertedToDivs); }); }); }