有没有一种无摩擦的方式来保存在firebase中的多行输入? [英] is there a frictionless way to save input with multiple lines in firebase?

查看:150
本文介绍了有没有一种无摩擦的方式来保存在firebase中的多行输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望用户能够输入几个段落作为firebase输入,并保留换行/返回/输入以用于格式化目的。本教程中的firechat或更基本的聊天应用程序都没有提供这种功能...



我尝试了很多东西:

获取我的contenteditable div的html,然后使用textarea输入而不是contenteditable将div和brs转换为\ r\\\
换行符



div



在div中显示输出而不是lis

是否有可能firebase不保存任何空白字符除了单个空间?他们的教程聊天应用程序出现这种行为,不支持换行符/回车或标签为例



我会期望工作的一种方法是采取contenteditable div ,将其保存到firebase,然后添加

解决方案

我建议查看 Firepad




  • Firepad是Firebase应用程序的一种嵌入式开放源代码协作代码和文本编辑体验。
  • 它毫无疑问是无摩擦的。
  • 它允许您可以创建所需的丰富的文本编辑器体验。
  • FireBoard.io / docs /rel =nofollow>文档描述,这是如何初始化Firepad的:


    $ b

     < div id =firepad>< / div> 
    < script>
    var firepadRef =新的Firebase('< FIREBASE URL>');
    var codeMirror = CodeMirror(document.getElementById('firepad'),{lineWrapping:true});
    var firepad = Firepad.fromCodeMirror(firepadRef,codeMirror,
    {richTextShortcuts:true,richTextToolbar:true,defaultText:'Hello,World!'});
    < / script>


    I'd like a user to be able to type several paragraphs as a firebase input and have the newlines/returns/enter preserved for formatting purposes. Neither the firechat or the more basic chat app in the tutorial provide this functionality ...

    I've tried many things:

    getting the html of my contenteditable div, then converting divs and brs to \r\n newline characters

    using a textarea input instead of a contenteditable div

    displaying the output in divs instead of lis

    Is it possible that firebase does not save any whitespace characters except for the single space? their tutorial chat application exhibit this behavior, not supporting newlines/carriage returns or tabs for example

    One approach that I would have expected to work is taking the html of the contenteditable div, saving it to firebase, and then adding that

    解决方案

    I'd suggest checking out Firepad.

    • Firepad is a drop-in "Open source collaborative code and text editing" experience for Firebase apps.
    • It is definitely frictionless.
    • It will allow you to create the rich text-editor experience you're looking for.

    As the documentation describes, this is how you initialize Firepad:

    <div id="firepad"></div>
    <script>
      var firepadRef = new Firebase('<FIREBASE URL>');
      var codeMirror = CodeMirror(document.getElementById('firepad'), { lineWrapping: true });
      var firepad = Firepad.fromCodeMirror(firepadRef, codeMirror,
          { richTextShortcuts: true, richTextToolbar: true, defaultText: 'Hello, World!' });
    </script>
    

    这篇关于有没有一种无摩擦的方式来保存在firebase中的多行输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆