92 lines
4.3 KiB
Plaintext
92 lines
4.3 KiB
Plaintext
<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %>
|
||
<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %>
|
||
<style>
|
||
.CodeMirror-scroll{
|
||
overflow: auto !important;
|
||
margin-bottom: -30px;
|
||
margin-right: -30px;
|
||
padding-bottom: 30px;
|
||
height: 100%;
|
||
outline: none;
|
||
position: relative;
|
||
}
|
||
</style>
|
||
<div id="shixun_form">
|
||
<li class="clearfix" style="line-height:1.9;">
|
||
<label class=" panel-form-label fl"> 参考答案:</label>
|
||
<div id="challenge_answer" class="new_li">
|
||
<textarea name="challenge[answer]"><%= @challenge.answer %></textarea>
|
||
</div>
|
||
<p id="e_tip_in" style="margin-left: 10%" class="c_grey"></p>
|
||
<p id="e_tips_in" style="margin-left: 10%" class="c_grey"></p>
|
||
</li>
|
||
<li class="clearfix">
|
||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" onclick="$('#challenge_shixun_answer_update').submit();">保存</a>
|
||
<% if @challenge.answer %>
|
||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 3) %>" class="task-btn fr mr10" id="answer_cancel">取消</a>
|
||
<% end %>
|
||
</li>
|
||
</div>
|
||
<script>
|
||
answer_editormd = editormd("challenge_answer", {
|
||
width : "89.6%",
|
||
height : 600,
|
||
syncScrolling : "single",
|
||
//你的lib目录的路径,我这边用JSP做测试的
|
||
path : "/editormd/lib/",
|
||
tex : true,
|
||
autoFocus: false,
|
||
toolbarIcons : function() {
|
||
// Or return editormd.toolbarModes[name]; // full, simple, mini
|
||
// Using "||" set icons align right.
|
||
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ]
|
||
},
|
||
toolbarCustomIcons : {
|
||
testIcon : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
|
||
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
|
||
},
|
||
//这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。
|
||
saveHTMLToTextarea : true,
|
||
// 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标
|
||
dialogMaskOpacity : 0.6,
|
||
placeholder: "<%= @st == 0 ? '' : "请输入各个选项的具体解析或其他相关信息" %>",
|
||
imageUpload : true,
|
||
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
|
||
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url
|
||
});
|
||
window.onload = function(){
|
||
$("#challenge_answer [type=\"latex\"]").bind("click", function(){
|
||
answer_editormd.cm.replaceSelection("```latex");
|
||
answer_editormd.cm.replaceSelection("\n");
|
||
answer_editormd.cm.replaceSelection("\n");
|
||
answer_editormd.cm.replaceSelection("```");
|
||
var __Cursor = answer_editormd.cm.getDoc().getCursor();
|
||
answer_editormd.cm.setCursor(__Cursor.line-1, 0);
|
||
});
|
||
|
||
$("#challenge_answer [type=\"inline\"]").bind("click", function(){
|
||
answer_editormd.cm.replaceSelection("$$$$");
|
||
var __Cursor = answer_editormd.cm.getDoc().getCursor();
|
||
answer_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
|
||
answer_editormd.cm.focus();
|
||
});
|
||
$("[type=\"inline\"]").attr("title", "行内公式");
|
||
$("[type=\"latex\"]").attr("title", "多行公式");
|
||
|
||
// 实训简介自动保存
|
||
md_elocalStorage(answer_editormd, "challenge_in_<%= User.current.id %>", "in");
|
||
};
|
||
// md恢复上次数据
|
||
function md_rec_data(k,mdu,id){
|
||
console.log(k);
|
||
if(window.sessionStorage.getItem(k+mdu) !== null){
|
||
answer_editormd.setValue(window.sessionStorage.getItem(k+mdu));
|
||
md_clear_data(k,mdu,id);
|
||
}
|
||
}
|
||
|
||
/* $("#answer_cancel").click(function(){
|
||
$("#answer_edit").hide();
|
||
$("#edit_answer_show").show();
|
||
})*/
|
||
</script> |