wip: breakContent & others transformations - still need to confirm the api
[fnpeditor.git] / src / wlxml / wlxml.js
index fb5b328..e6ea26b 100644 (file)
@@ -1,8 +1,9 @@
 define([
     'libs/jquery',
     'libs/underscore',
-    'smartxml/smartxml'
-], function($, _, smartxml) {
+    'smartxml/smartxml',
+    'smartxml/transformations'
+], function($, _, smartxml, transformations) {
     
 'use strict';
 
@@ -49,6 +50,9 @@ $.extend(WLXMLElementNode.prototype, smartxml.ElementNode.prototype, {
         }.bind(this));
         return toret;
     },
+    setMetaAttribute: function(key, value) {
+        this.setAttr('meta-'+key, value);
+    },
     getOtherAttributes: function() {
         var toret = {};
         this.getAttrs().forEach(function(attr) {
@@ -106,7 +110,15 @@ $.extend(WLXMLElementNode.prototype, smartxml.ElementNode.prototype, {
     }
 });
 
-
+WLXMLElementNode.prototype.transformations.register(transformations.createContextTransformation({
+    name: 'wlxml.setMetaAttribute',
+    impl: function(args) {
+        this.setMetaAttribute(args.name, args.value);
+    },
+    getChangeRoot: function() {
+        return this.context;
+    }
+}));