ckeditorのキーバインディングにh1、h2、h3タグを追加する必要がありました。この単純な機能でこれを実行しました。
この関数はうまく機能し、期待通りに機能しますが、一度しか使用できません。別のディレクトリに同じ関数をコピーしてインクルードしようとすると、機能しません。何が間違っているのですか?複数のプラグインをckeditorで使用するにはどうすればよいですか?
場所:同じコードが異なる名前とタグ付きプラグイン/ボタン-H1/plugin.js
var a= {
exec:function(editor){
var format = {
element : "h1"
};
var style = new CKEDITOR.style(format);
style.apply(editor.document);
}
},
// Add the plugin
b="button-h1";
CKEDITOR.plugins.add(b,{
init:function(editor){
editor.addCommand(b,a);
editor.ui.addButton("button-h1",{
label:"Button H1",
icon: this.path + "button-h1.png",
command:b
});
}
});
しかし、私は「ボタン-H2」という名前の別のフォルダ内に別のプラグインを作成し、それは仕事をしません。
場所:プラグイン/ボタン-H2/plugin.js
// Exactly the same as above, but with "h2" tags.
var a= {
exec:function(editor){
var format = {
element : "h2"
};
var style = new CKEDITOR.style(format);
style.apply(editor.document);
}
},
// Add the plugin
b="button-h2";
CKEDITOR.plugins.add(b,{
init:function(editor){
editor.addCommand(b,a);
editor.ui.addButton("button-h2",{
label:"Button H2",
icon: this.path + "button-h2.png",
command:b
});
}
});
は基本的に、私が選択したテキストの周りに見出しタグを追加する "CTRL + 1" を使用できるようにするユーザーを必要としています。
このメソッドは、H1またはH2のいずれかの見出しのいずれかでのみ使用できますが、両方では使用できません。
私のconfig.jsには、すべてを設定するための以下のものがあります。
config.extraPlugins = "button-h1,button-h2";
config.keystrokes =
[
[ CKEDITOR.CTRL + 49 /*1*/, 'button-h1' ],
[ CKEDITOR.CTRL + 50 /*2*/, 'button-h2' ]
];
ので、
- プラグインの作品が、私は唯一のH1やH2にそれを使用することができ、両方ではない、なぜ?
これを関数や何かの中に入れて、同時に複数回実行できるようにする必要がありますか?