1

TinyMCE でカスタムの大文字タグを使用できるようにする方法を知っている人はいますか? TinyMCE は、大文字のタグが有効であると宣言されているにもかかわらず、大文字のタグを好まないようです。ここに私の TinyMCE 設定があります:

tinyMCE.init({
    mode: "specific_textareas",
    theme: "advanced",
    language: "en",
    theme_advanced_toolbar_location: "top",
    theme_advanced_toolbar_align: "left",
    theme_advanced_statusbar_location: "bottom",
    theme_advanced_buttons1: "bold,italic,|,sub,sup,|,charmap,|,table,|,code",
    theme_advanced_path: false,
    theme_advanced_resizing: true,
    plugins: "fullscreen,paste,table",
    paste_auto_cleanup_on_paste : true,
    relative_urls: false,
    width: "300",
    height: "300",
    theme_advanced_resizing_min_height : "10",
    force_br_newlines : true,
    force_p_newlines : false,
    forced_root_block : '',
    entity_encoding: "raw",
    valid_elements : "B/strong,I/em,SUP/sup,SUB/sub",
    extended_valid_elements: "CUSTOM"
})

次のようなタイプ

<CUSTOM>this is a custom tag</CUSTOM>

<CUSTOM> が削除されるため、機能しません。

init スクリプトを に変更すると、正常にextended_valid_elements: "custom"動作します - 入力できます

<custom>this is a custom tag</custom>

<custom は保持されます。

誰も回避策を知りませんか?

ありがとう!

4

1 に答える 1

1

これを行う方法の説明は次のとおりです(逆も同様に機能します):http://www.codingforums.com/archive/index.php/t-148450.html

tinymce onInit イベントを使用し、タグを大文字に戻すには onSubmit または onSave を使用する必要があります (または、コードの他の適切な場所にコンテンツを送信する前に、コンテンツを元に戻すこともできます)。このハンドラーを追加するには、tinymce セットアップ構成パラメーターを使用します。

setup : function(ed) {

    ed.onInit.add(function(ed, evt) {
        $(ed.getBody()).find('p').addClass('headline');

        // get content from editor source html element
        var content = $(ed.id).html();

        // tagname to lowercase
        content = content.replace(/< *\/?(\w+)/g,function(w){return w.toLowerCase()});

        ed.setContent(content);
    });

    ed.onSubmit.add(function(ed, evt) {
        $(ed.getBody()).find('p').addClass('headline');

        // get content from edito
        var content = ed.getContent();

        // tagname to toUpperCase
        content = content.replace(/< *\/?(\w+)/g,function(w){return w.toUpperCase()});

        // write content to html source element (usually a textarea)
        $(ed.id).html(content );
    });
},
于 2012-07-06T09:20:33.487 に答える