所有,
我在我的应用程序中非常成功地使用CKEditor,允许客户端构建和发送HTML电子邮件.只有一个障碍–CK使用style =“float:left”用于图像,而Outlook拒绝接受它是有效的(方式去,微软..)FCKEditor曾经使用对齐而不是浮点来定位图像.有没有办法破解CKEditor在图像对齐方面的行为?
在CK的论坛上发帖是徒劳的.任何帮助表示赞赏!
这是另一种选择……我发现宽度/高度刚刚改变以添加对齐.
CKEDITOR.on('instanceReady',function (ev) {
// Ends self closing tags the HTML4 way,like <br>.
ev.editor.dataProcessor.htmlFilter.addRules(
{
elements:
{
$: function (element) {
// Output dimensions of images as width and height
if (element.name == 'img') {
var style = element.attributes.style;
if (style) {
// Get the width from the style.
var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec(style),width = match && match[1];
// Get the height from the style.
match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec(style);
var height = match && match[1];
// Get the align from the style
var match = /(?:^|\s)float\s*:\s*(left|right)/i.exec(style),align = match && match[1];
if (width) {
element.attributes.style = element.attributes.style.replace(/(?:^|\s)width\s*:\s*(\d+)px;?/i,'');
element.attributes.width = width;
}
if (height) {
element.attributes.style = element.attributes.style.replace(/(?:^|\s)height\s*:\s*(\d+)px;?/i,'');
element.attributes.height = height;
}
if (align) {
element.attributes.style = element.attributes.style.replace(/(?:^|\s)float\s*:\s*(left|right);?/i,'');
element.attributes.align = align;
}
}
}
if (!element.attributes.style)
delete element.attributes.style;
return element;
}
}
});
});