this.$element = $(htmlElement);
},
bound: function() {
- return this.canvas !== undefined;
+ return $.contains(document.documentElement, this.dom()[0]);
},
dom: function() {
return this.$element;
documentElement._container().toggle(toggle);
}
- var eventBus = documentElement.bound() ? documentElement.canvas.eventBus :
+ var eventBus = documentElement.canvas ? documentElement.canvas.eventBus :
{trigger: function() {}};
this.trigger = function() {
eventBus.trigger.apply(eventBus, arguments);
canvas.setCurrentElement(asideElement);
});
+commands.register('take-away-node', function(canvas) {
+ var position = canvas.getCursor().getPosition(),
+ element = position.element,
+ nodeElement = element ? element.parent() : canvas.getCurrentNodeElement();
+
+ if(!nodeElement || !(nodeElement.parent()))
+ return;
+
+
+ var range = nodeElement.unwrapContents();
+
+ if(element) {
+ var elementIsFirstChild = nodeElement.childIndex(element);
+ if(element.bound()) {
+ canvas.setCurrentElement(element, {caretTo: position.offset});
+ } else {
+ if(elementIsFirstChild) {
+ canvas.setCurrentElement(range.element1, {caretTo: 'end'});
+ } else {
+ canvas.setCurrentElement(range.element2, {caretTo: 'end'});
+ }
+ }
+ } else {
+ canvas.setCurrentElement(range.element1, {caretTo: 'start'});
+ }
+
+});
+
return {
run: function(name, params, canvas) {
<button data-name="new-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-plus"></i></button>
</div>
<div class="rng-module-documentToolbar-toolbarGroup">
- <button data-name="unwrap-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-arrow-up"></i></button>
- <button data-name="wrap-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-arrow-down"></i></button>
+ <button data-name="take-away-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-remove-circle"></i></button>
</div>
<div class="rng-module-documentToolbar-toolbarGroup">
<button data-name="list" data-btn-type="cmd" data-meta="bullets" class="btn btn-mini"><i class="icon-list"></i></button>
+ <button data-name="unwrap-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-arrow-up"></i></button>
+ <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="footnote" data-btn-type="cmd" class="btn btn-mini"><i class="icon-comment"></i></button>