X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/fb606ab5c798838e28398f2a3fb45d29ae2dbc5f..4c81ad4075b0e8e67f984cce3494f9853179a9d6:/modules/documentCanvas/documentCanvas.js?ds=sidebyside diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index bb8ad4a..1577be0 100644 --- a/modules/documentCanvas/documentCanvas.js +++ b/modules/documentCanvas/documentCanvas.js @@ -51,6 +51,15 @@ return function(sandbox) { e.preventDefault(); view.insertNewNode(null, null); } + if(e.which === 8) { + var anchor = window.getSelection().anchorNode; + var len = anchor.length; + console.log(len); + if(len === 1) { + e.preventDefault(); + $(anchor).parent().text(''); + } + } }); this.node.onShow = function() { @@ -82,14 +91,17 @@ return function(sandbox) { //TODO: Insert inline var anchor = $(window.getSelection().anchorNode); var anchorOffset = window.getSelection().anchorOffset; - if(anchor[0].nodeType === Node.TEXT_NODE) + var textLen; + if(anchor[0].nodeType === Node.TEXT_NODE) { + textLen = anchor.text().length; anchor = anchor.parent(); + } if(anchor.text() === '') { var todel = anchor; anchor = anchor.parent(); todel.remove(); } - if(anchorOffset > 0 && anchorOffset < anchor.text().length) { + if(anchorOffset > 0 && anchorOffset < textLen) { if(wlxmlTag === null && wlxmlClass === null) { return this.splitWithNewNode(anchor); }