X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a737843b7f2278e38f02b00f8cb791446c2b99e1..7bc06393365fdffe695cef6dd825edf4ce521919:/modules/documentCanvas/canvas/documentElement.js diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 384186f..0558a3e 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -2,8 +2,10 @@ define([ 'libs/jquery-1.9.1.min', 'libs/underscore-min', 'modules/documentCanvas/classAttributes', -'modules/documentCanvas/canvas/utils' -], function($, _, classAttributes, utils) { +'modules/documentCanvas/canvas/utils', +'modules/documentCanvas/canvas/widgets', +'modules/documentCanvas/canvas/wlxmlManagers' +], function($, _, classAttributes, utils, widgets, wlxmlManagers) { 'use strict'; @@ -44,6 +46,9 @@ $.extend(DocumentElement.prototype, { _setupDOMHandler: function(htmlElement) { this.$element = $(htmlElement); }, + bound: function() { + return this.canvas !== undefined; + }, dom: function() { return this.$element; }, @@ -69,17 +74,12 @@ $.extend(DocumentElement.prototype, { }, wrapWithNodeElement: function(wlxmlNode) { - var wrapper = DocumentNodeElement.create({tag: wlxmlNode.tag, klass: wlxmlNode.klass}); + var wrapper = DocumentNodeElement.create({tag: wlxmlNode.tag, klass: wlxmlNode.klass}, this); this.dom().replaceWith(wrapper.dom()); wrapper.append(this); return wrapper; }, - detach: function() { - this.dom().detach(); - this.canvas = null; - }, - markAsCurrent: function() { this.canvas.markAsCurrent(this); }, @@ -103,6 +103,18 @@ $.extend(DocumentElement.prototype, { isVisible: function() { return this instanceof DocumentTextElement || this.getWlxmlTag() !== 'metadata'; + }, + + isInsideList: function() { + return this.parents().some(function(parent) { + return parent.is('list'); + }); + }, + + exec: function(method) { + var manager = this.data('_wlxmlManager'); + if(manager[method]) + return manager[method].apply(manager, Array.prototype.slice.call(arguments, 1)); } }); @@ -112,51 +124,40 @@ var DocumentNodeElement = function(htmlElement, canvas) { DocumentElement.call(this, htmlElement, canvas); }; -var getDisplayStyle = function(tag, klass) { - if(tag === 'metadata') - return 'none'; - if(tag === 'span') - return 'inline'; - return 'block'; -} - $.extend(DocumentNodeElement, { - createDOM: function(params) { - var dom = $('