$.extend(Canvas.prototype, Backbone.Events, {
+ createElementType: function(elementPrototype) {
+ /* TODO: reconcile this with ElementsRegister behavior */
+ var Constructor = function() {
+ documentElement.DocumentNodeElement.apply(this, Array.prototype.slice.call(arguments, 0));
+ };
+ Constructor.prototype = elementPrototype;
+ return Constructor;
+ },
+
getElementOffset: function(element) {
return element.dom.offset().top - this.dom.offset().top;
},
//return DocumentTextElement.fromHTMLElement(htmlElement, canvas);
return $element.data('canvas-element');
}
+
+ /* experimental */
+ if($element.parent().data('canvas-element')) {
+ return $element.parent().data('canvas-element');
+ }
},
reloadRoot: function() {
triggerKeyEvent: function(keyEvent, selection) {
selection = selection || this.getSelection();
- if(selection && (selection.type === 'caret' || selection.type === 'textSelection') && selection.toDocumentFragment().isValid()) {
+ if(selection && (
+ (selection.type === 'caret' || selection.type === 'textSelection') && selection.toDocumentFragment().isValid()
+ || selection.type == 'nodeSelection')) {
keyboard.handleKeyEvent(keyEvent, selection);
}
},