postInit
选项和 jQueryscrollTop
函数的组合应该可以解决问题。我还建议为它们插入一个占位符段落,同时滚动到底部。例如:
jQuery('.wymeditor').wymeditor({
postInit: function (wym) {
var $contents,
$p,
$blockquote = jQuery(wym._doc).find('blockquote');
// Insert a placeholder empty paragraph
// so that users will be encouraged to not type inside the blockquote
$blockquote.after("<p>");
// Scroll the iframe to the bottom
$contents = $(wym._iframe).contents();
$contents.scrollTop($contents.height());
// Move the selection to the paragraph
$(wym._iframe).focus();
$p = jQuery(wym._doc).find('p');
var sel = rangy.getIframeSelection(wym._iframe),
range = rangy.createRange(wym._doc);
range.setStart($p[0], 0);
range.setEnd($p[0], 0);
range.collapse(true);
sel.setSingleRange(range);
if (jQuery.browser.msie) {
wym.saveCaret();
}
}
});