Browse Source

Change signature of insertImage

Yevhen Pavliuk 8 years ago
parent
commit
b30688d323
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,8 +404,8 @@ export default class RichTextEditor extends Component {
404 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 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,7 +77,7 @@ export const InjectedMessageHandler = `
77 77
           zss_editor.updateLink(action.data.url, action.data.title);
78 78
           break;
79 79
         case '${actions.insertImage}':
80
-          zss_editor.insertImage(action.data.url, action.data.alt);
80
+          zss_editor.insertImage(action.data);
81 81
           break;
82 82
         case '${actions.setSubscript}':
83 83
           zss_editor.setSubscript();

+ 4
- 3
src/editor.html View File

@@ -1332,10 +1332,11 @@
1332 1332
 				zss_editor.backuprange();
1333 1333
 			}
1334 1334
 
1335
-			zss_editor.insertImage = function(url, alt) {
1335
+			zss_editor.insertImage = function(attributes) {
1336 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 1340
 				zss_editor.enabledEditingItems();
1340 1341
 			}
1341 1342