From fb29800c7d33a84cea57f7bf63212a35c6432158 Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 28 Dec 2016 19:30:52 -0500 Subject: [PATCH 1/2] - Replaces line breaks with empty paragraphs --- lib/Newsletter/Editor/StructureTransformer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Newsletter/Editor/StructureTransformer.php b/lib/Newsletter/Editor/StructureTransformer.php index 6b526d18ec..e7da01aaf9 100644 --- a/lib/Newsletter/Editor/StructureTransformer.php +++ b/lib/Newsletter/Editor/StructureTransformer.php @@ -72,7 +72,9 @@ class StructureTransformer { } else { return array( 'type' => 'text', - 'text' => $item->toString(), + 'text' => ($item->getNextSibling()) ? + preg_replace('/\n/', "

 

", $item->toString()) : + $item->toString() ); } From 698cdecbfea44d842cb1d1d99f41b98e5580597b Mon Sep 17 00:00:00 2001 From: Vlad Date: Thu, 29 Dec 2016 13:29:08 -0500 Subject: [PATCH 2/2] - Conditionally keeps margin/padding for ALC posts inside editor - Adds line breaks for ALC posts in the renderer --- .../css/src/newsletter_editor/contentBlocks/base.styl | 10 ++++++++-- lib/Newsletter/Editor/PostContentManager.php | 5 +++-- lib/Newsletter/Editor/StructureTransformer.php | 4 +--- lib/Newsletter/Renderer/Blocks/Text.php | 10 +++++++++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/assets/css/src/newsletter_editor/contentBlocks/base.styl b/assets/css/src/newsletter_editor/contentBlocks/base.styl index 2a37615fc3..9ebbcd6f90 100644 --- a/assets/css/src/newsletter_editor/contentBlocks/base.styl +++ b/assets/css/src/newsletter_editor/contentBlocks/base.styl @@ -34,7 +34,7 @@ $block-text-line-height = $text-line-height position: relative line-height: $block-text-line-height - p, h1, h2, h3, h4, h5, h6 + h1, h2, h3, h4, h5, h6 line-height: $block-text-line-height padding: 0 margin: 0 @@ -44,9 +44,15 @@ $block-text-line-height = $text-line-height h1, h2, h3, h4, h5, h6 margin-bottom: 0.3em - p + p:not(.mailpoet_wp_post) margin-top: 0 margin-bottom: 0 + padding: 0 + margin: 0 + + p + line-height: $block-text-line-height + font-style: normal font-weight: normal ul diff --git a/lib/Newsletter/Editor/PostContentManager.php b/lib/Newsletter/Editor/PostContentManager.php index 82e618e99c..655c2ba80c 100644 --- a/lib/Newsletter/Editor/PostContentManager.php +++ b/lib/Newsletter/Editor/PostContentManager.php @@ -6,6 +6,7 @@ if(!defined('ABSPATH')) exit; class PostContentManager { const MAX_EXCERPT_LENGTH = 60; + const WP_POST_CLASS = 'mailpoet_wp_post'; function getContent($post, $displayType) { if($displayType === 'titleOnly') { @@ -42,7 +43,7 @@ class PostContentManager { '

', '

', '', '
    ', '
      ', '
    1. ', '
      ' ); $content = strip_tags($content, implode('', $tags_not_being_stripped)); - $content = wpautop($content); + $content = str_replace(' 'text', - 'text' => ($item->getNextSibling()) ? - preg_replace('/\n/', "

       

      ", $item->toString()) : - $item->toString() + 'text' => $item->toString() ); } diff --git a/lib/Newsletter/Renderer/Blocks/Text.php b/lib/Newsletter/Renderer/Blocks/Text.php index 1543999147..931c51d891 100644 --- a/lib/Newsletter/Renderer/Blocks/Text.php +++ b/lib/Newsletter/Renderer/Blocks/Text.php @@ -1,6 +1,7 @@
      ' : ''; // if this element is followed by a list, add single line break - $line_breaks = ($next_element && preg_match('/
    2. /i', $next_element->text())) ? + $line_breaks = ($next_element && preg_match('/
    3. getOuterText())) ? '
      ' : $line_breaks; + if($paragraph->hasClass(PostContentManager::WP_POST_CLASS)) { + $paragraph->removeClass(PostContentManager::WP_POST_CLASS); + // if this element is followed by a paragraph, add double line breaks + $line_breaks = ($next_element && preg_match('/

      getOuterText())) ? + '

      ' : + $line_breaks; + } $paragraph->html('