CKEditor在<p>源HTML的标签之间添加缩进



所以,nodejs项目,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>'

在翡翠视图中,我得到了它

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

(不带标签,作为 HTML(从节点保存后如何查看

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

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

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

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

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 儿童添加特别的无 p 边距标签,但不是......不明白这个填充是什么设置。

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

最新更新