2012-11-27 52 views
1

對於我的Bootstrap網站,我想使用wysihtml 5 editor。但是那個默認不支持超/下標。bootstrap wysithml5帶下標和上標

此行中我添加編輯:

<a class='btn' data-wysihtml5-command='superscript'>superscript</a> 

下面的代碼是wysihtml5編輯的引導源的一部分:

dom.delegate(container, "[data-wysihtml5-command]", "click", function(event) { var link = this, command = link.getAttribute("data-wysihtml5-command"), commandValue = link.getAttribute("data-wysihtml5-command-value"); that.execCommand(command, commandValue); event.preventDefault(); });

它通過做工作的一切默認,但不適用於上標和下標。

谷歌給了我結果,我不得不使用execCommand與commandValue設置爲false,但也沒有工作。

有人知道如何去做它的工作,它增加了/代碼?

回答

3

下面的代碼添加到源https://github.com/xing/wysihtml5/blob/master/dist/wysihtml5-0.3.0.js

改性wysihtm5與SUP和子

從源

(function (wysihtml5) { 
    var undef; 

    wysihtml5.commands.sub = { 
     exec: function (composer, command) { 
      return wysihtml5.commands.formatInline.exec(composer, command, "sub"); 
     }, 

     state: function (composer, command, color) { 
      // element.ownerDocument.queryCommandState("bold") results: 
      // firefox: only <b> 
      // chrome: <b>, <strong>, <h1>, <h2>, ... 
      // ie:  <b>, <strong> 
      // opera: <b>, <strong> 
      return wysihtml5.commands.formatInline.state(composer, command, "sub"); 
     }, 

     value: function() { 
      return undef; 
     } 
    }; 
})(wysihtml5); 
(function (wysihtml5) { 
    var undef; 

    wysihtml5.commands.sup = { 
     exec: function (composer, command) { 
      return wysihtml5.commands.formatInline.exec(composer, command, "sup"); 
     }, 

     state: function (composer, command, color) { 
      // element.ownerDocument.queryCommandState("bold") results: 
      // firefox: only <b> 
      // chrome: <b>, <strong>, <h1>, <h2>, ... 
      // ie:  <b>, <strong> 
      // opera: <b>, <strong> 
      return wysihtml5.commands.formatInline.state(composer, command, "sup"); 
     }, 

     value: function() { 
      return undef; 
     } 
    }; 
})(wysihtml5); 

和後線6876後來自源的7291行

"sub": "sub", 
    "sup": "sup" 

和從源極線8441後

"83": "sub", // S 
    "80": "sup" // P