- generic element doesn't actually handle onNodeAttrChange for a 'class'
attribute - that kind of change leads to creating new canvas element
instance since
e0aad96df245c7148966887cbcc77417a4b7675b
- for the same reason support for changing class information on a generic
element during its life time is not necessary
init: function() {
DocumentNodeElement.prototype.init.call(this);
this._container()
init: function() {
DocumentNodeElement.prototype.init.call(this);
this._container()
- .attr('wlxml-tag', this.wlxmlNode.getTagName());
- this.setWlxmlClass(this.wlxmlNode.getClass());
+ .attr('wlxml-tag', this.wlxmlNode.getTagName())
+ .attr('wlxml-class', this.wlxmlNode.getClass().replace(/\./g, '-'));
+
this.wlxmlNode.contents().forEach(function(node) {
var el = this.canvas.createElement(node);
if(el.dom) {
this.wlxmlNode.contents().forEach(function(node) {
var el = this.canvas.createElement(node);
if(el.dom) {
- onNodeAttrChange: function(event) {
- if(event.meta.attr === 'class') {
- this.setWlxmlClass(event.meta.newVal); //
- }
- },
onNodeAdded: function(event) {
if(event.meta.node.isRoot()) {
this.canvas.reloadRoot();
onNodeAdded: function(event) {
if(event.meta.node.isRoot()) {
this.canvas.reloadRoot();
- },
-
- getWlxmlClass: function() {
- var klass = this._container().attr('wlxml-class');
- if(klass) {
- return klass.replace(/-/g, '.');
- }
- return undefined;
- },
- setWlxmlClass: function(klass) {
- if(klass === this.getWlxmlClass()) {
- return;
- }
- if(klass) {
- this._container().attr('wlxml-class', klass.replace(/\./g, '-'));
- }
- else {
- this._container().removeAttr('wlxml-class');
- }
- this.refreshPath();
canvas.wlxmlDocument.transaction(function() {
var added = currentElement.wlxmlNode.after({
tagName: currentElement.wlxmlNode.getTagName() || 'div',
canvas.wlxmlDocument.transaction(function() {
var added = currentElement.wlxmlNode.after({
tagName: currentElement.wlxmlNode.getTagName() || 'div',
- attrs: {'class': currentElement.getWlxmlClass() || 'p'}
+ attrs: {'class': currentElement.wlxmlNode.getClass() || 'p'}
});
added.append({text:''});
return added;
});
added.append({text:''});
return added;
canvas.wlxmlDocument.transaction(function() {
var added = element.wlxmlNode.after(
canvas.wlxmlDocument.transaction(function() {
var added = element.wlxmlNode.after(
- {tagName: element.wlxmlNode.getTagName() || 'div', attrs: {'class': element.getWlxmlClass() || 'p'}}
+ {tagName: element.wlxmlNode.getTagName() || 'div', attrs: {'class': element.wlxmlNode.getClass() || 'p'}}
);
added.append({text: ''});
return added;
);
added.append({text: ''});
return added;