Opened 11 years ago
Closed 11 years ago
#11004 closed Bug (fixed)
Image2: dialog is not integrated with ACF
Reported by: | Piotrek Koszuliński | Owned by: | Olek Nowodziński |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.3.3 |
Component: | General | Version: | 4.3 Beta |
Keywords: | Cc: |
Description
Fields like hasCaption and alignment should have requiredContent defined.
Change History (21)
comment:1 Changed 11 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 11 years ago by
Owner: | set to Olek Nowodziński |
---|---|
Status: | confirmed → assigned |
comment:3 Changed 11 years ago by
Status: | assigned → review |
---|
comment:4 follow-up: 5 Changed 11 years ago by
Status: | review → review_failed |
---|
Fixed: Don't set empty alt="" of <img> when no Alt. Text specified.
Alt is required - HTML is invalid without it. So we have to add it, even if it's empty.
comment:5 Changed 11 years ago by
Status: | review_failed → review |
---|
Replying to Reinmar:
Fixed: Don't set empty alt="" of <img> when no Alt. Text specified.
Alt is required - HTML is invalid without it. So we have to add it, even if it's empty.
Discarded that commit and test branch.
comment:7 Changed 11 years ago by
Status: | review → review_failed |
---|
- Set allowedContent to
p; img[src]
and open image2 sample. - Double-click 1st image.
- Change src to image2.jpg.
- Save.
- Switch to source mode.
- Expected:
<p><img alt="" src="assets/image2.jpg" /></p>
- Actual:
<p><img alt="" height="480" src="assets/image2.jpg" width="534" /></p>
Please write tests for most important cases (at least two, three tcs: open dialog, check visible fields, save and check data).
comment:8 Changed 11 years ago by
PS.
- By important I meant probable.
- Remember that only one of width, height may be allowed. It will be the easiest to handle that in
#data
event. - Remember about resize handler - it should be disabled when width and height are not allowed.
comment:9 Changed 11 years ago by
Status: | review_failed → review |
---|
Created branch t/11004 in tests:
- Testing the visibility of dialog fields according to
allowedContent
of the editor. - Testing
data
function to check if produced HTML is consistent with ACF rules of the editor. - Testing the presence of widget resizer according to ACF rules of the editor.
- Testing justify plugin integration: justify command states according to ACF rules when widget is selected.
Pushed several commits to dev making all tests green.
Notes and remarks:
- We really need rich
requiredContent
, defined as a logical AND/OR of two or more elements with different set of attributes/classes/styles.
At the moment,
requiredContent
ofhasCaption
in Image2 dialog isfigcaption
. It's a very poor assertion sincefigure
is also required to create a right captioned image.
Another example:
requiredContent
ofalign
field isimg[float]
. But we need alsofigure[float]
anddiv p{text-align}
, don't we? There are so many cases where dialog layout would fail due to specific ACF rules.
- Regarding 1.: This more than a dialog-related thing. To produce consistent HTML,
widgetDef#data
should also followrequiredContent
defined in dialog (and vice-versa). At the moment, even iffigcaption
is allowed butfigure
isn't, thehasCaption
field will be displayed in the dialog andwidgetDef#data
will inject<figure>
into editable. The same<figure>
will be also ineditor#getData
output. It's bad, really.
- Alignment fields in dialog (left, right, etc.) should be displayed conditionally according to ACF rules.
comment:10 Changed 11 years ago by
Milestone: | CKEditor 4.3.1 → CKEditor 4.3.2 |
---|---|
Status: | review → review_failed |
I realised that by hardcoding allowed and required content strings we're making impossible to use other data formats by overwriting upcast and downcast methods. Let's rethink this ticket then.
My idea is that we can extract those rules to overwritable object. For example widget.definition could have a features property with:
features: { alignedImage: { requiredContent: '...', allowedContent: '...' }, captionedImage: { requiredContent: '...', allowedContent: '...' } }
All rules needed for dialog and internal logic could be stored this way what would make the extension possible.
comment:11 Changed 11 years ago by
Milestone: | CKEditor 4.3.2 → CKEditor 4.3.3 |
---|
comment:12 Changed 11 years ago by
Status: | review_failed → review |
---|
Pushed updated solution to t/11004b (+tests).
comment:13 Changed 11 years ago by
Status: | review → review_failed |
---|
About dev changes:
- allowedContent in input definitions does nothing. What's funny - you didn't even defined allowedContent in image2.features :D.
- requiredContent of entire widget should contain
img[!src,alt]
. - Since alt is a required attribute in HTML, there's no need to define rules for it - its input should be always displayed and this attr should be always set.
- Result of check( features.align.requiredContent ) should be cached in alignCommandIntegrator because commands may be refreshed pretty often. Although, this function is executed before ACF rules are ready, so the result has to be cached after first check.
comment:14 Changed 11 years ago by
Tests:
- Automated tests look well. You'll need of course to update them after changes related to alt attribute.
- Manual tests went gr8 too. I only noticed that it's not possible to allow only width, without allowing height, but I understand that it would require a lot of work to separate them.
comment:15 Changed 11 years ago by
Maybe one more thing - would it be possible to separate centering image2 from other alignments? It's rather easy to define acf for right/left/none, but some developers may not like centering.
comment:16 Changed 11 years ago by
Status: | review_failed → review |
---|
Just updated dev and test branches.
I only noticed that it's not possible to allow only width, without allowing height, but I understand that it would require a lot of work to separate them.
That's true. It's a mess.
Maybe one more thing - would it be possible to separate centering image2 from other alignments? It's rather easy to define acf for right/left/none, but some developers may not like centering.
I started coding this feature and, though pretty and easy it is for a dialog, it automatically affects integration with Justify and dozens of other things. Once I had realized that it's a lot of work (and even more tests!) I basically abandoned the idea.
Manual tests required.
comment:17 Changed 11 years ago by
Status: | review → review_failed |
---|
As I thought, buttons are registered to ACF after alignCommandIntegrator
call. However, because of #11567, which we'll fix in 4.4, the image2 widget is registered before that. Status of alignment commands won't be correctly recognized after we #11567 is closed, so better to have the check fixed now.
Although, this function is executed before ACF rules are ready, so the result has to be cached after first check.
comment:18 Changed 11 years ago by
Except comment:17 and:
/www/cksource/ckeditor-dev/plugins/image2/plugin.js(145): warning: trailing comma is not legal in ECMA-262 object initializers }, ................................^
everything looks ok.
comment:19 Changed 11 years ago by
Status: | review_failed → review |
---|
comment:21 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
git:24f7406 landed in master (ba12e9f tests).
t/11004 (+tests) contains:
alt=""
of<img>
when no Alt. Text specified.requiredContent
docs.