0

テストアプリで NicEditor を使っているので、You Tube から動画を追加するボタンをつけようと思ったのですが、サンプルサイトのナイスエディターでもサンプルを見つけるまで動かず、あれこれ cogido add をボタンは表示されますが、ボタンバーには表示されません

var nicCodeOptions = {
buttons : {
    'xhtml': { name: 'Edit HTML', type: 'nicCodeButton' },
    'youTube' : {name : 'YouTube', type : 'nicYouTubeButton'}
},
iconFiles: {
    'youTube': '/nicedit/youtube.gif'
}
};

var nicYouTubeButton = nicEditorAdvancedButton.extend({
width: '350px',

addPane: function () {
    this.addForm({
        '': { type: 'title', txt: 'YouTube Url' },
        'youTubeUrl': { type: 'text', txt: 'URL', value: 'http://', style: { width: '150px'} },
        'height': { type: 'text', txt: 'Height', value: '560', style: { width: '150px'} },
        'width': { type: 'text', txt: 'Width', value: '315', style: { width: '150px'} }
    });
},

submit: function (e) {
    var code = this.inputs['youTubeUrl'].value;
    var width = this.inputs['height'].value;
    var height = this.inputs['width'].value;

    if (code.indexOf('watch?v=') > 0) {
        code = code.replace('watch?v=','embed/');
    }

    var youTubeCode = '<iframe width="' + width + '" height="' + height + '" src="' + code + '" frameborder="0" allowfullscreen></iframe>';

    this.removePane();
    this.ne.nicCommand('insertHTML', youTubeCode);
}
});
nicEditors.registerPlugin(nicPlugin,nicYouTubeOptions);
4

1 に答える 1

0

このプラグイン スクリプトを nicedit スクリプトに追加しますか、それともページに追加しますか? 私はこの問題を抱えていましたが、これが私がそれを修正した方法です:

スクリプトではなくページに関連していることを確認し'youTube': '/nicedit/youtube.gif' 、最初のスラッシュ 'youTube' を削除'nicedit/youtube.gif'します。ページでプラグインを使用しているか、Nicedit.js スクリプト内で使用しているかによってすべて異なります。

これは、ページにコードを追加する方法です(実行する順序が重要であることがわかりました)

<script> Nicedit.js </script>
<script> YOUR PLUGIN CODE (above)</script>
###CONFIG ###
<script>
bkLib.onDomLoaded(function() {
new nicEditor({buttonList : ['youTube','bold','italic','underline','strikeThrough','fontSize','fontFormat','left','center','right','justify','ol','ul','removeformat','indent','outdent','hr']}).panelInstance('article');
});
</script>
于 2014-03-03T14:25:35.470 に答える