Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am getting an error when there are 2 or more instances of the CKEditor in a single page.
I get Uncaught TypeError: Cannot call method 'getFrameDocument' of null in the line ckeditor.js line 102.
After this the counter plugin stops working as well..
Comment | File | Size | Author |
---|---|---|---|
#18 | ckeditor.counter.patch | 604 bytes | Alice Heaton |
Comments
Comment #1
inian CreditAttribution: inian commentedComment #2
dczepierga CreditAttribution: dczepierga commentedCould u write which module u're using to have more instances of CKEditor in a single page?
When u disable this plugin everything works fine?
Greetings
Comment #3
dczepierga CreditAttribution: dczepierga commentedComment #4
inian CreditAttribution: inian commentedI have written a custom module where I am having multiple instances of the ckeditor.
If I disable this plugin, everything is working normally.
Comment #5
dczepierga CreditAttribution: dczepierga commentedIt is possible to send me this module? It will help me to reproduce this and fix it asap...
Greetings
Comment #6
inian CreditAttribution: inian commentedTo reproduce the error on a fresh Drupal install,
Attach a field to a content type which has ckeditor and set the 'number of values' to unlimited.
Make sure that the word count plugin is enabled.
When u click on the 'add another item' button and new instances of ckeditor are getting added, the "Uncaught TypeError: Cannot call method 'getFrameDocument' of null " exception occurs. (it usually occurs when I click on the "add new item" button twice and there are 3 instances of ckeditor on the screen. The error occurs immediately when i click on the third ckeditor)
After this the counter plugin stops working entirely.
PS - I have uncommented the editor.on( 'key', count); in the counter plugin so that the word count keeps updating as the user types.
Comment #7
inian CreditAttribution: inian commentedComment #8
dczepierga CreditAttribution: dczepierga commented@inian, if u disable count symbols on every key u still get this error?
Which browser do u use to check this?
Greetings
Comment #9
dczepierga CreditAttribution: dczepierga commentedComment #10
inian CreditAttribution: inian commented@dczepierga
Yes the error occurs even when the count on every key is disabled.
I checked this in chrome.
Comment #11
dczepierga CreditAttribution: dczepierga commentedI check this with Chrome 19 and Firefox 12 - for me works when every key is disabled. If i enable this option a have some errors after few seconds of using...
Do u don't use any custom theme or page cache/optimize?
Do u try to use last DEV version of CKEditor module with last CKEditor library?
Greetings
Comment #12
inian CreditAttribution: inian commentedI checked the issue again with Chrome 19, fresh Drupal install and after disabling the updating process when every key is pressed. I also used the latest CKeditor library and the latest development release Druapl ckeditor module for testing.
I had to add around 5 CKeditors to a single page for me to get the error when every key press is disabled. When it is enabled, I get the error even when there are 3 ckeditors in the page..
Comment #13
inian CreditAttribution: inian commentedThis is the entire stacktrace of the error :-
Uncaught TypeError: Cannot call method 'getFrameDocument' of null ckeditor.js:102
j.add.init.C.on.C.addMode.getData ckeditor.js:102
(anonymous function) ckeditor.js:129
a.event.on.m ckeditor.js:6
a.event.fire ckeditor.js:6
a.editor.fire ckeditor.js:7
e.extend.getData ckeditor.js:26
count /drupal/sites/all/modules/ckeditor/plugins/counter/plugin.js?t=C3HA5RM:35
a.event.on.m ckeditor.js:6
a.event.fire ckeditor.js:6
a.editor.fire ckeditor.js:7
a.focusManager.forceBlur ckeditor.js:23
a.focusManager.focus ckeditor.js:22
j.add.init.C.on.ad ckeditor.js:101
m ckeditor.js:6
a.event.fire ckeditor.js:6
d.domObject.g ckeditor.js:12
Comment #14
inian CreditAttribution: inian commentedComment #15
duozerskI would love to help with this one as the counter plugin was written by me... just subscribing for now, will have more time for this issue on the weekend.
Comment #16
duozerskWhile reviewing this issue and looking through the counter plugin code I can suggest to try commenting out this code:
editor.on( 'dataReady', count );
My thought process was that the issue is related to the CKEditor initialization so if we would comment this string then the counter plugin won't act during the initiation process. I don't have the testing environment to check for this, but it is definitely something to try and see if it helps.
Thanks
AndyB
Comment #17
duozerskActually, I have a woking website (Drupal 6) with a CCK textarea field having unlimited values - and everything is working fine with up to 11-12 fields (didn't try to add more than that...). So it is Drupal 6 with CKEditor 6.x-1.8 (stock counter plugin included with this version, not modified) and multiple CCK textarea fields; fields adding is handled by CCK.
AndyB
Comment #18
Alice Heaton CreditAttribution: Alice Heaton commentedI have an issue with the same error and backtrace, though with only one editor on the page.
I have seen it in various contexts, but the reliable way I have found to reproduce it is by :
- Highlighting some text ;
- With the text still highlighted, clicking on "Switch editor to plain text" link.
The error happens during the 'blur' event. I have read somewhere that this can happen during a certain combination of blurring and saving events because the iframe document cannot be found. This makes sense in my use case, as I'm removing the editor from the page, then it's quite possible the iframe is already gone by the time count is called.
Going on that hypothesis, I have checked and can confirm that, in my case, this is indeed the issue - when the 'blur' event is called, editor.document is null, and adding a simple test for that fixes the issue.
In my use case, this is not the fault of the counter module - plugins shouldn't be called when there is no document. (And if that was a possibility, then editor.getData should check for the eventuality). This might be the fault of Drupal's module (the way the 'Switch to plain text editor' link is handled), or the fault of CKEditor - I'm not sure.
In the mean time, as this issue seems to have happened under other circumstances, I think it wouldn't hurt for this module to implement the fix anyway.
I have attached a patch. Could the people who have experienced a similar issue test it to confirm it is the same issue ?
Comment #19
Alice Heaton CreditAttribution: Alice Heaton commented