1

Word文書からコピーして貼り付けると、問題なく、ほぼ正確なコピーが作成されます。

(cssの干渉を防ぐために)iframe内にコンテンツを表示すると、エディターの場合とまったく同じように表示されます。

私がこれを行う場合:

tinyMCE.execCommand("mceReplaceContent",false, $("#frameBody").contents().find("#txtBody").html());

tinyMCEウィンドウにコピーしますが、フォーマットは少し異なります。箇条書きは通常の円ではなく中空の円であり、かなりの間隔があります。

どうすればこれを修正できますか?

私は次のようにtinyMCEを作成しています:

tinyMCE.init({
        // General options
        mode : "textareas",
        theme : "advanced",
        plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,iespell,inlinepopups,insertdatetime,searchreplace,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,code,|,insertdate,inserttime,|,forecolor,backcolor",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",

        // Skin options
        skin : "o2k7",
        skin_variant : "silver",
});

<textarea name='FishBody' style='width:919px; height:600px' id='txtFishBody'></textarea>
4

3 に答える 3

2

私はそれを修正しました、それはhtmlが引っ張られていた方法の問題であったことがわかりました。

基本的に、このhtmlを保存すると:

<div>
Hello
</div>

あなたは

<div>\r\nHello\r\n<div>

私は\r\ nをに置き換えることでそれに対抗していまし<br/>たが、それは必要ではないようです-余分な<br>タグがそれを混乱させていました。\r\n空の文字列に置き換えるように変更しました。すべての問題が解決されました:)

于 2012-04-13T13:15:30.200 に答える
1

ほとんどのrteのようなtinymceエディターは、エディターのiframeに標準のcssを使用します。それが弾丸が異なって見える理由です。外観が異なるもう1つの理由は、クリーンアップ関数が無効なhtml要素と属性を削除することである可能性があります(tinymce構成設定valid_elementsvalid_childrenを詳しく調べたい場合があります)。

于 2012-04-13T09:46:36.363 に答える
0

このオプションを試すことができます

past_retain_style_properties:all-- または「colorfont-size」を含めたいものは何でも

例:役立つ場合に備えて、他のオプションがあるコードをコピーして貼り付ける

tinymce.init({
            selector: 'textarea',
            width: "100%",
            height : "250",
            encoding: "xml",
            menubar: false,
            statusbar: false,
            color_cols: "5",
            setup: function (ed) {
                ed.on('init', function () {
                    this.getDoc().body.style.fontSize = '10pt';
                    this.getDoc().body.style.fontFamily = 'Arial';
                });
            },
            theme: "modern",
            browser_spellcheck: true,
            plugins:
            [
                "table paste textcolor"
            ],
            paste_retain_style_properties: "all",
            toolbar1: "undo redo | bold italic underline strikethrough | fontsizeselect fontselect | alignleft aligncenter alignright alignjustify",
            toolbar2: "copy cut paste | bullist numlist outdent indent | forecolor backcolor | searchreplace | table"
        });

参照:https ://www.tiny.cloud/docs/plugins/paste/

于 2019-10-23T19:13:14.837 に答える