#2885 closed Task (fixed)
Implement the div container command.
Reported by: | Martin Kou | Owned by: | Garry Yao |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 3.1 |
Component: | General | Version: | 3.0 Beta 2 |
Keywords: | Confirmed Review+ | Cc: |
Description
Need to implement the div container command and add it to the toolbar.
Attachments (12)
Change History (43)
comment:1 Changed 16 years ago by
Owner: | changed from Martin Kou to Garry Yao |
---|---|
Status: | new → assigned |
Changed 16 years ago by
Attachment: | 2885.patch added |
---|
comment:2 Changed 16 years ago by
Keywords: | Confirmed Review? added |
---|
comment:3 Changed 16 years ago by
Keywords: | Review- added; Review? removed |
---|
Ok... The review took quite some time because I needed to sift through the ticket system and previous code for precedences. Feeling like being a lawyer here.
_source/plugins/newcontainer/plugin.js:
- Line 32-48 - Plugin config entries must not use sub-namespaces. Refer to #2822.
- Line 11-30 - Now that you aren't declaring anything in the local namespace, there's no need for the outermost closure.
- Except for special cases like...
function abc() { // This return does not work in Firefox - it returns undefined. return { attr : value }; }
It is recommended that you follow the style conventions in other existing source files for literal object "blocks" - i.e. The opening bracket should occupy a new line instead of staying at the same line as the preview token.
_source/core/dom/element.js:
- Line 378 - The regular expression is wrong. It matches non-pure-whitespace texts like "Hello world" or "There are some spaces in me".
_source/core/tools.js:
- Line 320-323 - isEmpty() is not really needed for parsing form field values. Because when the user fills in 0, the value is the string "0" which evaluates to true. Empty form fields automatically evaluates to false because empty strings are false.
- Line 329-331 - cloneArray() isn't really needed nor does it simplify anything. Writing someArray.concat( [] ) is much shorter than CKEDITOR.tools.cloneArray( someArray ), and is just as easy to understand.
_source/lang/en.js:
- Lines 12-13 - Please don't remove the indenting whitespaces. If you want to fix the styles in these two lines, there's something else you can fix here.
- Lines 375-387 - These entries are already defined in the common strings above, please delete them from the lang file and reuse the common strings in your dialog, so we can have less translation entries to take care of.
- Lines 384-387 - Please don't add unnecessary sub-namespaces inside your lang namespace, it's only serving to increase code size without any benefits to readability.
_source/plugins/newcontainer/dialogs/newcontainer.js:
- Lines 214-323 - Please follow the current convention for writing the arrays and object literals in dialog files. Instead of...
children : [{ ...
You should write
children : [ { ... } ]
Unless you've encountered some errors like the function example above.
- Lines 183-202: Now that we have CKEDITOR.dom.node::getCommonAncestor(), you don't really need to define this function again in your dialog. To get the common ancestor of multiple nodes, use a loop.
- The dialog's setup and commit phases should use the setup/commit system introduced in [2990]. This is done in order to facilitate third party developers to add and remove dialog fields and even tabs. Refer to the table or the checkbox dialog in [2990] for how it is done.
comment:4 Changed 16 years ago by
_source/plugins/newcontainer/dialogs/newcontainer.js:
- Lines 77-86, 104-129 - The indexOf() operation in these loops are unnecessarily increasing these loops' run time complexity to O(n2). Recommend to use the marker functions under CKEDITOR.dom.element for marking processed nodes.
Changed 16 years ago by
Attachment: | 2885_2.patch added |
---|
comment:5 Changed 16 years ago by
Keywords: | Review? added; Review- removed |
---|
Fine grained review, the updated patch is fixing all the issues mentioned in Martin's above comments, it also BTW fix a minor bug inside CKEDITOR.dom.element.clearMarkers
comment:6 Changed 16 years ago by
Keywords: | Review- added; Review? removed |
---|
Still a few bugs:
- I think I've mentioned this to you on Skype already. The div container command is supposedly used for laying out documents, so there's no limit on the number of div containers you can nest. Thus, the create div command should already create a new div to enclose all selected blocks, including previously created div containers.
To let users edit existing div containers, there should be a separate edit div command, which edits the div nearest to the selection range. The edit div command is expected to be accessible via context menu. We don't have a context menu yet, but that command still needs to be implemented and tested (via a toolbar button for testing purpose).
- Line 98 should be
ancestor = ancestor.getCommonAncestor( blockGroups[ i ][ j ], true );
Missing the true flag means that if multiple blocks are selected and the create div command is executed, then you get a JavaScript error. - The problems mentioned in _source/lang.en.js are still not fixed.
- Now that the toolbar button layout is changed, please place your create div toolbar button after the blockquote button in your new patch. Just like how it was in v2.
Changed 16 years ago by
Attachment: | 2885_3.patch added |
---|
comment:7 Changed 16 years ago by
Keywords: | Review? added; Review- removed |
---|
The updated introduce the following changes after discuss with Martin on Skype:
- Separate edit with create mode which depend on two different commands;
- Make newly created 'div' inserted at correct position;
- Adding a config option CKEDITOR.config.div_wrapTable to distinguish whether newly created 'div' should wrap table or reside in table cell.
- Fixing language file issues.
comment:8 Changed 16 years ago by
The patch also introduce a minor change to CKEDITOR.dom.elementpath which make the block limit elements definitoin list public visitable by putting them inside corresponding namespace.
comment:9 Changed 16 years ago by
Keywords: | Review? removed |
---|---|
Owner: | changed from Garry Yao to Martin Kou |
Status: | assigned → new |
Taking over the ticket to add context menu and the TODO features.
Changed 16 years ago by
Attachment: | 2885_4.patch added |
---|
comment:10 Changed 16 years ago by
Keywords: | Review? added |
---|
Proposing a new patch, which fixes the following issues:
- Added edit div container and remove div container context menu options.
- Fixed the style input in div container dialog.
- Fixed a bug with the div container dialog which causes it to not work for the following case:
<p> paragr^aph 1</p> <div> <p> paragraph 2</p> <p> paragraph 3</p> </div> <p> paragr^aph 4<br /> </p>
- Fixed JavaScript error in IE.
comment:11 Changed 16 years ago by
Keywords: | Review- added; Review? removed |
---|
- Why has the "cke_button_creatediv" button been defined in the toolbar.css file, while others have been properly defined in icons.css?
- It misses the skin changes (icons) for the office2003 skin.
- As already defined before, there should not be "default" values in the settings.
- The "div" plugins requires "elementspath", but I can't understand the correlation between them.
- The dialog is too big, with a lot of blank space at the bottom. Has it been tested at all?!
- The getNonEmptyChildren doesn't look like a good addition to the API, and it's used by the div dialog only. It should be then moved to that dialog code as a private, instead on enlarging the CKEDITOR.dom.element class.
- Instead of having CKEDITOR.dom.elementPath.pathBlockLimitElements, we should instead have CKEDITOR.dtd.$blockLimit at this point.
Changed 16 years ago by
Attachment: | 2885_5.patch added |
---|
comment:12 Changed 16 years ago by
Keywords: | Review? added; Review- removed |
---|
Changed 16 years ago by
Attachment: | 2885_6.patch added |
---|
comment:14 Changed 16 years ago by
Keywords: | Review- added; Review? removed |
---|
- Debug statement need to be removed on L260 of _source\plugins\div\dialogs\div.js
- 'compareNodes' function on L272 is idle;
- Dialog 'minHeight' config could be reduced, notice that when switch to 'Advanced' tab, it's able to see unnecessary space after the last field.
- Div detection logic on L100 of _source\plugins\div\plugin.js is not right, reproduce with this procedure:
Reproducing Procedures
- Open the replace by class example page;
- Make the following content with selection:
<table> <tr><td><div>te^xt</div></td></tr> </table>
- Right click on the selection position to open context menu;
- Expected Result: There's div editing items on menu;
- Actual Result: The div editing items were not on menu;
Changed 16 years ago by
Attachment: | 2885_7.patch added |
---|
comment:15 follow-up: 16 Changed 16 years ago by
Keywords: | Review? added; Review- removed |
---|
I've fixed point 1 to point 3.
Point 4 is actually the intended result. The div container is a layout element, div nodes that are used as paragraphs do not count.
comment:16 Changed 16 years ago by
Replying to martinkou:
Point 4 is actually the intended result. The div container is a layout element, div nodes that are used as paragraphs do not count.
The input of this TC is actually the out come of apply 'div' with a table cell containing only test, so it's a bug.
comment:17 follow-up: 19 Changed 16 years ago by
Then the lone div added to the table cell is wrong - the div container should never become a paragraph.
The new patch guarantees a div container would always contain paragraphs. It also fixes a bug where a collapsed <p> is seen in Firefox after performing the following procedure:
- Open replacebyclass.html in Firefox.
- Press Ctrl-A and Delete to delete all contents.
- Open Create Div Container dialog.
- Press OK.
- A div container with a collapsed <p> is seen.
Changed 16 years ago by
Attachment: | 2885_8.patch added |
---|
comment:18 Changed 16 years ago by
Keywords: | Review- added; Review? removed |
---|
L232 - L248 of div.js has caused another bug reproduced by :
- Apply div on the following document with selection:
<table> <tr><td>te^xt</td></tr> </table>
- Expected Result :
<table> <tr><td><div><p>te^xt<p></div></td></tr> </table>
- Actual Result:
<table> <tr><td><div><p><br /><p></div></td></tr> </table>
comment:19 Changed 16 years ago by
Changed 16 years ago by
Attachment: | 2885_9.patch added |
---|
comment:20 Changed 16 years ago by
Keywords: | Review? added; Review- removed |
---|
comment:21 Changed 16 years ago by
Keywords: | Review- added; Review? removed |
---|
- The auto paragraph fixing logic make the div container creation more feasible, which should be a good move, but not sure in which case will we use L255-L261 of _source\plugins\div\dialogs\div.js codes?
- Another problem here for IE: No way to create div within empty document in IE, we already have the same require from list plugin,so probably codes at L366-L379 of _source\plugins\list\plugin.js could be reused to archive this.
Changed 16 years ago by
Attachment: | 2885_10.patch added |
---|
comment:22 Changed 16 years ago by
Keywords: | Review? added; Review- removed |
---|
Point 1... I've thought about that a bit in the previous patch as well. But I was worried whether it is still possible for empty div containers to exist at that point. I need to prove that it's impossible for empty div container to be there before deleting that block.
I've deleted that block of code in the new patch. My prove is as follows: For each block group...
- If the created div container had nothing, then L213 - L219 was never executed for the current block group.
- If L213 - L219 was never executed, then the current block group in L205 contains no block.
- But L291 guarantees that each block group will have at least one block.
So L255 - L261 can be deleted.
Point 2... There's no need to copy the block of code from the list plugin. With the current logic, as long as there's something in the document to create div containers from, then at least one div container will be created. I've noticed the applyDiv() function does not save the current selection with bookmarks... So adding bookmarks for the current selection position will fix both problems - it keeps the previous selection intact after adding div containers, and it guarantees that at least one div will be created even in an empty document.
comment:23 Changed 16 years ago by
Milestone: | CKEditor 3.0 → CKEditor 3.1 |
---|
We should be totally focused on the stabilization process for the 3.0 release. This ticket is taking our time from it, so I'm moving to the next release.
comment:24 Changed 16 years ago by
Version: | SVN (FCKeditor) → CKEditor 3.0 Beta 2 |
---|
comment:25 Changed 15 years ago by
Owner: | changed from Martin Kou to Garry Yao |
---|
Changed 15 years ago by
Attachment: | 2885_11.patch added |
---|
comment:26 Changed 15 years ago by
Status: | new → assigned |
---|
Beside update the changes to current trunk, the new patch also targeting the following issues:
- Fix a bug where CKEDITOR.dom.element.setMarker failed on text node in IE ( doesn't allow expand property );
- Simplified the logic for remove/edit div.
Ticket Tests added at :
http://ckeditor.t/tt/2885/1.html.
http://ckeditor.t/tt/2885/2.html.
comment:27 follow-up: 28 Changed 15 years ago by
Keywords: | Review- added; Review? removed |
---|
- I'm still able to reproduce the issue mentioned in Garry's comment.
- Just for Kama, there are no icons to Edit and Remove.
Changed 15 years ago by
Attachment: | 2885_12.patch added |
---|
comment:28 Changed 15 years ago by
Keywords: | Review? added; Review- removed |
---|
Replying to fredck:
I'm still able to reproduce the issue mentioned in Garry's comment.
The result is by purpose, which could somehow distinguish a 'div' been created from this command and the one created as a block-level style, but it's also cumbersome, I've simply removed it.
TCs updated.
comment:29 Changed 15 years ago by
Keywords: | Review+ added; Review? removed |
---|
Before committing:
- There is an extra cke_skin_office2003 style being defined in the Kama (_source/skins/kama/icons.css) files.
- Please move the configuration definition comments from the dialog file to the plugin.js file.
comment:30 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:31 Changed 15 years ago by
The changes should not get into trunk, move it into 3.1.x branch with [4578].
This patch file requires 2871_4.patch