},
setText: function(text, node) {
//this.canvas.wlxmlDocument.transform('setText', {node:node, text: text});
- node.transform('smartxml.setText', {text: text});
+ node.setText(text);
}
var wlxmlNode = selectionStart.element.data('wlxmlNode'),
caretTo = selectionStart.offset < selectionEnd.offset ? 'start' : 'end',
//wrapper = wlxmlNode.wrapWith({tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}, start: selectionStart.offset, end: selectionEnd.offset}),
- wrapper = wlxmlNode.transform('smartxml.wrapWith', {tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}, start: selectionStart.offset, end: selectionEnd.offset})
+ //wrapper = wlxmlNode.transform('smartxml.wrapWith', {tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}, start: selectionStart.offset, end: selectionEnd.offset})
+ wrapper = wlxmlNode.wrapWith({tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}, start: selectionStart.offset, end: selectionEnd.offset});
;
var wrapperCanvasElement = utils.findCanvasElement(wrapper);
canvas.setCurrentElement(wrapperCanvasElement.children()[0], {caretTo: caretTo});
], function() {
'use strict';
-
+/* globals Node */
+var TEXT_NODE = Node.TEXT_NODE;
var INSERTION = function(implementation) {
var toret = function(node) {
this.prev().appendText(next.getText());
next.detach();
}
- return DocumentNode.prototype.detach.call(this);
+ return this.__super__.detach();
},
setTag: function(tagName) {
_with: {tagName: desc.tagName, attrs: desc.attrs}
});
} else {
- return DocumentNode.prototype.wrapWith.call(this, desc);
+ return this.__super__.wrapWith.call(this, desc);
}
},
replaceRoot: function(node) {
var insertion = this.getNodeInsertion(node);
this.root.detach();
- defineDocumentProperties(this, insertion.ofNode._$);
+ this._defineDocumentProperties(insertion.ofNode._$);
insertion.ofNode.triggerChangeEvent('nodeAdded');
return insertion.ofNode;
}
'use strict';
/* globals Node */
-var TEXT_NODE = Node.TEXT_NODE;
-
-
var DocumentNode = function(nativeNode, document) {
if(!document) {
if(!(this.document.containsNode(this))) {
return null;
}
-
+
var nodePath = [this].concat(this.parents()),
toret, idx;
ancestor = ancestor || this.document.root;
this._nodeTransformations = {};
this._textNodeTransformations = {};
this._elementNodeTransformations = {};
+
+ this.registerExtension(coreTransformations);
};
$.extend(Document.prototype, Backbone.Events, {
return {
documentFromXML: function(xml) {
var doc = new Document(xml);
- doc.registerExtension(coreTransformations);
return doc;
},
c = b.contents()[0];
var parents = c.parents();
- expect(parents).to.eql([b,a]);
+ // @@
+ expect(parents[0].sameNode(b)).to.be.true;
+ expect(parents[1].sameNode(a)).to.be.true;
});
});
// potem spr na dotychczasowych undo/redo tests;
this.args.forEach(function(arg, idx, args) {
- if(arg.nodeType) { // ~
+ if(arg && arg.nodeType) { // ~
var path = arg.getPath();
Object.defineProperty(args, idx, {
get: function() {
- if(transformation.hasRun) {
+ if(transformation.hasRun && path) {
return transformation.document.getNodeByPath(path);
} else {
return arg;
});
},
getChangeRoot: function() {
- return this.args.node1.parent();
+ return this.args[0].node1.parent();
},
isAllowed: function() {
- return this.args.node1.parent().sameNode(this.args.node2.parent());
+ return this.args[0].node1.parent().sameNode(this.args[0].node2.parent());
}
};
return true;
},
isAllowed: function() {
- var parent = this.args.nodel1.parent();
- return parent.is('list') && parent.sameNode(this.args.node2.parent());
+ var parent = this.args[0].nodel1.parent();
+ return parent.is('list') && parent.sameNode(this.args[0].node2.parent());
}
};