From: Aleksander Ɓukasz Date: Fri, 21 Jun 2013 12:19:16 +0000 (+0200) Subject: canvas api wip: remove node X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/30ab52867dd38bdf8bda76e60be833b2603fb6ab canvas api wip: remove node --- diff --git a/modules/documentCanvas/canvas.js b/modules/documentCanvas/canvas.js index 20c286a..92c02c6 100644 --- a/modules/documentCanvas/canvas.js +++ b/modules/documentCanvas/canvas.js @@ -106,6 +106,12 @@ Canvas.prototype.splitNode = function(options) { return newNode; } +Canvas.prototype.removeNode = function(options) { + var toRemove = $(this.content.find('#' + options.node.id).get(0)); + toRemove.remove(); + +} + Canvas.prototype.createList = function(options) { var element1 = $(this.content.find('#' + options.start.id).get(0)); var element2 = $(this.content.find('#' + options.end.id).get(0)); diff --git a/modules/documentCanvas/tests/canvas.test.js b/modules/documentCanvas/tests/canvas.test.js index a948787..6ba3f42 100644 --- a/modules/documentCanvas/tests/canvas.test.js +++ b/modules/documentCanvas/tests/canvas.test.js @@ -93,6 +93,17 @@ define([ ); }); + test('remove node', function() { + var c = new canvas.Canvas('
Fancy and nice header 1
'); + var span = c.getNode({tag: 'span'})[0]; + var siblings = c.removeNode({node:span}); + assert.xmlEqual(c.toXML(), '\ +
\ +
Fancy and nice 1
\ +
' + ); + }); + test('list', function() { var c = new canvas.Canvas('
Alice
has
a cat
'); var div1 = c.getNode({tag:'div'})[0];