我正在尝试在表单中添加一些简单的 WYSIWYG 字段。最初编辑器工作得很好,但在某个地方我丢失了工具栏。我认为原始代码不知何故被团队中的其他成员覆盖,但我不知道,而且我对 Git 不太满意,无法回去检查。
这是在 edit_content.html.erb
<div id="edit_form">
<fieldset>
<span><legend><%= @category.title.capitalize %> Content</legend></span>
<div class="field">
<%= f.label :statement %> <br />
<%= f.text_area :statement, rows: 10, cols: 80, :class=>'redactor_text' %>
</div>
<div class="field">
<%= f.label :quote %> <br />
<%= f.text_area :quote, row: 10, cols: 80, :class=>'redactor_text' %>
</div>
</fieldset>
</div>
这是在 assets\javascripts\redactor-rails\config.js
$('.redactor').redactor(
{ "imageUpload":"/redactor_rails/pictures?" + params,
"imageGetJson":"/redactor_rails/pictures",
"fileUpload":"/redactor_rails/documents?" + params,
"fileGetJson":"/redactor_rails/documents",
"path":"/assets/redactor-rails",
"css":"style.css"
});
$('.redactor_text').redactor(
{ buttons: ["html", "|", "formatting", "|", "bold", "italic", "underline", "deleted", "|",
"unorderedlist", "orderedlist", "outdent", "indent", "|", "image", "video", "file", "link", "table", "|",
"fontcolor", "backcolor", "|", "alignment", "|", "horizontalrule"]
});
我最初选择 redactor 是因为我听说它可以与回形针一起使用,并且我想稍后使用该功能,因此非常感谢您对此事的任何帮助!