Opened 13 years ago
Closed 12 years ago
#10027 closed Bug (fixed)
Allow list-only indentation
| Reported by: | Piotrek Koszuliński | Owned by: | Olek Nowodziński |
|---|---|---|---|
| Priority: | Normal | Milestone: | CKEditor 4.2 |
| Component: | Core : Lists | Version: | |
| Keywords: | Drupal | Cc: | wim.leers@… |
Description
Currently indent plugin allows two things:
- indenting block elements like
<p>, <h1>, etc. either with margin-left style or classes defined in config.indentClasses, - creating nested (indented) lists structures (e.g
ul > li > ol > li).
These features should be split (to two separate plugins?) or option allowing to disable one of them should be introduced (e.g. config.indentOnly='lists|blocks'?).
Change History (20)
comment:1 Changed 13 years ago by
| Status: | new → confirmed |
|---|
comment:2 Changed 13 years ago by
| Milestone: | CKEditor 4.1 |
|---|
comment:4 Changed 13 years ago by
Can't we avoid the core stuff, using the very same proposal. At this point we would have this:
- "indent" plugin that creates the buttons and delivers the "core" part of the indentation stuff, firing events and doing the generic job.
- "indentlist" and "indentblock" plugins, doing what they're suppose to do, using the "indent" plugin API. Both would depend on "indent".
Still one thing is not clear... what abou the ENTER key? Would it simply depend on "indentlist"? Sounds like an ok way for it.
comment:5 Changed 13 years ago by
Exactly - there's no need to add anything to core. Indent buttons and commands should be added by "indent" plugin required by "indentlist" and "indentblock" plugins.
The enter key IMO needs just a few lines of the current "outdent" command. It uses it just for simplicity. I'm for fully independent commands, because "indentlist" would have to require "indent" too and most likely "list" as well!. So all these plugins would be required by "enter" plugin? Noo...
Especially that we were considering merging "enter" plugin into the core (by creating a class grouping keyboard handlers which are now spread across editable class and enter plugin) and core cannot require a plugin.
comment:6 Changed 13 years ago by
| Owner: | set to Olek Nowodziński |
|---|---|
| Status: | confirmed → assigned |
comment:7 Changed 13 years ago by
| Milestone: | → CKEditor 4.2 |
|---|
comment:9 Changed 13 years ago by
| Status: | assigned → review |
|---|
Created branches t/10027 in dev and tests.
Dev
t/10027 introduces a new indentation system with three separate plugins: indent, indentlist and indentblock.
indentplugin: handles UI (buttons), defines generic indent and outdent commands that fireexecandrefreshevents handled by content-specific commands.
indentlistplugin: handles list indentation (<ul>,<ol>), definesindentlistandoutdentlistcommands. This plugin can nest lists and collapse them into paragraphs. It brings TAB key support for indenting and outdenting lists.
indentblockplugin: handles generic indentation (with CSSmargin-left|right) of blocks (also<ul>and<ol>when nesting isn't possible), definesindentblockandoutdentblockcommands. It brings TAB key support for indenting and outdenting lists with CSSmargin-left|right.
t/10027 also brings indent dev sample for easy testing.
In this ticket I focused on porting previous functionality which, even if sometimes buggy (#7006), is still predictable and users don't complain about it.
Tests
Significantly increased test coverage (previously only edge cases), including:
- lists
- various blocks (paragraphs, divs, tables)
- indent classes
- indent units
- initial command states
- ENTER_BR behavior
- keystrokes
indentlistandindentblock-only cases
Note: two tests will fail until #10439 is resolved - this is intentional.
Issues
I'm still wondering whether indentlist, outdentlist, indentblock and outdentblock should be editor commands or not. They can be independently called and used but i.e. they don't revert selection (indent plugin does) which makes them hard to use. I'm for having them outside of command system to not to confuse users.
Misc
This ticket resolves #8244.
comment:10 Changed 13 years ago by
I couldn't find any bugs. I tried every permutation of actions I could think of (which is probably not every possible permutation, but still). I checked the markup, the tabbing behavior and button states.
Finally, this indeed solves #8244.
Wonderful :)
comment:11 Changed 13 years ago by
I'm glad to hear that. However I'm pretty sure that Fred is gonna find something odd ;) Some code refactoring is still possible.
comment:12 follow-up: 14 Changed 12 years ago by
| Status: | review → assigned |
|---|
I see that you're bringing changes to the enter key code but no new test for it.
I'm not stating that anything is wrong but it would be good the check the status of the tests and eventually add new ones, if necessary.
comment:14 Changed 12 years ago by
| Status: | assigned → review |
|---|
Replying to fredck:
I see that you're bringing changes to the enter key code but no new test for it.
I'm not stating that anything is wrong but it would be good the check the status of the tests and eventually add new ones, if necessary.
You were right. I created several tests for enterkey in lists and found out that it's broken. I created more tests that revealed that even the original implementation was buggy. E.g.:
- When splitting a list into two separate lists (enter in empty element, neither first or last child), the
idattribute was preserved for both of them, bringing two nodes of the sameidinto DOM.
- Using enter in the first (empty) element of the list, which is inside of another list, moved caret to the beginning of editable (pretty WTFish).
I fixed all the bugs introduced by #10027 along with the bugs of the old implementation.
Question: While in ENTER_BR, what is the correct tag to be created when a block must be created (e.g. inheriting class, style, etc.)? <div> or <p>?
comment:15 Changed 12 years ago by
| Status: | review → review_failed |
|---|
I'm having 2 reds here:
http://ckeditor4.t/dt/plugins/indent/indent.html
Additionally, there is a mixture of TABS and SPACEs in the indentation of comments in enterkey/plugin.js.
comment:16 Changed 12 years ago by
| Status: | review_failed → review |
|---|
- I moved red tests to where they belong (#10439).
- Fixed tab/space mess (shame, shame...)
- Fixed code style.
- Made content-specific commands internal for indentation system (no longer editor commands, see comment:9).
- Brought back ol' and naive outdent
startupDisabledsince command states will be resolved in #10439.
comment:17 Changed 12 years ago by
| Status: | review → assigned |
|---|
I'm cancelling the review as additional changes to the code are necessary as discussed in a private call with Olek.
comment:18 Changed 12 years ago by
| Status: | assigned → review |
|---|
Rebased t/10027 (dev+tests) on latest major.
- Introduced job-based indentation system that completely separates block-based and nesting-based indentation.
- Extended docs.
- Extended tests.
- Major code refactoring and optimization.
comment:19 Changed 12 years ago by
| Status: | review → review_passed |
|---|
comment:20 Changed 12 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | review_passed → closed |
Merged fix into master, dev (git:41cbd9d), tests (0f6fc5b).
This ticket also resolves #8244.

Extracted from #10192:
p || lias arequiredContentfor indent plugin.The above are quick patches to let enterkey close lists correctly. The reasoning is as follows:
outdentcommand).requiredContentofp{margin-left}.config.allowedContent = 'p ul ol li'disables indent (nomargin-left)Although #10192 solves the issue, indent's
requiredContent = [ 'p{margin-left}', 'li' ]brings some troubles.Since #10192, setting
config.allowedContent = 'p li'enablespindentation without explicitconfig.allowedContent = '...p{margin-left}...'. This is why indent plugin must be smarter to consider ACF rules when enabling/disabling commands. This implies a major refactorization of indent'srefreshandexecmethods to handle several new cases.The main inconvenience is that list indentation and block indentation should be handled separately by list/indent and share the same button set. The idea is as follows:
indent|outdentListandindent|outdentBlockin separate plugins (list, indent).indent|outdent.indent|outdentcommands control toolbar buttons.indent|outdentevents which, passed or canceled by the listeners, would do the work. List and indent plugins would listen onindent|outdentevents and decide (considering ACF) whether any action can be performed:indent|outdentListandindent|outdentBlockwould fireindent|outdentRefreshevent which, handled byindent|outdentcommands in core, would enable or disable them (+buttons).indent|outdentRefreshwould basically provide information aboutindent|outdentstates as seen fromindent|outdentListandindent|outdentBlockcommands."Core"
indent|outdentcommands and events can be eventually delegated to a separate plugin (let's call it indentUi) which would also create toolbar buttons. This will let us avoid redundant button invokation code in list and indent. This has also some other advantages:indent|outdentevents, do custom job and control UI interface states.action action ^ ^ | | +----+ execute +------------+ in|outdent evt +-----+-----+ in|outdent evt +-----+-----+ in|outdent evt | |+------------>| |+---------------->| |+- - - - - - - - >| |+- - - - - - - - - . . . | UI | | indentUi | | plugin #1 | | plugin #2 | | |<------------+| | | | | | +----+ set state +------------+ +-----------+ +-----------+ ^ + + | in|outdentRefresh evt | | +-------------------------------------------------------------+------------------------ . . .