我用过nicEdit - http://nicedit.com/
我需要从youtube插入视频.我只需要插入url例如:http://www.youtube.com/watch?v=4GuqB1BQVr4
并替换为
<iframe width="560" height="315" src="http://www.youtube.com/embed/4GuqB1BQVr4" frameborder="0" allowfullscreen></iframe>
如何使用nicEdit从youtube插入视频?
小智 6
JDandChips代码效果很好,但我发现它将视频放在内容的底部.将其插入光标处
this.ne.selectedInstance.setContent(this.ne.selectedInstance.getContent() + youTubeCode);
this.removePane();
Run Code Online (Sandbox Code Playgroud)
this.removePane();
this.ne.nicCommand('insertHTML', youTubeCode);
Run Code Online (Sandbox Code Playgroud)
对我很有用.
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);
Run Code Online (Sandbox Code Playgroud)
nicCommand为需要在光标位置插入html的其他插件插入html.
对不起,打算说一个插件在光标位置插入任何html GO HERE.
归档时间: |
|
查看次数: |
5326 次 |
最近记录: |