我真的需要删除图片插件中的这些属性,我只需要允许用户设置src属性,仅此而已。但是,由于JavaScript和Ckeditor不是我的强项,因此我无法想出如何实现。有人知道吗?
我正在使用CKEditor 4.3.1
我真的需要删除图片插件中的这些属性,我只需要允许用户设置src属性,仅此而已。但是,由于JavaScript和Ckeditor不是我的强项,因此我无法想出如何实现。有人知道吗?
我正在使用CKEditor 4.3.1
HTML
<textarea id="editor" name="editor1"><p>Initial value.</p></textarea>
脚本
<script type="text/javascript">
CKEDITOR.on('dialogDefinition', function (ev) {
// Take the dialog name and its definition from the event data.
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
// Check if the definition is from the dialog we're
// interested in (the 'image' dialog).
if (dialogName == 'image') {
// Get a reference to the 'Image Info' tab.
var infoTab = dialogDefinition.getContents('info');
// Remove unnecessary widgets/elements from the 'Image Info' tab.
infoTab.remove('browse');
infoTab.remove('txtHSpace');
infoTab.remove('txtVSpace');
infoTab.remove('txtBorder');
infoTab.remove('txtAlt');
infoTab.remove('txtWidth');
infoTab.remove('txtHeight');
infoTab.remove('htmlPreview');
infoTab.remove('cmbAlign');
infoTab.remove('ratioLock');
}
});
CKEDITOR.replace('editor');
</script>
我建议您使用ckfinder来浏览图片。 以下是在调用coeditor时使用的代码:
<script type="text/javascript">
//<![CDATA[
// This call can be placed at any point after the
// <textarea>, or inside a <head><script> in a
// window.onload event handler.
CKEDITOR.replace('testoEditor', {
filebrowserBrowseUrl : '../../ckfinder/ckfinder.html',
filebrowserImageBrowseUrl : '../../ckfinder/ckfinder.html?Type=Images',
width : '505',
height : '400',
});
//]]>
</script>