Javascript wysihtml5文本区域大小调整
我使用的是wysihtml5编辑器,简单的编辑器示例Javascript wysihtml5文本区域大小调整,javascript,html,editor,wysiwyg,Javascript,Html,Editor,Wysiwyg,我使用的是wysihtml5编辑器,简单的编辑器示例 http://xing.github.io/wysihtml5/examples/simple.html 一切都很好,除了我试图使文本区域的宽度和高度调整 如果我切换到html视图,效果会很好。我想允许文本区域在普通文本中调整大小。一旦编辑器加载,更改编辑器本身的css jQuery(document).ready(function() { $('.wysihtml5-sandbox').css("resize", "both"
http://xing.github.io/wysihtml5/examples/simple.html
一切都很好,除了我试图使文本区域的宽度和高度调整
如果我切换到html视图,效果会很好。我想允许文本区域在普通文本中调整大小。一旦编辑器加载,更改编辑器本身的css
jQuery(document).ready(function() {
$('.wysihtml5-sandbox').css("resize", "both");
}
刚刚发现这个使用wysihtml5-0.3.0.js的简单解决方案
<style>
textarea { ... min-height:500px; }
</style>
<textarea><?php echo $doc2edit; ?></textarea>
<script>
window.onload = function() {
resizeEditor(); // resize iframe containing HTML tags
}
function getElementsByClass(node,searchClass,tag) {
var classElements = new Array();
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("\\b"+searchClass+"\\b");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
} } return classElements;
}
function resizeEditor(){
// resize elem with class 'wysihtml5-sandbox'
var el = getElementsByClass(document,'wysihtml5-sandbox','*');
for (i = 0; i < el.length; i++) {
el[i].style.height = (editor.composer.commands.doc.body.clientHeight+20)+"px";
}
}
</script>
解决方案是调整wysihtml5编辑器创建的大小。
BOX_FORMATTING = [
...., "min-height"