From 1054c989e73029aaac65cd47a3e349482d8db6ce Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Thu, 2 Jun 2022 21:54:33 +0200
Subject: [PATCH] wip

---
 app/models/communication/block/component/base.rb           | 2 +-
 app/models/communication/block/component/image.rb          | 1 +
 app/models/communication/block/component/rich_text.rb      | 2 ++
 app/models/communication/block/component/string.rb         | 7 +++++++
 app/models/communication/block/component/text.rb           | 7 +++++++
 app/models/communication/block/template/chapter.rb         | 2 +-
 .../blocks/templates/chapter/_preview.html.erb             | 2 +-
 7 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 app/models/communication/block/component/string.rb
 create mode 100644 app/models/communication/block/component/text.rb

diff --git a/app/models/communication/block/component/base.rb b/app/models/communication/block/component/base.rb
index 683cc24fe..290e1cb2d 100644
--- a/app/models/communication/block/component/base.rb
+++ b/app/models/communication/block/component/base.rb
@@ -11,6 +11,6 @@ class Communication::Block::Component::Base
   end
 
   def data=(value)
-    @data = Osuny::Sanitizer.sanitize value, 'string'
+    @data = value
   end
 end
diff --git a/app/models/communication/block/component/image.rb b/app/models/communication/block/component/image.rb
index 1beff0ea8..f4852c559 100644
--- a/app/models/communication/block/component/image.rb
+++ b/app/models/communication/block/component/image.rb
@@ -1,2 +1,3 @@
 class Communication::Block::Component::Image < Communication::Block::Component::Base
+
 end
diff --git a/app/models/communication/block/component/rich_text.rb b/app/models/communication/block/component/rich_text.rb
index 2ba38a8ff..114d7b01a 100644
--- a/app/models/communication/block/component/rich_text.rb
+++ b/app/models/communication/block/component/rich_text.rb
@@ -1,5 +1,7 @@
 class Communication::Block::Component::RichText < Communication::Block::Component::Base
+
   def data=(value)
     @data = Osuny::Sanitizer.sanitize value, 'text'
   end
+
 end
diff --git a/app/models/communication/block/component/string.rb b/app/models/communication/block/component/string.rb
new file mode 100644
index 000000000..2d4302f3a
--- /dev/null
+++ b/app/models/communication/block/component/string.rb
@@ -0,0 +1,7 @@
+class Communication::Block::Component::String < Communication::Block::Component::Base
+
+  def data=(value)
+    @data = Osuny::Sanitizer.sanitize value, 'string'
+  end
+
+end
diff --git a/app/models/communication/block/component/text.rb b/app/models/communication/block/component/text.rb
new file mode 100644
index 000000000..a5fdf5767
--- /dev/null
+++ b/app/models/communication/block/component/text.rb
@@ -0,0 +1,7 @@
+class Communication::Block::Component::Text < Communication::Block::Component::Base
+
+  def data=(value)
+    @data = Osuny::Sanitizer.sanitize value, 'string'
+  end
+
+end
diff --git a/app/models/communication/block/template/chapter.rb b/app/models/communication/block/template/chapter.rb
index 79d29bb1e..a744759c1 100644
--- a/app/models/communication/block/template/chapter.rb
+++ b/app/models/communication/block/template/chapter.rb
@@ -1,7 +1,7 @@
 class Communication::Block::Template::Chapter < Communication::Block::Template::Base
   has_rich_text :text
   has_rich_text :notes
-  # has_image :image
+  has_image :image
 
   def build_git_dependencies
     add_dependency image&.blob
diff --git a/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb b/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb
index 4f6bb7659..79f20d919 100644
--- a/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb
+++ b/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb
@@ -1,3 +1,3 @@
-<%#= render 'admin/communication/blocks/components/image/preview', property: :image %>
+<%= render 'admin/communication/blocks/components/image/preview', property: :image %>
 <%= render 'admin/communication/blocks/components/rich_text/preview', property: :text %>
 <%= render 'admin/communication/blocks/components/rich_text/preview', property: :notes %>
-- 
GitLab