X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/c833dec45110d8cb85cdf63813a17b1c27516552..0061ce72a4ef53ac99f75a4f3aa51d5c18a27b5e:/src/editor/modules/documentCanvas/canvas/canvas.js diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 3dac88f..fffc61d 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -97,6 +97,15 @@ var Canvas = function(wlxmlDocument, elements, metadata, sandbox) { $.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; }, @@ -165,7 +174,9 @@ $.extend(Canvas.prototype, Backbone.Events, { 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); } },