1

新しいクラスを追加するときに、スパンから以前のクラスを削除できる必要があります。

以下は、ボタンを介して渡されるスパンとクラスを追加するカスタム関数です。

wysihtml5.commands.custom_underline = {
  exec: function(composer, command, className) {
    return wysihtml5.commands.formatInline.exec(composer, command, "span", className, new RegExp(className, "g"));
  },
  state: function(composer, command, className) {
    return wysihtml5.commands.formatInline.state(composer, command, "span", className, new RegExp(className, "g"));
  }
};

ボタンは次のとおりです。

<a data-wysihtml5-command="custom_underline" data-wysihtml5-command-value="u grey">Grey</a>
<a data-wysihtml5-command="custom_underline" data-wysihtml5-command-value="u dark_grey">Dark Grey</a>
<a data-wysihtml5-command="custom_underline" data-wysihtml5-command-value="u black">Black</a>

灰色のボタンと濃い灰色のボタンの両方をクリックすると、次のコードが生成されます。

<span class="u grey u dark_grey">Some text</span>

新しいクラスを追加する前に、以前のクラスを削除する方法を見つける必要があります。

4

0 に答える 0