Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
5.2k views
in Technique[技术] by (71.8m points)

javascript - CKEditor 5 and Symfony 4 Form integration

I have to integrate the new CKEditor 5 instead of the old CKEditor 4 in symfony, with CKEditor 4 the form was submitted but now when I add CKEditor 5 this is not submitted I don't know why. On the create an article page I had the old CKEditor 4 and it worked like a charm, how can I make the CKEditor 5 work?

My ckeditor_widget.html.twig look like this:

{% block ckeditor_widget %}
        <script src="{{ asset('bundles/fosckeditor/packages/ckeditor5-build-classic/build/ckeditor.js') }}"></script>

        <textarea id="ckeditor" name="ckeditor">{{ value }}</textarea>

        <script>
            ClassicEditor
                .create( document.querySelector( '#ckeditor' ) )
                .then( editor => {
                    theEditor = editor;
                } )
                .catch( error => {
                    console.error( error );
                } );

            document.getElementById("submit").addEventListener("click", function() {
                theEditor.updateSourceElement();
            });
        </script>
{% endblock %}

My builder of CKEditor look like this :

->add('content', CKEditorType::class, [
                'label' => 'label.content',
                'required' => true,
                'config_name' => 'cms',
                'config' => [
                    'filebrowserUploadHandler' => function (RouterInterface $router) use ($community) {
                        return $router->generate(
                            'app_manager_file_upload',
                            [
                                'group_id' => $community->getId(),
                            ],
                            UrlGeneratorInterface::ABSOLUTE_URL
                        );
                    },
                ],
            ])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...