Commontator with Trix
Good day robots,
I'm trying to implement the Trix editor as the default editor for Commontator's comments.
The default Commontator view is defined as follows in app\views\commontator\comments\_form.html.erb
:
<%= form_for([commontator, thread, comment],
remote: !no_remote) do |f| %>
<div class="comment_form_field">
<%= f.text_area :body, rows: '7' %>
<%= javascript_tag('Commontator.initMentions()') if Commontator.mentions_enabled %>
</div>
<% end %>
So I get that I need to replace that text_area
for the Trix default tag: <trix-editor input="???"></trix-editor>
not sure what to put into the input parameter.
The generated HTML for the above form_for
is as follows;
<form class="new_comment" id="new_comment" action="/commontator/threads/1/comments" accept-charset="UTF-8" data-remote="true" method="post">
<div class="comment_form_field">
<div class="field_with_errors">
<textarea rows="7" name="comment[body]" id="comment_body" spellcheck="false"></textarea>
</div>
</div>
<div class="comment_form_actions">
<input type="submit" name="commit" value="Post Comment" data-disable-with="Post Comment">
<input type="submit" name="cancel" value="Cancel" data-disable-with="Cancel">
</div>
</form>
Any ideas? cheers!
I should feel ashamed of myself but I'm gonna go ahead and confess that I should have tried a bit harder.
I changed the text_area
to hidden_field
and added <trix-editor input="comment_body"></trix-editor>
commentbody being the same id as the now hidden field.