var element = this.fromHTMLElement(dom[0], canvas);
+ element.data('wlxmlNode', wlxmlNode);
+ wlxmlNode.setData('canvasElement', element);
+
element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()});
_.keys(wlxmlNode.getMetaAttributes()).forEach(function(key) {
$.extend(DocumentTextElement, {
createDOM: function(wlxmlTextNode) {
- return $('<div>')
+ var dom = $('<div>')
.attr('document-text-element', '')
- .text(wlxmlTextNode.getText() || utils.unicode.ZWS);
+ .text(wlxmlTextNode.getText() || utils.unicode.ZWS),
+ element = this.fromHTMLElement(dom[0], this);
+ element.data('wlxmlNode', wlxmlTextNode);
+ return dom;
},
create: function(wlxmlTextNode, canvas) {
prependText: function(text) {
this.dom().contents()[0].data = text + this.dom().contents()[0].data;
},
- getText: function() {
- return this.dom().text().replace(utils.unicode.ZWS, '');
+ getText: function(options) {
+ options = _.extend({raw: false}, options || {});
+ var toret = this.dom().text();
+ if(!options.raw) {
+ toret = toret.replace(utils.unicode.ZWS, '');
+ }
+ return toret;
},
isEmpty: function() {
// Having at least Zero Width Space is guaranteed be Content Observer