Browse Source

New insert image attrs

ihork 8 years ago
parent
commit
5cef066328
3 changed files with 7 additions and 6 deletions
  1. 2
    2
      src/RichTextEditor.js
  2. 1
    1
      src/WebviewMessageHandler.js
  3. 4
    3
      src/editor.html

+ 2
- 2
src/RichTextEditor.js View File

404
     this._sendAction(actions.updateLink, {url, title});
404
     this._sendAction(actions.updateLink, {url, title});
405
   }
405
   }
406
 
406
 
407
-  insertImage(url, alt) {
408
-    this._sendAction(actions.insertImage, {url, alt});
407
+  insertImage(attributes) {
408
+    this._sendAction(actions.insertImage, attributes);
409
     this.prepareInsert(); //This must be called BEFORE insertImage. But WebViewBridge uses a stack :/
409
     this.prepareInsert(); //This must be called BEFORE insertImage. But WebViewBridge uses a stack :/
410
   }
410
   }
411
 
411
 

+ 1
- 1
src/WebviewMessageHandler.js View File

77
           zss_editor.updateLink(action.data.url, action.data.title);
77
           zss_editor.updateLink(action.data.url, action.data.title);
78
           break;
78
           break;
79
         case '${actions.insertImage}':
79
         case '${actions.insertImage}':
80
-          zss_editor.insertImage(action.data.url, action.data.alt);
80
+          zss_editor.insertImage(action.data);
81
           break;
81
           break;
82
         case '${actions.setSubscript}':
82
         case '${actions.setSubscript}':
83
           zss_editor.setSubscript();
83
           zss_editor.setSubscript();

+ 4
- 3
src/editor.html View File

1332
 				zss_editor.backuprange();
1332
 				zss_editor.backuprange();
1333
 			}
1333
 			}
1334
 
1334
 
1335
-			zss_editor.insertImage = function(url, alt) {
1335
+			zss_editor.insertImage = function(attributes) {
1336
 				zss_editor.restorerange();
1336
 				zss_editor.restorerange();
1337
-				var html = '<img src="'+encodeHtmlEntities(url)+'" alt="'+encodeHtmlEntities(alt)+'" /><br>';
1338
-				zss_editor.insertHTML(html);
1337
+				var imageContainer = $('<div><img></div>');
1338
+				imageContainer.find('img').attr(attributes);
1339
+				zss_editor.insertHTML(imageContainer.html() + '<br>');
1339
 				zss_editor.enabledEditingItems();
1340
 				zss_editor.enabledEditingItems();
1340
 			}
1341
 			}
1341
 
1342