JQTE エディターのデフォルトの高さを変更するにはどうすればよいですか?
私はもう試した:
$("textarea").jqte({
height:"400px"
});
ドキュメントはこれについて何も述べていません。
jqte スタイルシートで jqte_editor の min-height 値を変更してみてください。
/* editor area */
.jqte_editor, .jqte_source {
min-height:300px;
}
エディターの高さをロックして、エディターが拡大する代わりにスクロールバーが表示されるようにするには、.jqte_editor
height
またはを設定する必要がありますmin-height
。も設定する必要がありますmax-height
。
次に何が起こるかは、jqte のバグです。
.jqte_editor
その下にあるすべての要素 (テキスト) をさらに下に押し込みます修正 (jqte バージョン 1.4.0)
JavaScript ファイルを開きますjquery-te-1.4.0.js
。
検索して見つけるfunction affectStyleAround(element,style)
交換:
if(selectedTag && style==false)
{
// apply to the selected node with parent tag's styles
if(selectedTag.parent().is("[style]"))
selectedTag.attr("style",selectedTag.parent().attr("style"));
// apply to child tags with parent tag's styles
if(selectedTag.is("[style]"))
selectedTag.find("*").attr("style",selectedTag.attr("style"));
}
これとともに:
if(selectedTag && style==false)
{
// apply to the selected node with parent tag's styles
if(selectedTag.parent().is("[style]") && !selectedTag.parent().is(".jqte_editor"))
selectedTag.attr("style",selectedTag.parent().attr("style"));
// apply to child tags with parent tag's styles
if(selectedTag.is("[style]") && !selectedTag.parent().is(".jqte_editor"))
selectedTag.find("*").attr("style",selectedTag.attr("style"));
}
追加されたコードに注意してください。
&& !selectedTag.parent().is(".jqte_editor")
幸運を!
オプションはありませんが、これを行うことができます:
$("textarea").css('min-height','400px').jqte();
これにより、高さが自動的に最小値に設定されます400px
これがTHEソリューションです。このソリューションをよりよく確認するには、非最小バージョンに移動してください。コンポーネントの高さを制御するために完全に挿入される起動オプションとして「高さ」を渡すことができるように、少量のコードを追加しました。
バージョン 1.4.0 の 215 行目に、次の変更を追加します。
<div class="'+vars.css+"_editor"+'" style="height:'+vars.height+';"></div>
次のコードを追加しています。
style="height:'+vars.height+';"
次に、次のように {height:'500px'} をコードに渡します。
$(".myCustomTextField").jqte({'height': '500px'});
終わり!
VKS によって提案されたパッチを適用しました (わずかな変更を加えて、彼の回答に関する私のコメントを参照してください)。
このようなものを使用して、元のテキストエリアの「行」属性を使用して編集領域の高さを計算しようとします (VKS のパッチがないと、これは恐ろしい問題を引き起こします)。
var $areas = $("textarea.html-editor");
$areas.each(function (index, textarea) {
var $area = $(textarea);
$area.jqte();
var $editor = $area.closest(".jqte").find(".jqte_editor");
var height = ($area.attr("rows") * 25 / 15) + "em";
$editor.css({ "min-height": height, "max-height": height });
});
(その計算行* 25/15は、「em」を使用した私の特定のケースでたまたま機能するものです-独自の計算を使用する必要があります。たとえば、目的のフォントでスパンの「px」の高さを測定するなど、多くの解決策があります等。)