gpt4 book ai didi

javascript - Symfony 4 表单与 ckeditor 文本区域未提交

转载 作者:行者123 更新时间:2023-12-03 00:49:02 32 4
gpt4 key购买 nike

我需要在我的网站上使用所见即所得编辑器。我使用 symfony 4。

我尝试使用 ckeditor 5 CDN ( https://ckeditor.com/ckeditor-5/download/ )

View 运行良好,但 symfony 表单未提交。 (textareatype 可能会杀死表单,因为使用 ckeditor,它会被更改为许多 div,并且 textarea 部分可能会被视为空白)

这是表单中文本区域的代码。

->add('content', TextareaType::class, [
'label' => "Content label",
'required' => true,
'attr' => [
'class' => "ckeditor"
]
])

以及脚本的代码

<script>
ClassicEditor
.create( document.querySelector( '.ckeditor' ) )
.catch( error => {
console.error( error );
} );
</script>

谢谢。使用简单的所见即所得编辑器是多么困难,这真是令人绝望。

最佳答案

我找到了解决方案。我强调我使用CKEditor 5。

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

document.getElementById("news_submit").addEventListener("click", function() {
theEditor.updateSourceElement();
});

该方法现在是 CKEditor 5 的“updateSourceElement”。

关于javascript - Symfony 4 表单与 ckeditor 文本区域未提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53135089/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com