我遇到了使用 ckeditor 的恼人功能.
当您上传图像时,在您的文本内容之间或任何地方,ckeditor 会默认自动填充宽度和高度输入字段,这会导致带有 width
和 height 的 html 标记
在 style
属性中设置:
<img alt="" src="/uploads/ckeditor/pictures/196/content_David_Leo006.jpg" style="width: 2000px; height: 669px;">
但是如果你把输入框的值删掉再提交,宽高是不会设置的:
<img alt="" src="/uploads/ckeditor/pictures/196/content_David_Leo006.jpg">
现在,就像 21 世纪任何正常、聪明、健康的 Web 开发人员一样,我有一个响应式设计来处理这些事情,所以我希望标签始终像后者一样生成。如何完全隐藏和禁用宽度/高度的输入字段?
CK 编辑器的文档非常困惑
最佳答案
我对表格做了类似的事情。我不希望最终用户输入愚蠢的值,因为我们强制采用响应式样式和宽度。
也许这段代码可以帮到你:
CKEDITOR.on( 'dialogDefinition', function( ev )
{
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
if (dialogName == 'table') {
// Get the advanced tab reference
var infoTab2 = dialogDefinition.getContents('advanced');
//Set the default
// Remove the 'Advanced' tab completely
dialogDefinition.removeContents('advanced');
// Get the properties tab reference
var infoTab = dialogDefinition.getContents('info');
// Remove unnecessary bits from this tab
infoTab.remove('txtBorder');
infoTab.remove('cmbAlign');
infoTab.remove('txtWidth');
infoTab.remove('txtHeight');
infoTab.remove('txtCellSpace');
infoTab.remove('txtCellPad');
infoTab.remove('txtCaption');
infoTab.remove('txtSummary');
}
});
关于html - CK 编辑器禁用宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22474630/