Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js |
— | — | @@ -586,9 +586,11 @@ |
587 | 587 | * <p>a</p><p>b</p>| - End of the document |
588 | 588 | * Content locations |
589 | 589 | * <p>|a</p><p>b</p> - Inside an element (like in a paragraph or listItem) |
590 | | - * <p>a|</p><p>b</p> - May also be inside an element but right before/after an open/close |
| 590 | + * <p>a|</p><p>b</p> - May also be inside an element but right before/after an |
| 591 | + * open/close |
591 | 592 | * |
592 | | - * if ( Incoming data contains structural elements ) { // We're assuming the incoming data is balanced, is that OK? |
| 593 | + * if ( Incoming data contains structural elements ) { |
| 594 | + // We're assuming the incoming data is balanced, is that OK? |
593 | 595 | * if ( Insertion point is a structural location ) { |
594 | 596 | * if ( Incoming data is not a complete structural element ) { |
595 | 597 | * Incoming data must be balanced |
— | — | @@ -618,9 +620,10 @@ |
619 | 621 | //debugger; |
620 | 622 | |
621 | 623 | /** |
622 | | - * Return true if can merge the remaining contents of the elements after a selection is deleted across them. |
623 | | - * For instance, if a selection is painted across two paragraphs, and then the text is deleted, the two paragraphs can become one paragraph. |
624 | | - * However, if the selection crosses into a table, those cannot be merged. |
| 624 | + * Return true if can merge the remaining contents of the elements after a selection is deleted |
| 625 | + * across them. For instance, if a selection is painted across two paragraphs, and then the text |
| 626 | + * is deleted, the two paragraphs can become one paragraph. However, if the selection crosses |
| 627 | + * into a table, those cannot be merged. |
625 | 628 | * @param {Number} integer offset |
626 | 629 | * @param {Number} integer offset |
627 | 630 | * @return {Boolean} |
— | — | @@ -628,9 +631,10 @@ |
629 | 632 | function canMerge( range ) { |
630 | 633 | var node1 = doc.getNodeFromOffset( range.start ); |
631 | 634 | var node2 = doc.getNodeFromOffset( range.end - 1 ); |
632 | | - // This is the simple rule we are following for now -- same type & same parent = can merge. So you can merge adjacent paragraphs, or listitems. |
633 | | - // And you can't merge a paragraph into a table row. |
634 | | - // There may be other rules we will want in here later, for instance, special casing merging a listitem into a paragraph. |
| 635 | + // This is the simple rule we are following for now -- same type & same parent = can merge. |
| 636 | + // So you can merge adjacent paragraphs, or listitems. And you can't merge a paragraph into |
| 637 | + // a table row. There may be other rules we will want in here later, for instance, special |
| 638 | + // casing merging a listitem into a paragraph. |
635 | 639 | |
636 | 640 | // wait, some nodes don't have types? Is this the top document node? |
637 | 641 | return ( |
— | — | @@ -675,7 +679,8 @@ |
676 | 680 | // we add one because retain(3,3) really means retain 1 char at pos 3 |
677 | 681 | tx.pushRetain( op.end - op.start + 1 ); |
678 | 682 | } else if ( op.type === 'remove' ) { |
679 | | - // we add one because to remove(3,5) we need to slice(3,6), the ending is last subscript removed + 1. |
| 683 | + // we add one because to remove(3,5) we need to slice(3,6), the ending is last |
| 684 | + // subscript removed + 1. |
680 | 685 | tx.pushRemove( this.data.slice( op.start, op.end + 1 ) ); |
681 | 686 | } else { |
682 | 687 | console.log( "this is impossible" ); |
— | — | @@ -694,7 +699,8 @@ |
695 | 700 | } |
696 | 701 | |
697 | 702 | |
698 | | - // choose a deletion strategy; merging nodes together, or stripping content from existing structure. |
| 703 | + // choose a deletion strategy; merging nodes together, or stripping content from existing |
| 704 | + // structure. |
699 | 705 | if ( canMerge( range ) ) { |
700 | 706 | mergeDelete( range, tx ); |
701 | 707 | } else { |