zhangchao před 4 roky
rodič
revize
add2bf5bec
4 změnil soubory, kde provedl 23 přidání a 1 odebrání
  1. 4
    0
      src/RichTextEditor.js
  2. 2
    0
      src/WebviewMessageHandler.js
  3. 1
    0
      src/const.js
  4. 16
    1
      src/editor.html

+ 4
- 0
src/RichTextEditor.js Zobrazit soubor

@@ -446,6 +446,10 @@ export default class RichTextEditor extends Component {
446 446
     this._sendAction(actions.insertImage, url);
447 447
   }
448 448
 
449
+  insertEmoji(url) {
450
+    this._sendAction(actions.insertEmoji, url);
451
+  }
452
+
449 453
   setSubscript() {
450 454
     this._sendAction(actions.setSubscript);
451 455
   }

+ 2
- 0
src/WebviewMessageHandler.js Zobrazit soubor

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

+ 1
- 0
src/const.js Zobrazit soubor

@@ -34,6 +34,7 @@ export const actions = {
34 34
   insertLink: 'INST_LINK',
35 35
   updateLink: 'UPDATE_LINK',
36 36
   insertImage: 'INST_IMAGE',
37
+  insertEmoji: 'INST_EMOJI',
37 38
   setSubscript: 'subscript',
38 39
   setSuperscript: 'superscript',
39 40
   setStrikethrough: 'strikeThrough',

+ 16
- 1
src/editor.html Zobrazit soubor

@@ -1352,6 +1352,12 @@
1352 1352
 				zss_editor.enabledEditingItems();
1353 1353
 			}
1354 1354
 
1355
+			zss_editor.insertEmoji = function(url) {
1356
+				zss_editor.restorerange();
1357
+				document.execCommand('insertHTML', false, '<img class="emoji" src="' + encodeHtmlEntities(url) + '"/>');
1358
+				zss_editor.enabledEditingItems();
1359
+			}
1360
+
1355 1361
 			zss_editor.insertImageBase64String = function(imageBase64String, alt) {
1356 1362
 				zss_editor.restorerange();
1357 1363
 				var html = '<img src="data:image/jpeg;base64,'+encodeHtmlEntities(imageBase64String)+'" alt="'+encodeHtmlEntities(alt)+'" />';
@@ -1683,11 +1689,12 @@
1683 1689
 			#zss_editor_content {
1684 1690
 				font-family: Arial, Helvetica, sans-serif;
1685 1691
 				color: #000;
1686
-				width: 95%;
1692
+				width: calc(100% - 20px);
1687 1693
 				-webkit-overflow-scrolling: touch;
1688 1694
 				overflow:auto;
1689 1695
 				padding-left: 10px;
1690 1696
 				padding-right: 10px;
1697
+				line-height: 20px;
1691 1698
 			}
1692 1699
 
1693 1700
 			#zss_editor_title {
@@ -1722,6 +1729,14 @@
1722 1729
 				padding-right: 10px;
1723 1730
 				display: none;
1724 1731
 			}
1732
+
1733
+			.emoji {
1734
+				height: 19.5px;
1735
+				width: 19.5px;
1736
+				line-height: 19.5px;
1737
+				display: inline-block;
1738
+				vertical-align: top;
1739
+			}
1725 1740
 		</style>
1726 1741
 
1727 1742
 		<style type="text/css">