X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/ce51fb7e5de8910382af08e299831714e5f0e4e4..b193de5bbfb1c96da0bb9a5398eb2a11b094017a:/modules/visualEditor.js?ds=sidebyside diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 98923a5..8d77302 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -91,6 +91,13 @@ rng.modules.visualEditor = function(sandbox) { node.addClass('rng-current'); mediator.nodeSelected(node); }, + markFirstSelected: function() { + var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() { + return $(this).clone().children().remove().end().text().trim() !== ''; + }).first(); + if(firstNodeWithText.length) + $(firstNodeWithText[0]).click().focus(); + }, _addMetaRow: function(key, value) { var newRow = $(sandbox.getTemplate('metaItem')({key: key || '', value: value || ''})); newRow.appendTo(this.metaTable); @@ -135,7 +142,7 @@ rng.modules.visualEditor = function(sandbox) { } var isDirty = false; - + var wasShownAlready = false; return { @@ -159,6 +166,12 @@ rng.modules.visualEditor = function(sandbox) { }, setDirty: function(dirty) { isDirty = dirty; + }, + onShowed: function() { + if(!wasShownAlready) { + wasShownAlready = true; + view.markFirstSelected(); + } } }