From 1ec5d7d681d91b9a22f025e4964bf11eb41f287f Mon Sep 17 00:00:00 2001 From: Harriet H-W Date: Fri, 22 Nov 2024 17:23:00 +0000 Subject: [PATCH] wip style blocks --- .../services/content_block_manager/get_preview_content.rb | 8 ++++++-- .../test/unit/app/services/get_preview_content_test.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/engines/content_block_manager/app/services/content_block_manager/get_preview_content.rb b/lib/engines/content_block_manager/app/services/content_block_manager/get_preview_content.rb index 572b70486ca..6aadac22954 100644 --- a/lib/engines/content_block_manager/app/services/content_block_manager/get_preview_content.rb +++ b/lib/engines/content_block_manager/app/services/content_block_manager/get_preview_content.rb @@ -44,13 +44,17 @@ def preview_html end def replace_existing_content_blocks(nokogiri_html) - existing_content_block_spans(nokogiri_html).each do |span| + content_block_spans(nokogiri_html).each do |span| span.replace @content_block_edition.render end + # TODO: how to style the blocks, if at all? + content_block_spans(nokogiri_html).each do |span| + span["style"] = "background-color: yellow;" + end nokogiri_html end - def existing_content_block_spans(nokogiri_html) + def content_block_spans(nokogiri_html) nokogiri_html.css("span[data-content-id=\"#{@content_block_edition.document.content_id}\"]") end end diff --git a/lib/engines/content_block_manager/test/unit/app/services/get_preview_content_test.rb b/lib/engines/content_block_manager/test/unit/app/services/get_preview_content_test.rb index 00194f07a8d..db7be1e8b9b 100644 --- a/lib/engines/content_block_manager/test/unit/app/services/get_preview_content_test.rb +++ b/lib/engines/content_block_manager/test/unit/app/services/get_preview_content_test.rb @@ -13,7 +13,7 @@ class ContentBlockManager::GetPreviewContentTest < ActiveSupport::TestCase "

test

example@example.com" end let(:expected_html) do - "

test

new@new.com" + "

test

new@new.com" end let(:document) do build(:content_block_document, :email_address, content_id: preview_content_id)