suyati / line-control

A Light Weight HTML5 Text Editor designed as a JQuery Plugin
Other
124 stars 90 forks source link

Problem restoring to editor after pasting any text and saving it to database #121

Open Ademgenc53 opened 3 years ago

Ademgenc53 commented 3 years ago

Hello, I'm using PHP and PDO, I am very happy with this editor, except one problem, no other problems OR I'm doing wrong somewhere

When I write and save text in the editor, there is no problem loading text back into the editor. However, when I copy text from anywhere and paste it into the text editor and save it, the text is not restored inside the editor OR Text is not restored inside the editor even when there is only text in the database(without any html tags) aaaaaaa

I'm trying both options

echo addslashes($read['content_text']);
echo $read['content_text'];
<textarea id="txtEditor3"></textarea>
<textarea id="content_text" name="content_text" style="display:none;"></textarea>

<script language="javascript" type="text/javascript">
  $(document).ready( function() {
    $("#txtEditor3").Editor();
      $("#txtEditor3").Editor("setText", "<?php echo addslashes($read['content_text']); ?>");  // From the database into the editor
        $("input:submit").click(function(){
          $('#content_text').text($('#txtEditor3').Editor("getText"));
        });
   });
</script>

Column in PDO database 'content_text' longtext COLLATE utf8_general_ci DEFAULT NULL

I am writing to the database in this way

        $sql = $PDOdatabase->prepare(" UPDATE table SET content_text=? WHERE id=? ");
        $sql->execute([$_POST['content_text'], '1']);