From: Aleksander Ɓukasz Date: Fri, 19 Apr 2013 14:49:19 +0000 (+0200) Subject: Visual editor: hitting enter moves to a new tag - copy of current one (Chrome, FF) X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/b8a6d80a6573772f180b39aaeaf6c3ef48f2c021?ds=sidebyside;hp=c0e11a8f6d0d9a4c030aa90fe91f0fc49cd05e0e Visual editor: hitting enter moves to a new tag - copy of current one (Chrome, FF) --- diff --git a/editor.css b/editor.css index cf1abc2..5d3eae2 100644 --- a/editor.css +++ b/editor.css @@ -177,6 +177,11 @@ body { min-height:20px; } +span[wlxml-tag] { + display:inline-block; + min-width: 10px; +} + [wlxml-tag=header] { font-size: 13px; font-weight: bold; diff --git a/modules/visualEditor.js b/modules/visualEditor.js index f3c0a5c..702c812 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -31,6 +31,18 @@ rng.modules.visualEditor = function(sandbox) { view._markSelected(anchor); }); + this.node.on('keydown', '#rng-visualEditor-contentWrapper', function(e) { + if(e.which === 13) { + e.preventDefault(); + var anchor = $(window.getSelection().anchorNode); + if(anchor[0].nodeType === Node.TEXT_NODE) + anchor = anchor.parent(); + var newNode = anchor.clone().empty(); + anchor.after(newNode); + view.selectNode(newNode); + } + }); + var metaTable = this.metaTable = this.node.find('#rng-visualEditor-meta table');