X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/81a52f1229a0514560d601208f75f3e73e1e614d..45c6e40d4312a3bc53fb0c64574d9e5b1f298193:/src/editor/plugins/core/core.js diff --git a/src/editor/plugins/core/core.js b/src/editor/plugins/core/core.js index a780227..ed0cf28 100644 --- a/src/editor/plugins/core/core.js +++ b/src/editor/plugins/core/core.js @@ -31,15 +31,37 @@ plugin.documentExtension.textNode.transformations = { } }, mergeContentUp: function() { - var myPrev = this.prev(), + /* globals Node */ + var myPrev = this, + base = this, ret; - if(myPrev) { - ret = myPrev.append(this); + if(myPrev.nodeType === Node.TEXT_NODE) { + if(myPrev.getIndex() > 0) { + return; + } + myPrev = base = myPrev.parent(); + } + + myPrev = myPrev && myPrev.prev(); + + if(myPrev && myPrev.nodeType === Node.ELEMENT_NODE) { + var ptr = this, + next; + while(ptr) { + next = ptr.next(); + if(!ret) { + ret = myPrev.append(ptr); + } else { + myPrev.append(ptr); + } + + ptr = next; + } + if(base !== this) { + base.detach(); + } return {node: ret, offset: ret.sameNode(this) ? null : ret.getText().length - this.getText().length}; - } else { - var range = this.parent().unwrapContent(); - return {node: range.element1, offset: 0}; } } }; @@ -136,7 +158,7 @@ var commentAction = { params.fragment instanceof params.fragment.NodeFragment && !params.fragment.node.isRoot() }; if(state.allowed) { - state.description = gettext('Insert comment after current node'); + state.description = gettext('Insert comment'); } return state; } @@ -288,7 +310,12 @@ var linkAction = { if(params.fragment instanceof params.fragment.CaretFragment) { if(params.fragment.node.isInside('link')) { - return {allowed: true, toggled: true, execute: editLink}; + return { + allowed: true, + toggled: true, + description: gettext('Edit link'), + execute: editLink + }; } } return {allowed: false};