+ getDocumentElement: function(htmlElement) {
+ /* globals HTMLElement, Text */
+ if(!htmlElement || !(htmlElement instanceof HTMLElement || htmlElement instanceof Text)) {
+ return null;
+ }
+ var $element = $(htmlElement);
+ if(htmlElement.nodeType === Node.ELEMENT_NODE && $element.attr('document-node-element') !== undefined) {
+ return $element.data('canvas-element');
+ }
+
+ if(htmlElement.nodeType === Node.TEXT_NODE && $element.parent().attr('document-text-element') !== undefined) {
+ $element = $element.parent();
+ }
+
+ if($element.attr('document-text-element') !== undefined || (htmlElement.nodeType === Node.TEXT_NODE && $element.parent().attr('document-text-element') !== undefined)) {
+ //return DocumentTextElement.fromHTMLElement(htmlElement, canvas);
+ return $element.data('canvas-element');
+ }