I would like to be able to pass html to a ckeditor to be able to give the option to edit the text that I am writing in that ckeditor, an example would be like when we give it edit publication right here in stackoverflow it loads us everything that we had already written in the text box
let html = `<h2><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</h2>`
$('#editor1').val(html)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor</title>
<script src="https://cdn.ckeditor.com/4.16.1/standard/ckeditor.js"></script>
<script
src="https://code.jquery.com/jquery-1.12.4.min.js"
integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
crossorigin="anonymous"></script>
</head>
<body>
<textarea name="editor1"></textarea>
<script>
CKEDITOR.replace( 'editor1' );
</script>
</body>
</html>
I have even tried with$('#editor1).html(html)
Is there any way that I can pass the html content that has that variable to the ckeditor
You just need the editor instance and the .setData() method .
You can use these two options:
Your code would look like this: