瀏覽代碼

Change signature of insertImage

Yevhen Pavliuk 8 年之前
父節點
當前提交
b30688d323
共有 3 個文件被更改,包括 7 次插入6 次删除
  1. 2
    2
      src/RichTextEditor.js
  2. 1
    1
      src/WebviewMessageHandler.js
  3. 4
    3
      src/editor.html

+ 2
- 2
src/RichTextEditor.js 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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