1

Bootstrap の Web サイトでは、wysihtml 5 エディターを使用したいと考えています。しかし、それはデフォルトで上付き/下付きをサポートしていません。

エディター用に追加したこの行:

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

デフォルトではすべてに機能しますが、上付き文字と下付き文字には機能しません。

Google は、commandValue を false に設定して execCommand を使用する必要があるという結果を出しましたが、それも機能しませんでした。

誰かがそれを機能させるためのトリックを行う方法を知っていますか、コードに / を追加しますか?

4

3 に答える 3

3

次のコードをソースhttps://github.com/xing/wysihtml5/blob/master/dist/wysihtml5-0.3.0.jsに追加します

wysihtm5 を sup と sub で変更

ソースの 6876 行目以降

(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);

ソースの7291行目以降

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

ソースの8441行目以降

    "83": "sub", // S
    "80": "sup" // P
于 2013-04-30T17:09:45.503 に答える
3

SUPERSCRIPT の代わりに SUP を試す

于 2012-11-30T18:59:31.960 に答える