如何在 CKEditor 5 中更新元素()?
How to updateElement() in CKEditor 5?
我正在尝试更新一些已初始化的 CKEditor,但它不起作用。
在 CKEditor 4 中是:
for(var instanceName in CKEDITOR.instances)
CKEDITOR.instances[instanceName].updateElement();
不适用于 CKEditor 5。
我的答案将取决于 ClassicEditor but it will also work with the InlineEditor and BalloonEditor。
ClassicEditor.create()
function returns a Promise that will be resolved with the editor instance. There is no longer any global variable that holds created editors. See .
如果您在 <textarea>
元素(应该在 <form>
元素内)上初始化编辑器,<textarea>
的值将在提交表单时自动更新.你可以看到 source code.
当然,您可以手动更新元素。请参见 ClassicEditor.updateElement()
method. I also prepared an online demo: https://jsfiddle.net/pomek/k1wp093n/
请记住,editor.updateElement()
函数在未来的版本中将重命名为 editor.updateSourceElement()
。参见 ckeditor/ckeditor5-core#129
我正在尝试更新一些已初始化的 CKEditor,但它不起作用。
在 CKEditor 4 中是:
for(var instanceName in CKEDITOR.instances)
CKEDITOR.instances[instanceName].updateElement();
不适用于 CKEditor 5。
我的答案将取决于 ClassicEditor but it will also work with the InlineEditor and BalloonEditor。
ClassicEditor.create()
function returns a Promise that will be resolved with the editor instance. There is no longer any global variable that holds created editors. See
如果您在 <textarea>
元素(应该在 <form>
元素内)上初始化编辑器,<textarea>
的值将在提交表单时自动更新.你可以看到 source code.
当然,您可以手动更新元素。请参见 ClassicEditor.updateElement()
method. I also prepared an online demo: https://jsfiddle.net/pomek/k1wp093n/
请记住,editor.updateElement()
函数在未来的版本中将重命名为 editor.updateSourceElement()
。参见 ckeditor/ckeditor5-core#129