Opened 9 years ago
Last modified 9 years ago
#13771 closed Bug
contents.css not built into ckeditor.js — at Version 9
Reported by: | Sergiy Kuzmenko | Owned by: | Tomasz Jakut |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.5.5 |
Component: | General | Version: | |
Keywords: | Cc: |
Description (last modified by )
Fix code is fine, while tests could definitely be a little simplified. E.g.
- there's no point in making
name
var, as it's used only once, and it does not improve readability. Same goes forbot
, just compare:
'check if font size combo loads proper stylesheet': function() { var bot = this.editorBot, name = 'FontSize'; bot.combo( name, function( combo ) { var isPresent = searchForStylesheet( combo ); assert.isTrue( isPresent, 'check if stylesheet is present in font size combo\'s iframe' ); } ); },
to:
'check if font size combo loads proper stylesheet': function() { this.editorBot.combo( 'FontSize', function( combo ) { var isPresent = searchForStylesheet( combo ); assert.isTrue( isPresent, 'check if stylesheet is present in font size combo\'s iframe' ); } ); },
isPresent
is a different case here as
var isPresent = searchForStylesheet( combo ); assert.isTrue( isPresent, 'check if stylesheet is present in font size combo\'s iframe' );
might actually be more readable than:
assert.isTrue( searchForStylesheet( combo ), 'check if stylesheet is present in font size combo\'s iframe' );
So I can see how it might improve readability - that being said I'm fine with one way or another in this particular case.
- Stay DRY, extract
searchForStylesheet
function to_helper/tools.js
in your tests directory. - Utilize advantage of our
CKEDITOR.dom.*
wrappers, initial lines insearchForStylesheet
method might be simplified down to:
var frameDoc = combo._.panel.element.getFirst().getFrameDocument(), stylesheets = frameDoc.find( 'link[rel="stylesheet"]' ).$;
Not only that, using this you no longer need to check rel attribute.
Then you can actually think about rewriting it to:
function searchForStylesheet( combo ) { var frameDoc = combo._.panel.element.getFirst().getFrameDocument(); // Look for any stylesheet link elems that end with desired CSS file. return Boolean( frameDoc.findOne('link[rel="stylesheet"][href$="contents.css"]') ); }
I'd suggest you just to go through most important namespaces now:
- CKEDITOR.dom.node
- CKEDITOR.dom.element (this time use show dropdown and exclude Inherited, as you don't need to read node methods again :))
- CKEDITOR.dom.event
- CKEDITOR.dom.document
- CKEDITOR.dom.window
Then read other
CKEDITOR.dom.*
member docs the other day! :)
- It's great that you've thought about multiple editor creators! You can do it way simpler, without code duplication. Use
bender.editors
property, for example usage see table plugin tests.
Change History (9)
comment:1 Changed 9 years ago by
Component: | Project : CKBuilder → General |
---|---|
Milestone: | → CKEditor 4.5.4 |
Status: | new → confirmed |
Version: | 4.5.3 |
comment:2 Changed 9 years ago by
Probably not the skin: downloading a standard build with Moono Dark works fine. Custom builds do include contents.css, it's just not built into ckeditor.js
comment:3 Changed 9 years ago by
The contents.css file is never built into ckeditor.js. It's loaded automatically though if everything works fine.
comment:4 Changed 9 years ago by
Here's what I get:
- content.css is always present in the build (whether its standard or custom build)
- The difference is ckeditor.js content:
Standard build:
$ grep contents.css ckeditor.js this.editor,d=a.document,a=a.window.getFrame();j.baseProto.detach.call(this);this.clearCustomData();d.getDocumentElement().clearCustomData();a.clearCustomData();CKEDITOR.tools.removeFunction(this._.frameLoadedHandler);(d=a.removeCustomData("onResize"))&&d.removeListener();a.remove()}}})})();CKEDITOR.config.disableObjectResizing=!1;CKEDITOR.config.disableNativeTableHandles=!0;CKEDITOR.config.disableNativeSpellChecker=!0;CKEDITOR.config.contentsCss=CKEDITOR.getUrl("contents.css");(function(){function e(b,a){a||(a=b.getSelection().getSelectedElement());if(a&&a.is("img")&&!a.data("cke-realelement")&&!a.isReadOnly())return a}function f(b){var a=b.getStyle("float");if("inherit"==a||"none"==a)a=0;a||(a=b.getAttribute("align"));return a}CKEDITOR.plugins.add("image",{requires:"dialog",init:function(b){if(!b.plugins.image2){CKEDITOR.dialog.add("image",this.path+"dialogs/image.js");var a="img[alt,!src]{border-style,border-width,float,height,margin,margin-bottom,margin-left,margin-right,margin-top,width}";
Custom build:
$ grep contents.css ckeditor.js <nothing>
This definitely looks like a build issue to me. Especially that at runtime there's no attempt to load contents.css.
comment:5 Changed 9 years ago by
That's exactly the question - which plugin loads contents.css and what to do if it's not enabled in one's editor.
comment:6 Changed 9 years ago by
Milestone: | CKEditor 4.5.4 → CKEditor 4.5.5 |
---|
comment:7 Changed 9 years ago by
Owner: | set to Tomasz Jakut |
---|---|
Status: | confirmed → assigned |
comment:8 Changed 9 years ago by
Status: | assigned → review |
---|
The problem was caused by the fact that contents.css was loaded only if wysiwygarea plugin was present. Without it that file wouldn't be available.
The fix is rather simple: move the config entry for contents.css from plugin to the main config file - it's on branch:t/13771.
comment:9 Changed 9 years ago by
Description: | modified (diff) |
---|---|
Status: | review → review_failed |
Fix code is fine, while tests could definitely be a little simplified. E.g.
- there's no point in making
name
var, as it's used only once, and it does not improve readability. Same goes forbot
, just compare:
'check if font size combo loads proper stylesheet': function() { var bot = this.editorBot, name = 'FontSize'; bot.combo( name, function( combo ) { var isPresent = searchForStylesheet( combo ); assert.isTrue( isPresent, 'check if stylesheet is present in font size combo\'s iframe' ); } ); },
to:
'check if font size combo loads proper stylesheet': function() { this.editorBot.combo( 'FontSize', function( combo ) { var isPresent = searchForStylesheet( combo ); assert.isTrue( isPresent, 'check if stylesheet is present in font size combo\'s iframe' ); } ); },
isPresent
is a different case here as
var isPresent = searchForStylesheet( combo ); assert.isTrue( isPresent, 'check if stylesheet is present in font size combo\'s iframe' );
might actually be more readable than:
assert.isTrue( searchForStylesheet( combo ), 'check if stylesheet is present in font size combo\'s iframe' );
So I can see how it might improve readability - that being said I'm fine with one way or another in this particular case.
- Stay DRY, extract
searchForStylesheet
function to_helper/tools.js
in your tests directory. - Utilize advantage of our
CKEDITOR.dom.*
wrappers, initial lines insearchForStylesheet
method might be simplified down to:
var frameDoc = combo._.panel.element.getFirst().getFrameDocument(), stylesheets = frameDoc.find( 'link[rel="stylesheet"]' ).$;
Not only that, using this you no longer need to check rel attribute.
Then you can actually think about rewriting it to:
function searchForStylesheet( combo ) { var frameDoc = combo._.panel.element.getFirst().getFrameDocument(); // Look for any stylesheet link elems that end with desired CSS file. return Boolean( frameDoc.findOne('link[rel="stylesheet"][href$="contents.css"]') ); }
I'd suggest you just to go through most important namespaces now:
- CKEDITOR.dom.node
- CKEDITOR.dom.element (this time use show dropdown and exclude Inherited, as you don't need to read node methods again :))
- CKEDITOR.dom.event
- CKEDITOR.dom.document
- CKEDITOR.dom.window
Then read other
CKEDITOR.dom.*
member docs the other day! :)
- It's great that you've thought about multiple editor creators! You can do it way simpler, without code duplication. Use
bender.editors
property, for example usage see table plugin tests.
Confirmed. Interesting issue. I don't think it's related top the builder, but rather to the chosen plugins. Somehow, missing one of them makes dropdowns not aware of contents.css. It may also be something related to the skin, so that should be checked too.