X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/6240d0b0afba6964a9ec696a531372822193b767..3733d5e0527a89111f9e33bb8380fed20ea768fc:/modules/visualEditor.js?ds=sidebyside
diff --git a/modules/visualEditor.js b/modules/visualEditor.js
index 9cec971..bb4ad31 100644
--- a/modules/visualEditor.js
+++ b/modules/visualEditor.js
@@ -143,7 +143,11 @@ rng.modules.visualEditor = function(sandbox) {
var prefix = node.data.substr(0, startOffset);
var suffix = node.data.substr(endOffset);
var core = node.data.substr(startOffset, endOffset - startOffset);
- $(node).replaceWith(prefix + '' + core + '' + suffix);
+ var newNode = $('' + core + '');
+ $(node).replaceWith(newNode);
+ newNode.before(prefix);
+ newNode.after(suffix);
+ mediator.nodeCreated(newNode);
isDirty = true;
}
});
@@ -168,6 +172,18 @@ rng.modules.visualEditor = function(sandbox) {
getCurrentNode: function() {
return view.currentNode;
},
+ nodeCreated: function(node) {
+ view._markSelected(node);
+
+ var range = document.createRange();
+ range.selectNodeContents(node[0]);
+ range.collapse(false);
+
+ var selection = document.getSelection();
+ selection.removeAllRanges()
+ selection.addRange(range);
+
+ },
nodeSelected: function(node) {
sideBarView.updateEditPane(node);
}