Skip to content

Commit

Permalink
wip style blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Harriethw committed Nov 25, 2024
1 parent f6a54d1 commit 1ec5d7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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|

Check failure on line 51 in lib/engines/content_block_manager/app/services/content_block_manager/get_preview_content.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/CombinableLoops: Combine this loop with the previous loop.
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ContentBlockManager::GetPreviewContentTest < ActiveSupport::TestCase
"<body><p>test</p><span class=\"content-embed content-embed__content_block_email_address\" data-content-block=\"\" data-document-type=\"content_block_email_address\" data-content-id=\"#{preview_content_id}\">example@example.com</span></body>"
end
let(:expected_html) do
"<body><p>test</p><span class=\"content-embed content-embed__content_block_email_address\" data-content-block=\"\" data-document-type=\"content_block_email_address\" data-content-id=\"#{preview_content_id}\">new@new.com</span></body>"
"<body><p>test</p><span class=\"content-embed content-embed__content_block_email_address\" data-content-block=\"\" data-document-type=\"content_block_email_address\" data-content-id=\"#{preview_content_id}\" style=\"background-color: yellow;\">new@new.com</span></body>"
end
let(:document) do
build(:content_block_document, :email_address, content_id: preview_content_id)
Expand Down

0 comments on commit 1ec5d7d

Please sign in to comment.