Opened 12 years ago
Closed 12 years ago
#10136 closed Bug (fixed)
Error when running Stylesheet Parser sample
Reported by: | Olek Nowodziński | Owned by: | Piotrek Koszuliński |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.1 RC |
Component: | Core : Styles | Version: | 4.0.2 |
Keywords: | Cc: |
Description
- http://ckeditor4.t/ckeditor/samples/plugins/stylesheetparser/stylesheetparser.html
Uncaught TypeError: Cannot read property '$' of undefined
- Error is in plugin.js:101
Change History (10)
comment:1 Changed 12 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 12 years ago by
Owner: | set to Piotrek Koszuliński |
---|---|
Status: | confirmed → assigned |
comment:3 Changed 12 years ago by
Status: | assigned → review |
---|
Add this to the stylesheet parser sample:
on: { setData: function( evt ) { console.log( 'setData', evt.editor.document.$.styleSheets.length ); }, contentDom: function( evt ) { console.log( 'contentDom', evt.editor.document.$.styleSheets.length ); }, instanceReady: function( evt ) { console.log( 'instanceReady', evt.editor.document.$.styleSheets.length ); } }
Result:
setData 1 contentDom 3 instanceReady 3
On setData stylesheets are not ready yet. To parse them before data are loaded we would have to reinvent bootstrap logic of the wysiwygarea editable.
Thus, my proposal is that stylesheet parser should parse only files specified in config.contentsCss
or to avoid duplication with styles defined in styles.js
special setting - config.stylesheetParser_files
.
We'll be able to preload these files separately, before initializing editable. This will also fix case when startupMode != 'wysiwyg'
.
However, for now we need a quick hack that would make stylesheet parser working without integration with ACF. Pushed t/10136 with patch that does the job. It just postpones the moment when stylescombo creates combo's items. Thanks to that stylescombo waits for stylesheet parser that has to wait until editor.document is ready (contentDom). The only thing that this patch breaks is that styles combo won't be hidden when there are no styles at all.
comment:4 follow-up: 6 Changed 12 years ago by
Status: | review → review_failed |
---|
The following test fails on t/10136: http://ckeditor4.t/dt/plugins/stylescombo/stylescombo.html?name=test-external-styles-are-registerd-in-ACF
comment:5 Changed 12 years ago by
Additionally, shoudn't we have "once" as well in the "contentDom" listener in stylesheetparser/plugin.js?
comment:6 Changed 12 years ago by
Status: | review_failed → review |
---|
Replying to a.nowodzinski:
The following test fails on t/10136: http://ckeditor4.t/dt/plugins/stylescombo/stylescombo.html?name=test-external-styles-are-registerd-in-ACF
In case when stylesheetparser isn't loaded we can't wait until contentDom, because styles rules have to added to ACF before first setData. Fixed.
Additionally, shoudn't we have "once" as well in the "contentDom" listener in stylesheetparser/plugin.js?
Yep. Fixed.
comment:7 Changed 12 years ago by
Status: | review → review_failed |
---|
The proposed fix creates a implicit dependency between those plugins... if one of them change their code, it will break the other one... the kind of think we should never have.
If no other clear solution is available, we may reconsider this, but we should try a different approach first.
comment:8 Changed 12 years ago by
Status: | review_failed → review |
---|
Pushed dev and tests branches.
I introduced new event - editor#stylesSet. Stylesheetparser cancels it and waits for contentDom to fire it again, this time with all styles. Styles combo listens on stylesSet too and therefore is able to initialize styles asap.
comment:9 Changed 12 years ago by
Status: | review → review_passed |
---|
comment:10 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Fixed on major with git:8abbc10 on dev and f00bdbd on tests.
To reproduce: