笔记 django-ckeditor图片居中

 将/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")
    }
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值