X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/69df3ab4cbe3d3650e99b819b2ffbddb75dbdbc2..70b1b491ce0fcdf036c97e381b8fc6867e06b3c2:/modules/documentCanvas/commands.js diff --git a/modules/documentCanvas/commands.js b/modules/documentCanvas/commands.js index bb86991..8152ccd 100644 --- a/modules/documentCanvas/commands.js +++ b/modules/documentCanvas/commands.js @@ -1,6 +1,6 @@ define([ - -], function() { +'modules/documentCanvas/canvas/documentElement' +], function(documentElement) { 'use strict'; @@ -113,11 +113,18 @@ commands.register('newNodeRequested', function(canvas, params) { }); commands.register('footnote', function(canvas, params) { - var position = canvas.getCursor().getPosition(); + var cursor = canvas.getCursor(), + position = cursor.getPosition(), + asideElement; + - var asideElement = position.element.divide({tag: 'aside', klass: 'footnote', offset: position.offset}); + if(cursor.isSelectingWithinElement()) { + asideElement = position.element.wrapWithNodeElement({tag: 'aside', klass: 'footnote', start: cursor.getSelectionStart().offset, end: cursor.getSelectionEnd().offset}); + } else { + asideElement = position.element.divide({tag: 'aside', klass: 'footnote', offset: position.offset}); + asideElement.append({text: ''}); + } - asideElement.append({text: ''}); asideElement.toggle(true); canvas.setCurrentElement(asideElement); });