1

Froala への貼り付けに問題があります。<pre><code>Code here</code></pre>タグを追加するカスタム コード ボタンがあります。

$('textarea[name="description"]').editable({
    customButtons: {
        insertCode: {
            title: 'Insert code',
            icon: {
                type: 'font',
                value: 'fa fa-code'
            },
            callback: function() {
                if (!this.selectionInEditor()) {
                    this.$element.focus(); // Focus on editor if it's not.
                }

                var html = '<pre><code>' + (this.text() || '&#8203;') + '</code></pre>';

                this.insertHTML(html);
                this.saveUndoStep();
            }
        }
    }
});

コードをエディターに貼り付け、スタイリングを削除し、改行とインデントを維持できるようにしたいと考えています。here on SO with と同様CNTL+Kです。これは可能ですか?

4

1 に答える 1

0

this.text()選択したテキストではなく、選択した HTML を取得するものに置き換える必要があります。Froala WYSIWYG エディターにはそのようなメカニズムはありませんが、Get Selected HTML in browser via Javascriptの質問の回答を使用できます。

于 2014-10-23T11:39:41.257 に答える