对于 bootstrap-wysihtml5 使用以下函数:
<script>
$(function () {
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
// CKEDITOR.replace('editor1');
//bootstrap WYSIHTML5 - text editor
$(".textarea").wysihtml5();
});
function injectString(str){
var sel=frames[0].getSelection();
var nd=sel.anchorNode;
var txt=nd.data+'';
var pos=sel.anchorOffset||0;
sel.anchorNode.data=txt.slice(0,pos)+str+txt.slice(pos);
}</script>
像这样使用
<button id="name" data-wysihtml5-command="foreFrac" onclick="injectString('{name}')" type="button" class="btn btn-block btn-success btn-lg">Name </button>