From b23800a55bb80997449a4d94c2dc811ea3afcf6a Mon Sep 17 00:00:00 2001 From: Catrope Date: Sat, 7 Jul 2012 13:00:17 -0700 Subject: [PATCH] First stab at list indent/outdent This works pretty well, the only problems I found are: * when selecting multiple list items, only the first is in/outdented * there's no special handling for child lists, so the behavior for in/outdenting list items that have a child list can look weird, but it's consistent Also needs more documentation Change-Id: I6f4f3725e57a590196d7d638a77b87ea85586dc8 --- .../ui/tools/ve.ui.IndentationButtonTool.js | 212 +++++++++++++++--- 1 file changed, 180 insertions(+), 32 deletions(-) diff --git a/modules/ve/ui/tools/ve.ui.IndentationButtonTool.js b/modules/ve/ui/tools/ve.ui.IndentationButtonTool.js index 0bc0bbd55f..699504a293 100644 --- a/modules/ve/ui/tools/ve.ui.IndentationButtonTool.js +++ b/modules/ve/ui/tools/ve.ui.IndentationButtonTool.js @@ -46,45 +46,195 @@ ve.ui.IndentationButtonTool.prototype.onClick = function() { }; ve.ui.IndentationButtonTool.prototype.indent = function( listItems ) { - // FIXME old code, doesn't work - var surface = this.toolbar.surfaceView, - styles, - i, - tx; + var surfaceModel = this.toolbar.getSurfaceView().getModel(), + documentModel = surfaceModel.getDocument(), + selection = surfaceModel.getSelection(), + groups = documentModel.getCoveredSiblingGroups( selection ); - for ( i = 0; i < listItems.length; i++ ) { - styles = listItems[i].getElementAttribute( 'styles' ); - if ( styles.length < 6 ) { - tx = surface.model.getDocument().prepareElementAttributeChange( - surface.documentView.model.getOffsetFromNode( listItems[i], false ), - 'styles', - styles.concat( styles[styles.length - 1] ) - ); - surface.model.change( tx ); + function indentListItem( listItem ) { + /* + * Indenting a list item is done as follows: + * 1. Wrap the listItem in a list and a listItem (
  • -->