Roo/htmleditor/FilterWord.js
authorAlan <alan@roojs.com>
Thu, 17 Mar 2022 08:53:48 +0000 (16:53 +0800)
committerAlan <alan@roojs.com>
Thu, 17 Mar 2022 08:53:48 +0000 (16:53 +0800)
Roo/htmleditor/FilterWord.js

index 7e6e19f..da1c6f1 100644 (file)
@@ -12,7 +12,7 @@
 Roo.htmleditor.FilterWord = function(cfg)
 {
     // no need to apply config.
-    this.replaceBullets(cfg.node)
+    this.replaceDocBullets(cfg.node);
     
     this.walk(cfg.node);
     
@@ -118,5 +118,62 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
         
         
         
+    },
+    
+    styleToObject: function(node)
+    {
+        var styles = node.getAttribute("style").split(";");
+        var ret = {};
+        Roo.each(styles, function(s) {
+            if (!s.match(/:/)) {
+                return;
+            }
+            var kv = s.split(":");
+             
+            // what ever is left... we allow.
+            ret[kv[0]] = kv[1];
+        });
+        return ret;
+    }
+    
+    
+    replaceDocBullets : function(doc)
+    {
+        var listpara = doc.getElementsByClassName('MsoListParagraph');
+        while(listpara.length) {
+            this.replaceDocBullet(listpara.item(0));
+            //code
+        }
+    },
+    
+    replaceDocBullet : function(p)
+    {
+        // gather all the siblings.
+        var ns = p,
+            parent = p.parentNode,
+            items = []; 
+        while (ns) {
+            if (!ns.className.match(/MsoListParagraph/)) {
+                break;
+            }
+            items.push(ns);
+            ns = ns.nextSibling;
+            
+        }
+        var ul = parent.ownerDocument.createElement('ul'); // what about number lists...
+        
+        items.forEach(function(n) {
+            parent.removeChild(n);
+            var spans = n.getElementsByTagName('span');
+            n.removeChild(spans.item(0)); // remove the fake bullet.
+            
+        });
+        
+        
+        
+        
     }
+    
+    
+    
 });
\ No newline at end of file