CKEditor在源HTML

时间:2018-03-05 13:58:12

标签: javascript html node.js mongodb ckeditor

所以,nodejs project,express,mongodb,有一个函数可以生成一些HTML代码,用于保存在DB中,这就是它

botcfg.body =
    '<h3>Trade amount settings</h3>'
    + '<p># Coin position: <strong>' + req.body.coin_pos + '</strong></p>'
    + '<p># Trade amount: <strong>' + req.body.ta + '</strong></p>'
    + '<p># Template: <strong>' + req.body.template + '</strong></p>'
    + '<p># Fee: <strong>' + req.body.fee + '</strong></p>'
    + '<br>'
    + '<h3>Mad hatter mode</h3>'
    + '<p># Min Price Change To Buy: <strong>' + mh_min_pr_c2b + '</strong></p>'
    + '<br>'
    + '<h3>Safety settings</h3>'
    + '<p># Min Price Change To Buy: <strong>' + req.body.ss_min_pr_c2b + '</strong></p>'
    + '<p># Min Price Change To Sell: <strong>' + req.body.ss_min_pr_c2s + '</strong></p>'
    + '<p># Stop Loss (%): <strong>' + req.body.stoploss + '</strong></p>'
    + '<br>'

在Jade视图中,我得到了

h4 Config
            div.botconf-text.no-p-margin!= botcfg.body

(没有标签,为HTML) How i see after saving from node

之后,如果我想编辑这个主体我使用CKEditor 4

script.
    CKEDITOR.replace('botcfg-body-edit', {
        toolbar: 'Full',
        height: '600px'
    })

并且,当我什么都不做而只是保存文本时,我收到P标签之间的缩进文本... After ckeditor saving

我尝试以不同的方式添加下面的配置(autoParagraph single,fillEmptyBlocks single,他们在一起等),但没有任何帮助

config.autoParagraph = false;
config.fillEmptyBlocks = false;
config.enterMode = CKEDITOR.ENTER_BR;
config.forceEnterMode = true;

本文的P风格是

.botconf-text {
    white-space: pre-wrap;
    color: #99ff99;
    border-left: 2px dotted #ABABAB;
    padding: 8px;
    margin-left: 8px;
}

.no-p-margin p {
    margin: 0 0 2px;
}

尝试在div中为p个孩子添加特别的无边距标签,但不是......不明白这个填充的设置。

1 个答案:

答案 0 :(得分:0)

我的错...用于存储数据我使用MongoDB,当我在其中插入数据时它保存原样(使用\ r \ n)所以当我在jade模板中调用!= botcfg.body时我收到文本它是如何的存储,我在解析参数时添加正则表达式 botcfg.body = req.body.body.replace(/(\r\n|\n|\r)/gm,""); 一切顺利。可能是可以帮助别人的。 CKEditor配置不需要。

相关问题