首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打印时显示表border="0“

打印时显示表border="0“
EN

Stack Overflow用户
提问于 2016-02-01 22:27:03
回答 2查看 993关注 0票数 0

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

谢谢。

EN

回答 2

Stack Overflow用户

发布于 2016-02-04 00:13:13

默认情况下,ckeditor会添加虚线边框(它会将类cke_show_border添加到表元素中)。要解决这个问题,你可以修改css (在ckeditor目录中的contents.css),然后删除/编辑那个类的样式,或者你可以修改ckeditor核心代码,这样当你编辑它的时候,它不会把这个类添加到表中(当你提交文本时,它就会删除那个类)。

最简单的就是修改contents.css,编辑核心代码就有点难了,还得重新打包ckeditor.js。

票数 1
EN

Stack Overflow用户

发布于 2018-08-08 20:59:36

我通过取消缩小文件ckeditor.js解决了我的问题,有一个showborders函数负责在我修改它的时候添加“虚线”边框

之前的

代码语言:javascript
复制
 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+$/,
                            ""))
                    }
                }
            })
        }
    });

Now

代码语言:javascript
复制
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+$/,
                            ""))
                    }
                }
            })
        }
    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35133004

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档