X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/189dfb1a02272bf58fe1ad33d60461b4d05eb944..28faa6e7111db9527643804893de5aee7eb3da33:/modules/documentCanvas/canvas/documentElement.js?ds=sidebyside diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 9ddf190..c6c9f22 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -292,7 +292,7 @@ $.extend(DocumentNodeElement.prototype, { this.dom().removeAttr('wlxml-class'); }, is: function(what) { - if(what === 'list' && _.contains(['list-items', 'list-items-enum'], this.dom().attr('wlxml-class'))) + if(what === 'list' && _.contains(['list.items', 'list.items.enum'], this.getWlxmlClass())) return true; return false; }, @@ -456,6 +456,22 @@ $.extend(DocumentTextElement.prototype, { return {first: parentElement, second: newElement}; }, + divide: function(params) { + var myText = this.getText(); + + if(params.offset <= 0 || params.offset >= myText.length) + return; + + var lhsText = myText.substr(0, params.offset), + rhsText = myText.substr(params.offset), + newElement = DocumentNodeElement.create({tag: params.tag, klass: params.klass}, this.canvas), + rhsTextElement = DocumentTextElement.create({text: rhsText}); + + this.setText(lhsText); + this.after(newElement); + newElement.after(rhsTextElement); + return newElement; + } }); return {