我正在使用活动管理员和active admin froala editor创建一个Rails站点。
在制作博客,在管理面板中添加富文本编辑器并在我的博客上很好地显示,效果非常好。
但是,我的博客部分是技术性的,我想在其中添加一些代码以显示一些示例。我想到的一个选择是,仅使用github gists嵌入代码示例。
问题是发生这种情况时,是编辑器转义了script
标记,并将其作为文本插入。我不认为这是rails方面的问题(所有文本都显示为.html_safe
),并且位于froala上。
我当前的活动管理员表单设置如下
form do |f|
f.inputs do
f.input :title
f.input :image_link
f.input :published, as: :boolean
f.input :category_id, :as => :select, :collection => Category.all.map {|c| ["#{c.display_name}", c.id]}
f.input :body, as: :froala_editor, input_html: {data: {options: {htmlExecuteScripts: true, htmlRemoveTags: []} } }
f.input :admin_user_id, input_html: { value: current_admin_user.id }, as: :hidden
end
f.button 'Submit Post'
end
在阅读the froala docs时,看来我想要的选项可能是 htmlExecuteScripts
或htmlRemoveTags
,但这没有用。脚本输出的html仍显示字符串转义序列。
任何人都知道如何将可嵌入脚本添加到活动admin Froala编辑器中吗?任何帮助深表感谢。