2014-10-20 94 views
1

我在粘貼到Froala時遇到了一些麻煩。我有一個自定義代碼按鈕,增加了<pre><code>Code here</code></pre>標籤:Froala編輯器在粘貼代碼時保持縮進

$('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(); 
      } 
     } 
    } 
}); 

我希望能夠代碼粘貼到編輯器中刪除的造型,但保留換行符和縮進。與SO類似,與CNTL+K相似。這可能嗎?

回答

相關問題