Remove paragraph tags from the content entered in the textarea in Froala Editor

时间:2018-03-09 19:12:56

标签: python jquery html flask froala

I am using Froala editor in my Flask app. When I get the content of textarea in Python, the content is wrapped in <p></p> tags. Can anyone help as what needs to be done so that the content is not wrapped in <p></p> tags?

I tried using htmlDoNotWrapTags option as per the documentation during initializing of text area, but it didn't help.

https://www.froala.com/wysiwyg-editor/docs/options#htmlDoNotWrapTags

My code:

HTML:

<form action="/submit_form" method="POST">
   <fieldset>
      <label for="activities_completed">Activities completed</label>
      <textarea id="activities_completed" name="activities_completed"></textarea>
   </fieldset>


   <fieldset>
      <input type="submit" value="Submit">
   </fieldset>
</form>

Initializing Froala editor:

<script>
    $(function() {
        $('textarea#activities_completed').froalaEditor();
        htmlDoNotWrapTags: ['p'] // it did not help
    });
</script>

Getting value of textarea in Python:

if request.method == 'POST':
    activities_completed = request.form['activities_completed']
    print(activities_completed)

1 个答案:

答案 0 :(得分:0)

想出来。

以下代码已移除<p></p>代码。

 <script>
        $(function() {
            var config = {
                enter: $.FroalaEditor.ENTER_BR
            };
            $('textarea#activities_completed').froalaEditor(config);
        });
    </script>