#4809 closed Bug (fixed)
Table caption tag is output in wrong place
Reported by: | pomu0325 | Owned by: | Garry Yao |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 3.5.3 |
Component: | Core : Tables | Version: | 3.0.1 |
Keywords: | Cc: | pomu@… |
Description
<caption> is output after <thead>. Seems to be the same issue with #2874. Occurs with IE and FF. Chrome seems to work fine.
To Reproduce
- Insert new table with <th> and caption using table dialog.
- Switch to source mode.
<table border="1" cellpadding="1" cellspacing="1" style="width: 200px"> <thead> <tr> <th scope="col"> </th> <th scope="col"> </th> </tr> </thead> <caption> foo</caption> <tbody> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </tbody> </table>
Attachments (2)
Change History (13)
Changed 15 years ago by
Attachment: | 4809.patch added |
---|
comment:1 Changed 15 years ago by
Keywords: | Confirmed HasPatch added |
---|
comment:3 Changed 15 years ago by
Will the bug be solved in any oficial release of CKEditor? It's a bit tedious have to change it every time you update the editor.
comment:4 Changed 14 years ago by
Milestone: | → CKEditor 3.5.2 |
---|
comment:5 Changed 14 years ago by
Component: | General → Core : Tables |
---|
Changed 14 years ago by
Attachment: | 4809_2.patch added |
---|
comment:6 Changed 14 years ago by
Keywords: | HasPatch removed |
---|---|
Owner: | set to Garry Yao |
Status: | confirmed → review |
comment:7 Changed 14 years ago by
Hi.
Thank you for the patch, but there is a small mistake in the order of the TFOOT and TBODY elements.
According to the HTML specification, TFOOT have to appears before TBODY in the source code, otherwise the generated code will have validation errors.
comment:8 Changed 14 years ago by
Status: | review → review_passed |
---|
Make sure to update the code according to @jorgeoa's comment above.
comment:9 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Fixed with [6431], thanks for jorgeoa's remind.
comment:10 Changed 13 years ago by
Are we sure the logic for this patch is correct? (Source edited w/ http://dev.ckeditor.com/changeset/6544.) Yes, tags are ordered according to tableOrder, but same-named tags are re-ordered unintentionally.
Path source:
return node1.type == CKEDITOR.NODE_ELEMENT && node2.type == node1.type ? CKEDITOR.tools.indexOf( tableOrder, node1.name ) > CKEDITOR.tools.indexOf( tableOrder, node2.name ) ? 1 : -1 : 0;
For example, with this logic and the given the following source:
<table> <colgroup id="B"> </colgroup> <colgroup id="A"> </colgroup> <caption id="B"> </caption> <caption id="A"> </caption> ... </table>
Results in:
<table> <caption id="A"> </caption> <caption id="B"> </caption> <colgroup id="A"> </colgroup> <colgroup id="B"> </colgroup> ... </table>
Note that the caption tag ordering was changed to before colgroup, but the ordering of the caption and colgroup tags changed relative to their peer. This changes the style applied to each column.
This logic works:
if (node1.type == CKEDITOR.NODE_ELEMENT && node2.type == node1.type) { var idx1 = CKEDITOR.tools.indexOf( tableOrder, node1.name ); var idx2 = CKEDITOR.tools.indexOf( tableOrder, node2.name ); if (idx1 > idx2) { return 1; } else if (idx1 < idx2) { return -1 } } return 0;
comment:11 Changed 12 years ago by
@cwall please note that only one caption is allowed per table and it should be inserted right after table tag (http://www.w3schools.com/tags/tag_caption.asp). Fixing the code to:
<table border="1"> <caption id="A"> aa</caption> <colgroup id="B"> <col style="background-color:red" /> </colgroup> <colgroup id="A"> <col style="background-color:yellow" /> </colgroup> <tbody> <tr> <th> ISBN</th> <th> Title</th> </tr> <tr> <td> 3476896</td> <td> My first HTML</td> </tr> </tbody> </table>
and checking it in latest CKEditor 3.6.6.1 or 4.1.1 resulted in no reordering so i think logic is correct. If I have missed anything please leave a comment.
I know it's a bit forcible way but it worked with IE/FF/Chrome