Fix up some tools to not break on selection, added some test selection

stuff to sandbox

Change-Id: Ic97144e634111c489507814c6634c66831726191
This commit is contained in:
Rob Moen 2012-06-06 11:51:19 -07:00
parent 2439c0149a
commit 21ee17a192
3 changed files with 13 additions and 4 deletions

View file

@ -646,7 +646,13 @@ $(document).ready( function() {
var sandboxEditor = new ve.Surface( '#content', HTML[0], options ),
surfaceModel = sandboxEditor.getSurfaceModel(),
documentModel = sandboxEditor.getDocumentModel(),
parent = sandboxEditor.getParent();
parent = sandboxEditor.getParent(),
view = sandboxEditor.view;
/* Rob's test selection stuff */
/*surfaceModel.setSelection( new ve.Range(0, documentModel.getData().length ) );
view.showSelection ( surfaceModel.getSelection() );
console.log (surfaceModel.getSelection().getLength());*/
/* Sandbox Warning Message */

View file

@ -86,8 +86,8 @@ ve.FormatDropdownTool.prototype.updateState = function( annotations, nodes ) {
'attributes': nodes[0].attributes
};
// Look for mismatches, in which case format should be null
for ( i = 1; i < nodes[0].children.length; i++ ) {
if ( format.type != nodes[0].children[i].getElementType() ||
for ( i = 1; i < nodes.length; i++ ) {
if ( format.type != nodes[i].getElementType() ||
!ve.compareObjects( format.attributes, nodes.children[i].element.attributes ) ) {
format = null;
break;

View file

@ -78,7 +78,10 @@ ve.ui.IndentationButtonTool.prototype.outdent = function( listItems ) {
ve.ui.IndentationButtonTool.prototype.updateState = function( annotations, nodes ) {
function areListItems( nodes ) {
for( var i = 0; i < nodes.length; i++ ) {
if ( nodes[i].getParent().getElementType() !== 'listItem' ) {
if (
nodes[i].parent !== null &&
nodes[i].getParent().getElementType() !== 'listItem' )
{
return false;
}
}