From: Aleksander Ɓukasz Date: Thu, 1 Aug 2013 07:43:48 +0000 (+0200) Subject: internal container wip: synchronizing main node and container display style (inline... X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/e7eff731af23b9501d3180cee9f4037cc93a5922 internal container wip: synchronizing main node and container display style (inline/block) - removing font-size hack for hiding cursor flicker in Chrome because it breaks height of inline document-node-element --- diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index f03719e..d58d8c1 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -112,6 +112,14 @@ 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 = $('
'), @@ -127,6 +135,11 @@ $.extend(DocumentNodeElement, { } dom.data('other-attrs', params.others); + /* display style */ + var displayStyle = getDisplayStyle(params.tag, params.klass); + dom.css('display', displayStyle); + container.css('display', displayStyle); + var widgets = $('
'); widgets.append($('').text(params.tag + (params.klass ? ' / ' + params.klass : ''))); dom.append(widgets); @@ -295,6 +308,7 @@ $.extend(DocumentNodeElement.prototype, { }, setWlxmlTag: function(tag) { this._container().attr('wlxml-tag', tag); + this._updateDisplayStyle(); }, getWlxmlClass: function() { var klass = this._container().attr('wlxml-class'); @@ -312,6 +326,12 @@ $.extend(DocumentNodeElement.prototype, { this._container().attr('wlxml-class', klass.replace(/\./g, '-')); else this._container().removeAttr('wlxml-class'); + this._updateDisplayStyle(); + }, + _updateDisplayStyle: function() { + var displayStyle = getDisplayStyle(this.getWlxmlTag, this.getWlxmlClass); + this.dom().css('display', displayStyle); + this._container().css('display', displayStyle); }, is: function(what) { if(what === 'list' && _.contains(['list.items', 'list.items.enum'], this.getWlxmlClass())) diff --git a/modules/documentCanvas/nodes.less b/modules/documentCanvas/nodes.less index 3477c3c..de4fd7c 100644 --- a/modules/documentCanvas/nodes.less +++ b/modules/documentCanvas/nodes.less @@ -1,6 +1,3 @@ -[document-node-element] { - font-size: 1px; -} [document-text-element] { font-size: 14px; display: inline; @@ -20,7 +17,6 @@ } [wlxml-tag=span] { - display:inline; min-width: 10px; }