表格边框=“0”表示正在打印

时间:2016-02-01 14:27:03

标签: ckeditor

我正在使用CKEditor 4.5.6并放置一个没有边框的表格(border =“0”),但是,当我点击打印内容时,表格会在打印预览中显示虚线边框。我该如何解决这个问题?

感谢的。

2 个答案:

答案 0 :(得分:1)

默认情况下,ckeditor广告是虚线边框(它将类cke_show_border添加到表格元素中)。要摆脱这种情况,你可以修改ckeditor的css(ckeditor目录中的contents.css),删除/编辑该类的样式,或者你可以修改ckeditor核心代码,这样它就不会出现这种情况。在您编辑它时将此类添加到表中(它在您提交文本时删除该类)。

最简单的是修改contents.css,编辑核心代码有点困难,你必须重新打包ckeditor.js。

答案 1 :(得分:0)

我通过最小化文件ckeditor.js解决了我的问题,当我解决它时,有一个showborders函数负责添加“虚线”边框

之前

 CKEDITOR.plugins.add("showborders", {
        modes: {
            wysiwyg: 1
        },
        onLoad: function() {
            var a;
            a = (CKEDITOR.env.ie6Compat ? [".%1 table.%2,", ".%1 table.%2 td, .%1 table.%2 th", "{", "border : #d3d3d3 1px dotted", "}"] : ".%1 table.%2,;.%1 table.%2 \x3e tr \x3e td, .%1 table.%2 \x3e tr \x3e th,;.%1 table.%2 \x3e tbody \x3e tr \x3e td, .%1 table.%2 \x3e tbody \x3e tr \x3e th,;.%1 table.%2 \x3e thead \x3e tr \x3e td, .%1 table.%2 \x3e thead \x3e tr \x3e th,;.%1 table.%2 \x3e tfoot \x3e tr \x3e td, .%1 table.%2 \x3e tfoot \x3e tr \x3e th;{;border : #d3d3d3 1px dotted;}".split(";")).join("").replace(/%2/g,
                "cke_show_border_old ").replace(/%1/g, "a ");
            CKEDITOR.addCss(a)
        },
        init: function(a) {
            var b = a.addCommand("showborders", f);
            b.canUndo = !1;
            !1 !== a.config.startupShowBorders && b.setState(CKEDITOR.TRISTATE_ON);
            a.on("mode", function() {
                b.state != CKEDITOR.TRISTATE_DISABLED && b.refresh(a)
            }, null, null, 100);
            a.on("contentDom", function() {
                b.state != CKEDITOR.TRISTATE_DISABLED && b.refresh(a)
            });
            a.on("removeFormatCleanup", function(d) {
                d = d.data;
                a.getCommand("showborders").state == CKEDITOR.TRISTATE_ON && d.is("table") && (!d.hasAttribute("border") ||
                    0 >= parseInt(d.getAttribute("border"), 10)) && d.addClass("cke_show_border_old ")
            })
        },
        afterInit: function(a) {
            var b = a.dataProcessor;
            a = b && b.dataFilter;
            b = b && b.htmlFilter;
            a && a.addRules({
                elements: {
                    table: function(a) {
                        a = a.attributes;
                        var b = a["class"],
                            c = parseInt(a.border, 10);
                        c && !(0 >= c) || b && -1 != b.indexOf("cke_show_border_old ") || (a["class"] = (b || "") + " cke_show_border_old ")
                    }
                }
            });
            b && b.addRules({
                elements: {
                    table: function(a) {
                        a = a.attributes;
                        var b = a["class"];
                        b && (a["class"] = b.replace("cke_show_border_old ", "").replace(/\s{2}/, " ").replace(/^\s+|\s+$/,
                            ""))
                    }
                }
            })
        }
    });

现在

CKEDITOR.plugins.add("showborders", {
        modes: {
            wysiwyg: 1
        },
        onLoad: function() {
            console.log("try to add border")
        },
        init: function(a) {
            var b = a.addCommand("showborders", f);
            b.canUndo = !1;
            !1 !== a.config.startupShowBorders && b.setState(CKEDITOR.TRISTATE_ON);
            a.on("mode", function() {
                console.log("try to add border")
            }, null, null, 100);
            a.on("contentDom", function() {
                console.log("try to add border")
            });
            a.on("removeFormatCleanup", function(d) {
               console.log("try to add border")
           })
        },
        afterInit: function(a) {
            var b = a.dataProcessor;
            a = b && b.dataFilter;
            b = b && b.htmlFilter;
            a && a.addRules({
                elements: {
                    table: function(a) {
                        a = a.attributes;
                        var b = a["class"],
                            c = parseInt(a.border, 10);
                        c && !(0 >= c) || b && -1 != b.indexOf("cke_show_border ") || (a["class"] = (b || "") + " cke_show_border ")
                    }
                }
            });
            b && b.addRules({
                elements: {
                    table: function(a) {
                        a = a.attributes;
                        var b = a["class"];
                        b && (a["class"] = b.replace("cke_show_border ", "").replace(/\s{2}/, " ").replace(/^\s+|\s+$/,
                            ""))
                    }
                }
            })
        }
    });