user9970621
user9970621

Reputation: 11

How to get html form ckeditor5?

I want to get the content written by Editer5 and submit it to save,but only text information can be obtained, and the content of the picture can not be obtained. this is my code

this is my editor

this is my edit content

in editor html

but has no data

Upvotes: 0

Views: 1909

Answers (1)

j.swiderski
j.swiderski

Reputation: 2445

You assign created editor instance to a variable and then use the getData function. You can use .then on editor creation and assign it there:

var myEditor;

ClassicEditor
    .create( document.querySelector( '#editor' ) )
    .then( editor => {
        console.log( 'Editor was initialized', editor );
        myEditor = editor;
    } )
    .catch( err => {
        console.error( err.stack );
    } );

and then get data using myEditor.getData();

Please also have a look at: https://docs.ckeditor.com/ckeditor5/latest/framework/guides/ui/document-editor.html#the-editor

Upvotes: 1

Related Questions