Browse Source

修复表情链接可能获取不正确

zhangchao 4 years ago
parent
commit
3fac0438c3
3 changed files with 5 additions and 5 deletions
  1. 2
    2
      src/RichTextEditor.js
  2. 1
    1
      src/WebviewMessageHandler.js
  3. 2
    2
      src/editor.html

+ 2
- 2
src/RichTextEditor.js View File

@@ -462,8 +462,8 @@ export default class RichTextEditor extends Component {
462 462
     this._sendAction(actions.insertImage, url);
463 463
   }
464 464
 
465
-  insertEmoji(url) {
466
-    this._sendAction(actions.insertEmoji, url);
465
+  insertEmoji(url, tag) {
466
+    this._sendAction(actions.insertEmoji, { tag, url });
467 467
   }
468 468
 
469 469
   deleteEmoji(url) {

+ 1
- 1
src/WebviewMessageHandler.js View File

@@ -63,7 +63,7 @@ export const MessageConverter = (action) => {
63 63
     case `${actions.insertImage}`:
64 64
       return `zss_editor.insertImage('${action.data}');`;
65 65
     case `${actions.insertEmoji}`:
66
-        return `zss_editor.insertEmoji('${action.data}');`;
66
+        return `zss_editor.insertEmoji('${action.data.url}', '${action.data.tag}');`;
67 67
     case `${actions.deleteEmoji}`:
68 68
         return `zss_editor.deleteEmoji();`;
69 69
     case `${actions.setSubscript}`:

+ 2
- 2
src/editor.html View File

@@ -1357,9 +1357,9 @@
1357 1357
 				zss_editor.enabledEditingItems();
1358 1358
 			}
1359 1359
 
1360
-			zss_editor.insertEmoji = function(url) {
1360
+			zss_editor.insertEmoji = function(url, tag) {
1361 1361
 				zss_editor.restorerange();
1362
-				document.execCommand('insertHTML', false, '<img class="emoji" src="' + encodeHtmlEntities(url) + '"/>');
1362
+				document.execCommand('insertHTML', false, '<img tag="' + tag + '" class="emoji" src="' + encodeHtmlEntities(url) + '"/>');
1363 1363
 				zss_editor.backuprange(true);
1364 1364
 				zss_editor.blurContentEditor();
1365 1365
 				zss_editor.enabledEditingItems();