在下面的函数中,我在第 1 列短代码的末尾添加了一个“\n”字符串,但是它在 tinyMCE 可视化编辑器中没有任何效果。我期望换行符将短代码分隔到自己的行中(仅在编辑时,我不是指实时站点上已处理的短代码)。
如何在不添加实际 html<br>
或<p>
标签的情况下强制它?
function tinyMCEshortcode() {
var tagtext;
var customid = getCheckedValue(document.getElementsByName('customstyle'));
if (customid != 0 ){
tagtext = "["+ customid + "]Insert Your Text Here[/" + customid + "]";
}
if (customid != 0 && customid == 'two_columns' ){
tagtext = "["+ customid + "_1]<p>Content 1 Here</p>[/" + customid + "_1]" + "\n";
tagtext += "["+ customid + "_2]<p>Content 2 Here</p>[/" + customid + "_2]";
}
if(window.tinyMCE) {
window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, '<p>'+tagtext+'</p>');
//Peforms a clean up of the current editor HTML.
//tinyMCEPopup.editor.execCommand('mceCleanup');
//Repaints the editor. Sometimes the browser has graphic glitches.
tinyMCEPopup.editor.execCommand('mceRepaint');
tinyMCEPopup.close();
}
return;
}