From: Aleksander Ɓukasz Date: Fri, 19 Apr 2013 13:49:44 +0000 (+0200) Subject: Visual editor: handling empty document X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/072a91dee12e07caf91a693c29fd9f3be5ee177b Visual editor: handling empty document --- diff --git a/editor.css b/editor.css index aa920c8..cf1abc2 100644 --- a/editor.css +++ b/editor.css @@ -174,6 +174,7 @@ body { border-color: white; border-style:solid; border-width:1px; + min-height:20px; } [wlxml-tag=header] { diff --git a/modules/data.js b/modules/data.js index e4b564e..8debbd3 100644 --- a/modules/data.js +++ b/modules/data.js @@ -3,6 +3,23 @@ rng.modules.data = function(sandbox) { var doc = sandbox.getBootstrappedData().document; var document_id = sandbox.getBootstrappedData().document_id; + + if(doc === '') { + doc = '\n\ + \n\ + \n\ + \n\ +
\n\ + \n\ +
'; + } + + function readCookie(name) { var nameEQ = escape(name) + "="; var ca = document.cookie.split(';'); diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 73622f9..f3c0a5c 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -107,8 +107,13 @@ rng.modules.visualEditor = function(sandbox) { var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() { return $(this).clone().children().remove().end().text().trim() !== ''; }).first(); + var node; if(firstNodeWithText.length) - this.selectNode($(firstNodeWithText[0])); + node = $(firstNodeWithText[0]) + else { + node = this.node.find('[wlxml-class|="p"]') + } + this.selectNode(node); }, _addMetaRow: function(key, value) { var newRow = $(sandbox.getTemplate('metaItem')({key: key || '', value: value || ''}));