isVisible: function() {
return this instanceof DocumentTextElement || this.getWlxmlTag() !== 'metadata';
+ },
+
+ isInsideList: function() {
+ return this.parents().some(function(parent) {
+ return parent.is('list');
+ });
}
});
}
});
-commands.register('toggle-list', function(canvas, params) {
+commands.register('list', function(canvas, params) {
var cursor = canvas.getCursor(),
selectionStart = cursor.getSelectionStart(),
selectionEnd = cursor.getSelectionEnd(),
parent2 = selectionEnd.element.parent() || undefined;
var selectionFocus = cursor.getSelectionFocus();
- if(params.toggle) {
- canvas.list.create({element1: parent1, element2: parent2});
- } else {
- if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
- canvas.list.extractItems({element1: parent1, element2: parent2, merge: false});
- }
+
+ if(selectionStart.element.isInsideList() || selectionEnd.element.isInsideList()) {
+ return;
}
+
+ canvas.list.create({element1: parent1, element2: parent2});
+
canvas.setCurrentElement(selectionFocus.element, {caretTo: selectionFocus.offset});
});
<button data-name="wrap-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-arrow-down"></i></button>
</div>
<div class="rng-module-documentToolbar-toolbarGroup">
- <button data-name="list" data-btn-type="toggle" data-meta="bullets" class="btn btn-mini"><i class="icon-list"></i></button>
+ <button data-name="list" data-btn-type="cmd" data-meta="bullets" class="btn btn-mini"><i class="icon-list"></i></button>
<button data-name="createList" data-btn-type="cmd" data-meta="enum" class="btn btn-mini"><i class="icon-th-list"></i></button>
</div>
<div class="rng-module-documentToolbar-toolbarGroup">