X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/e573418502325e80c42523264424fa547a435de5..b554451bd332b417a9304fd60fafe116220a9ca4:/modules/documentCanvas/canvas.js?ds=sidebyside diff --git a/modules/documentCanvas/canvas.js b/modules/documentCanvas/canvas.js index a15bb2c..eb0fd0b 100644 --- a/modules/documentCanvas/canvas.js +++ b/modules/documentCanvas/canvas.js @@ -36,6 +36,14 @@ Canvas.prototype.getNode = function(desc) { return toret; } +Canvas.prototype.getPreviousNode = function(options) { + var element = $(this.content.find('#' + options.node.id).get(0)); + var prev = element.prev() + if(prev.length === 0) + prev = element.parent(); + return new wlxmlNode.Node(prev); +} + Canvas.prototype._createNode = function(wlxmlTag, wlxmlClass) { var toBlock = ['div', 'document', 'section', 'header']; var htmlTag = _.contains(toBlock, wlxmlTag) ? 'div' : 'span'; @@ -49,8 +57,11 @@ Canvas.prototype._createNode = function(wlxmlTag, wlxmlClass) { Canvas.prototype.insertNode = function(options) { var element = $(this.content.find('#' + options.context.id).get(0)); - if(options.place == 'after') - element[options.place](this._createNode(options.tag, options.klass)); + if(options.place == 'after') { + var node = this._createNode(options.tag, options.klass); + element[options.place](node); + return node; + } else if(options.place == 'wrapText') { var elementContents = element.contents(); if(elementContents.length !== 1 || elementContents.get(0).nodeType != 3) @@ -103,6 +114,13 @@ Canvas.prototype.splitNode = function(options) { newNode.append(node) }); nodeToSplit.after(newNode); + return newNode; +} + +Canvas.prototype.removeNode = function(options) { + var toRemove = $(this.content.find('#' + options.node.id).get(0)); + toRemove.remove(); + } Canvas.prototype.createList = function(options) {