将/ckeditor/static/ckeditor/ckeditor/plugins/image/dialogs/image.js内的
{
id: "cmbAlign",
requiredContent: "img{float}",
type: "select",
widths: ["35%", "65%"],
style: "width:90px",
label: d.lang.common.align,
"default": "",
items: [[d.lang.common.notSet, ""], [d.lang.common.left, "left"], [d.lang.common.right, "right"]],
onChange: function () {
e(this.getDialog());
g.call(this, "advanced:txtdlgGenStyle")
},
setup: function (a, b) {
if (1 == a) {
var c = b.getStyle("float");
switch (c) {
case "inherit":
case "none":
c =
""
}
!c && (c = (b.getAttribute("align") || "").toLowerCase());
this.setValue(c)
}
},
commit: function (a, b) {
var c = this.getValue();
if (1 == a || 4 == a) {
if (c ? b.setStyle("float", c) : b.removeStyle("float"), 1 == a) switch (c = (b.getAttribute("align") || "").toLowerCase(), c) {
case "left":
case "right":
b.removeAttribute("align")
}
} else 8 == a && b.removeStyle("float")
}
}
替换为
{
id: "cmbAlign",
requiredContent: "img{float}",
type: "select",
widths: ["35%", "65%"],
style: "width:90px",
label: d.lang.common.align,
"default": "",
items: [[d.lang.common.notSet, ""], [d.lang.common.left, "left"], [d.lang.common.right, "right"], [d.lang.common.center, "center"]],
onChange: function () {
e(this.getDialog());
g.call(this, "advanced:txtdlgGenStyle")
},
setup: function (a, b) {
if (1 == a) {
var c = b.getStyle("margin");
console.log(c)
switch (c) {
case "auto auto auto 0px":
c = "left"
break
case "auto 0px auto auto":
c = "right"
break
case "auto":
c = "center"
break
case "none":
c = ""
}
!c && (c = (b.getAttribute("align") || "").toLowerCase());
this.setValue(c)
}
},
commit: function (a, b) {
var c = this.getValue();
if (1 == a || 4 == a) {
if (c) {
switch (c) {
case'left':
b.setStyle('float', 'none');
b.setStyle('display', 'block');
b.setStyle('margin', 'auto auto auto 0px');
break;
case'right':
b.setStyle('float', 'none');
b.setStyle('display', 'block');
b.setStyle('margin', 'auto 0px auto auto');
break;
case'center':
b.setStyle('float', 'none');
b.setStyle('display', 'block');
b.setStyle('margin', 'auto');
break;
default:
b.setStyle('float', 'none');
b.setStyle('display', 'block');
b.setStyle('margin', 'auto');
}
} else {
b.removeStyle('float')
b.removeStyle('display')
b.removeStyle('margin')
}
// c ? b.setStyle("float", c) : b.removeStyle("float")
if (1 == a) switch (c = (b.getAttribute("align") || "").toLowerCase(), c) {
case "left":
case "right":
b.removeAttribute("align")
}
} else 8 == a && b.removeStyle("float")
}
}