ckeditor getData()在源模式下返回过时数据(最后一次更改丢失) [英] ckeditor getData() returning stale data (last change missing) in source mode
问题描述
尝试在
所以,请看一下代码(代码行的顺序或其他)。如果可能的话,分享更多代码,我可以提供更多帮助。
希望有所帮助。
try typing in source mode on http://ckeditor.com/demo to debug use
CKEDITOR.instances["editor1"].on("key", function(e) {console.log("change: " + e.editor.getData())})
in console
I always see one character less in the console, so If I have typed abc
I see ab
note: using key event because of https://dev.ckeditor.com/ticket/12031Guidelines and How to detect CKEditor source mode on change event
Writing a detailed answer here with my analysis.
As I said earlier, the getData() is being fetched even before the key stroke is being recorded as a part of the text in the Editor. That is why you see the previous data(The data that's before the key press)
I am not able to help you much with the current situation as very minimal code is exposed. I am not really sure how you are using it, and what lines are presiding it.
But, I will post in my analysis- I created a waitfunc() which just sets-timeout for 5secs. I did this to observe if the key is recorded in the editor first or the data is being taken first.
function waitfunc() {
setTimeout(function() {
console.log("wait")
}, 5000)
}
CKEDITOR.instances["editor1"].on("key", function(e) {
waitfunc();
console.log("change: " + e.editor.getData());
waitfunc();
})
I see the data is being taken first. And then new key pressed is added as a part of editor. I have added 'c' at the end of the paragraph.
So, please have a look at the code once(the ordering of lines of code or whatever). And if possible, share more code, I can help more than this.
Hope it helps.
这篇关于ckeditor getData()在源模式下返回过时数据(最后一次更改丢失)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!