diff --git a/app/assets/stylesheets/rich-text-content.css b/app/assets/stylesheets/rich-text-content.css index 5a8ba3fd7..88e4d2ae2 100644 --- a/app/assets/stylesheets/rich-text-content.css +++ b/app/assets/stylesheets/rich-text-content.css @@ -28,6 +28,10 @@ } } + p:has(+ p) { + margin: 0; + } + ol, ul { padding-inline-start: 3ch; } diff --git a/app/models/account/seeder.rb b/app/models/account/seeder.rb index 4a349b939..ff97538be 100644 --- a/app/models/account/seeder.rb +++ b/app/models/account/seeder.rb @@ -69,6 +69,7 @@ class Account::Seeder
Go back to the Board view, click the little “+” to the right of the DONE column, name the column, pick a color, then do it again.
+After that, drag this card to “DONE” or select “DONE” in the sidebar.
tags with content by inserting
s in %.2f seconds." % seconds
+ end
+
+ private
+ def suppressing_turbo_broadcasts
+ Board.suppressing_turbo_broadcasts do
+ Card.suppressing_turbo_broadcasts do
+ yield
+ end
+ end
+ end
+
+ def separate_nonblank_paragraphs
+ scanned = 0
+ fixed = 0
+ insertions = 0
+
+ action_texts_scope.find_each(**batch_options) do |rich_text|
+ next if account_id && rich_text.record.account.external_account_id != account_id
+
+ scanned += 1
+ edited = false
+
+ rich_text.body&.fragment.tap do |fragment|
+ next unless fragment
+
+ fragment.find_all("p + p").each do |node|
+ unless empty_node?(node) || empty_node?(node.previous_sibling)
+ node.add_previous_sibling empty_node_markup
+ edited = true
+ insertions += 1
+ end
+ end
+
+ if edited
+ puts " - modifying #{rich_text.record.class.name} #{rich_text.record.to_param} (account: #{rich_text.record.account.external_account_id})" unless demo_card?(rich_text.record)
+ # allow implicit touching to invalidate caches
+ rich_text.update! body: fragment.to_html
+ fixed +=1
+ end
+ end
+ end
+
+ puts "\n\Separation complete!"
+ puts " Rich texts examined: #{scanned}"
+ puts " Rich texts modified: #{fixed}"
+ puts " Paragraphs inserted: #{insertions}"
+ fixed
+ end
+
+ def action_texts_scope
+ ActionText::RichText.where(updated_at: updated_at)
+ end
+
+ def batch_options
+ { batch_size: 20, order: :desc }
+ end
+
+ def empty_node?(node)
+ node.to_html == empty_node_markup
+ end
+
+ def empty_node_markup
+ "
to replicaate previous view.
+# Run for the time range before paragraphs were not spaced
+# See https://app.fizzy.do/5986089/cards/3472
+# and https://github.com/basecamp/fizzy/pull/2107
+#
+# MUST BE RUN AFTER `decrypt!` when using ActiveRecord Encryption
+#
+# Run locally:
+# bin/rails runner script/migrations/split-sibling-paragraphs-with-p-br.rb
+#
+# Run via Kamal:
+# kamal app exec -d