Opened 9 years ago
Closed 9 years ago
#13829 closed Bug (fixed)
Add class based on widget type to the widget wrapper
Reported by: | Marek Lewandowski | Owned by: | Szymon Kupś |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.6.0 |
Component: | General | Version: | |
Keywords: | Cc: |
Description (last modified by )
This is a follow-up of #13200 issue.
As @Reinmar writes:
Inability to write rules matching certain widget wrapper + widget class
Once classes will be moved to wrappers it would be good if it was possible to write rules like:
.image.centered { ... } .embed.centered { ... }As I experienced recently centered image's wrapper may need very different styles than that of an embed widget. E.g. image's wrapper must have text-align: center. This affects embed widgets which may be unwanted if we only want to use margin-left/right: auto.
Hence, it will be useful if widget wrapper had classes based on widgets names - e.g. "widget-image", "widget-embed", etc.
Change History (10)
comment:1 Changed 9 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 9 years ago by
Description: | modified (diff) |
---|
comment:3 Changed 9 years ago by
comment:4 Changed 9 years ago by
Owner: | set to Szymon Kupś |
---|---|
Status: | confirmed → assigned |
comment:5 Changed 9 years ago by
Status: | assigned → review |
---|
Pushed branch:t/13829.
Added CSS class based on pattern cke_widget_<widgetname>
to the widget wrapper.
comment:6 Changed 9 years ago by
Status: | review → review_failed |
---|
Your solution relied on widgetName
param which (as doc says) is optional. This argument is not given e.g. in widget upcasting (happens when you paste a widget).
- Open a page with editor and any widget plugin.
- Add a widget.
- Move selection to the other place of the document.
- Type one letter.
- Press
ctrl + z
once (undo).
Expected: Your widget should keep the cke_widget_<name>
class.
Expected: The class is removed.
Other case might include copy & paste or drag & dropping the widget.
I've added some changes to t/13829 branch, please check it and tell if my patch looks fine. If so change ticket status to review_passed, add a changelog entry and merge branch to branch (more info in docs).
comment:7 Changed 9 years ago by
Status: | review_failed → assigned |
---|
comment:8 Changed 9 years ago by
Status: | assigned → review |
---|
I've pushed one commit to branch:t/13829 - changed regular expression in widgetWrapperAtributes
to match two tests in http://tests.ckeditor.dev:1030/tests/plugins/widget/widgetsintegration
comment:9 Changed 9 years ago by
Status: | review → review_failed |
---|
That last commit indeed fixes these tests.
As for the modifications by @m.lewandowski: I tested how this works with copying/pasting, drag & drop, mode switching and the class was there each time.
As for the code: I have one issue that I believe deserves attention: https://github.com/cksource/ckeditor-dev/blob/t/13829/plugins/widget/plugin.js#L644
This condition is always true.
comment:10 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | review_failed → closed |
Fixed the always-true condition problem, since it's a minor thing.
Fixed with git:45f3e0e84afddbcfaeebe939a364a61bef905f15.
Let's use prefixed class names so we'd end up with classes like
cke-widget-image
,cke-widget-codesnippet
etc.