Roo/htmleditor/BlockFigure.js
authorAlan <alan@roojs.com>
Thu, 6 Jan 2022 05:06:43 +0000 (13:06 +0800)
committerAlan <alan@roojs.com>
Thu, 6 Jan 2022 05:06:43 +0000 (13:06 +0800)
Roo/htmleditor/BlockFigure.js

index 016bceb..04653cb 100644 (file)
@@ -198,6 +198,29 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, {
         
         var m = this.width == '50%' && this.align == 'center' ? '0 auto' : 0; 
         
+        var img =   {
+                    tag : 'img',
+                    src : this.image_src,
+                    alt : d.innerText.replace(/\n/g, " "), // removeHTML..
+                    style: {
+                        width : 'auto',
+                        'max-width': '100%',
+                        margin : '0px' 
+                        
+                        
+                    }
+                };
+                
+        if (this.href) {
+            img = {
+                tag : 'a',
+                href: this.href,
+                cn : [
+                    img
+                ]
+            };
+        }
+        
         return  {
             tag: 'figure',
             'data-block' : 'Figure',
@@ -213,18 +236,8 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, {
             },
             align : this.align,
             cn : [
-                {
-                    tag : 'img',
-                    src : this.image_src,
-                    alt : d.innerText.replace(/\n/g, " "), // removeHTML..
-                    style: {
-                        width : 'auto',
-                        'max-width': '100%',
-                        margin : '0px' 
-                        
-                        
-                    }
-                },
+                img,
+              
                 {
                     tag: 'figcaption',
                     contenteditable : true,