WIP WYSIWYG ~3D SVG editor.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow replacing selection in SelectCommand

Adjust implementation of SelectCommand and the underlying functions it calls.
It's now the responsibility of the caller to update any UI necessary.
To Be Determined if that's a good idea or not.

+22 -14
+22 -14
zoodle.js
··· 94 94 this.history.push(command); 95 95 } 96 96 97 + setSelection(targets) { 98 + if (!Array.isArray(targets)) { 99 + targets = [targets]; 100 + } 101 + 102 + this.selection = targets; 103 + } 104 + 97 105 toggleSelection(target) { 98 106 const index = this.selection.indexOf(target); 99 107 if (index !== -1) { ··· 101 109 } else { 102 110 this.selection.push(target); 103 111 } 104 - this.updateProperties(); 105 - this.updateHighlights(); 106 - this.updateUI(); 107 112 } 108 113 109 114 clearSelection() { 110 - this.selection = []; 111 - this.updateProperties(); 112 - this.updateHighlights(); 113 - this.updateUI(); 115 + this.selection.length = 0; 114 116 } 115 117 116 118 updateHighlights() { ··· 683 685 } 684 686 685 687 class SelectCommand extends Command { 686 - constructor(editor, target) { 688 + constructor(editor, target, replace = false) { 687 689 super(editor); 690 + this.replace = replace; 688 691 this.oldSelection = null; 689 692 690 693 // If this is a compositeChild, find its parent ··· 698 701 this.target = target; 699 702 } 700 703 do() { 704 + this.oldSelection = this.editor.selection; 701 705 if (!this.target) { 702 - this.oldSelection = this.editor.selection; 703 706 this.editor.clearSelection(); 707 + } else if (this.replace) { 708 + this.editor.setSelection(this.target); 704 709 } else { 705 710 this.editor.toggleSelection(this.target); 706 711 } 712 + this.refresh(); 707 713 } 708 714 undo() { 709 - if (!this.target) { 710 - this.editor.selection = this.oldSelection; 711 - } else { 712 - this.editor.toggleSelection(this.target); 713 - } 715 + this.editor.selection = this.oldSelection; 716 + this.refresh(); 717 + } 718 + refresh() { 719 + this.editor.updateHighlights(); 720 + this.editor.updateUI(); 721 + this.editor.updateProperties(); 714 722 } 715 723 } 716 724