diff --git a/app/assets/stylesheets/admin/styles.sass b/app/assets/stylesheets/admin/styles.sass index 87493f3e224957452650506c2a787f669c4c23c6..5a4ddc5e0c54bac3c3b08cfce911ce293a2e9b8b 100644 --- a/app/assets/stylesheets/admin/styles.sass +++ b/app/assets/stylesheets/admin/styles.sass @@ -31,3 +31,8 @@ h1 padding-right: 2.5rem .nav-link--last padding-right: 0 + +.img-circle + aspect-ratio: 1/1 + object-fit: cover + width: 100% \ No newline at end of file diff --git a/app/views/admin/communication/blocks/edit.html.erb b/app/views/admin/communication/blocks/edit.html.erb index 369de66431643ce73a1599f3b922ec87eb536b64..35011324ffa923699901bb0df618712f38a9c72e 100644 --- a/app/views/admin/communication/blocks/edit.html.erb +++ b/app/views/admin/communication/blocks/edit.html.erb @@ -1,6 +1,7 @@ <% content_for :title, @block %> <% @block.data = {} if @block.data.nil? || @block.data.blank? +# Default elements array to move outside : it is only required when block type has an elements list @block.data['elements'] ||= [] %> <div id="app" v-cloak> @@ -67,8 +68,31 @@ }, getImageUrl(data) { return this.getFileUrl(data.signed_id, data.filename); + }, + handleSummernote() { + $(this.$refs.summernoteInput).summernote({ + toolbar: [ + ['font', ['bold', 'italic']], + ['insert', ['link']], + ['view', ['codeview']] + ], + callbacks: { + onChange: function(contents, $editable) { + this.$refs.summernoteInput.value = contents; + this.$refs.summernoteInput.dispatchEvent(new Event('input')); + }.bind(this) + } + }); + } + }, + mounted: function() { + if (this.$refs.summernoteInput) { + this.handleSummernote(); } } }); - app.mount('#app') + + window.addEventListener('load', function(){ + app.mount('#app') + }); </script> diff --git a/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb b/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb index d9dd8648ef784e546f8c6b5e204a1d1a0563c700..aec413429bb7c8cfea0c25a043144aa9af7b4e59 100644 --- a/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb @@ -4,10 +4,13 @@ for="text"> <%= t '.text_label' %> </label> - <textarea id="text" + <div class="summernote"> + <textarea id="text" class="form-control" v-model="data.text" + ref="summernoteInput" + data-summernote-config="mini" placeholder="<%= t '.text_placeholder' %>"></textarea> - + </div> </div> </div> diff --git a/app/views/admin/communication/blocks/templates/chapter/_show.html.erb b/app/views/admin/communication/blocks/templates/chapter/_show.html.erb index 0de9bf6680a69cf4a677e6ce8f5de2e59785d817..8749cc2ce162364937c84e6818eb232a329d1699 100644 --- a/app/views/admin/communication/blocks/templates/chapter/_show.html.erb +++ b/app/views/admin/communication/blocks/templates/chapter/_show.html.erb @@ -1 +1 @@ -<%= @block.data['text'] %> +<%= @block.data['text'].html_safe %> diff --git a/app/views/admin/communication/blocks/templates/testimonials/_show.html.erb b/app/views/admin/communication/blocks/templates/testimonials/_show.html.erb index 584a79f9eeaa5a118eacd7cd4de28f41323c3476..e44bebd934fc4dbd52039ae4e156e8d9a2e7b77b 100644 --- a/app/views/admin/communication/blocks/templates/testimonials/_show.html.erb +++ b/app/views/admin/communication/blocks/templates/testimonials/_show.html.erb @@ -11,8 +11,8 @@ <% photo = testimonial.dig('photo', 'id') %> <% unless photo.blank? %> <% blob = ActiveStorage::Blob.find photo %> - <div style="max-width: 80px" class="me-3"> - <%= kamifusen_tag blob, width: 80, class: 'img-fluid rounded-circle' %> + <div style="max-width: 80px;" class="me-3"> + <%= kamifusen_tag blob, width: 80, class: 'img-fluid rounded-circle img-circle' %> </div> <% end %> <p class="flex-fill mb-0">