【问题标题】:how summernote editor storing the in mongodb with meteorsummernote 编辑器如何用流星存储在 mongodb 中
【发布时间】:2016-05-30 16:14:42
【问题描述】:

我可以像这样以 html 格式存储在 mongodb 中:

{
    "_id" : "GwgCygRMgsB8jRBFr",
    "html" : "<p>mid</p><ol><li><b>m</b></li><li>,mbgb</li><li>lgkbg</li><li>b,g</li></ol><p><br></p><p><br></p>"
}
{
    "_id" : "XyK5jaLgQNxJyDP4u",
    "html" : "<p>mid</p><ol><li><b>m</b></li><li>,mbgb</li><li>lgkbg</li><li>b,g</li></ol><p><br></p><p><br></p>"
}

我只想在 textarea 中存储一个文本编辑,而不是他 html 的元素,我只需要发送文本,任何人都可以帮忙,我正在尝试这个,因为两天后我是流星的新手。

【问题讨论】:

    标签: javascript html mongodb meteor summernote


    【解决方案1】:

    在将其存储到数据库之前,您可以使用正则表达式过滤文本。但它们并非 100% 准确。

    var htmlString = "<div><p>Paragraph 1 text</p><p>Paragraph 2 text</div>";
    
    var regEx = /(<([^>]+)>)/ig;
    
    htmlString.replace(regEx, " "); //this will replace you html tags with space
    

    输出将是“第 1 段文本第 2 段文本”

    你可以像下面这样测试你的正则表达式

    var isValid = /(<([^>]+)>)/ig.test("<p>Some text</p>");
    

    【讨论】:

      猜你喜欢
      • 2016-04-10
      • 2018-12-23
      • 2016-01-20
      • 2017-01-10
      • 2021-10-14
      • 1970-01-01
      • 1970-01-01
      • 2021-09-22
      • 2020-11-18
      相关资源
      最近更新 更多