zhangchao hace 4 años
padre
commit
1c9edb54bd
Se han modificado 4 ficheros con 26 adiciones y 2 borrados
  1. 8
    1
      src/RichTextEditor.js
  2. 2
    0
      src/WebviewMessageHandler.js
  3. 2
    0
      src/const.js
  4. 14
    1
      src/editor.html

+ 8
- 1
src/RichTextEditor.js Ver fichero

@@ -145,7 +145,6 @@ export default class RichTextEditor extends Component {
145 145
           this.setContentPlaceholder(this.props.contentPlaceholder);
146 146
           this.setTitleHTML(this.props.initialTitleHTML || '');
147 147
           this.setContentHTML(this.props.initialContentHTML || '');
148
-
149 148
           !this.props.hiddenTitle && this.showTitle();
150 149
           this.props.enableOnChange && this.enableOnChange();
151 150
 
@@ -168,6 +167,9 @@ export default class RichTextEditor extends Component {
168 167
         case messages.CONTENT_FOCUSED:
169 168
           this.contentFocusHandler && this.contentFocusHandler();
170 169
           break;
170
+        case messages.CONTENT_BLUR:
171
+          this.contentBlurHandler && this.contentBlurHandler();
172
+          break;
171 173
         case messages.SELECTION_CHANGE: {
172 174
           const items = message.data.items;
173 175
           this.state.selectionChangeListeners.map((listener) => {
@@ -588,6 +590,11 @@ export default class RichTextEditor extends Component {
588 590
     this._sendAction(actions.setContentFocusHandler);
589 591
   }
590 592
 
593
+  setContentBlurHandler(callbackHandler) {
594
+    this.contentBlurHandler = callbackHandler;
595
+    this._sendAction(actions.setContentBlurHandler);
596
+  }
597
+
591 598
   addSelectedTextChangeListener(listener) {
592 599
     this._selectedTextChangeListeners.push(listener);
593 600
   }

+ 2
- 0
src/WebviewMessageHandler.js Ver fichero

@@ -104,6 +104,8 @@ export const MessageConverter = (action) => {
104 104
       return `zss_editor.setTitleFocusHandler();`;
105 105
     case `${actions.setContentFocusHandler}`:
106 106
       return `zss_editor.setContentFocusHandler();`;
107
+    case `${actions.setContentBlurHandler}`:
108
+        return `zss_editor.setContentBlurHandler();`;
107 109
     case `${actions.getTitleHtml}`:
108 110
       return `var html = zss_editor.getTitleHTML();
109 111
       ReactNativeWebView.postMessage(JSON.stringify({type: '${messages.TITLE_HTML_RESPONSE}', data: html}));`

+ 2
- 0
src/const.js Ver fichero

@@ -45,6 +45,7 @@ export const actions = {
45 45
   setContentPlaceholder: 'SET_CONTENT_PLACEHOLDER',
46 46
   setTitleFocusHandler: 'SET_TITLE_FOCUS_HANDLER',
47 47
   setContentFocusHandler: 'SET_CONTENT_FOCUS_HANDLER',
48
+  setContentBlurHandler: 'SET_CONTENT_BLUR_HANDLER',
48 49
   prepareInsert: 'PREPARE_INSERT',
49 50
   restoreSelection: 'RESTORE_SELECTION',
50 51
   setCustomCSS: 'SET_CUSTOM_CSS',
@@ -66,6 +67,7 @@ export const messages = {
66 67
   LOG: 'LOG',
67 68
   TITLE_FOCUSED: 'TITLE_FOCUSED',
68 69
   CONTENT_FOCUSED: 'CONTENT_FOCUSED',
70
+  CONTENT_BLUR: 'CONTENT_BLUR',
69 71
   SELECTION_CHANGE: 'SELECTION_CHANGE',
70 72
   CONTENT_CHANGE: 'CONTENT_CHANGE',
71 73
   SELECTED_TEXT_RESPONSE: 'SELECTED_TEXT_RESPONSE',

+ 14
- 1
src/editor.html Ver fichero

@@ -916,7 +916,7 @@
916 916
 				whenPastingInsertAsPlainText('zss_editor_title');
917 917
 				whenPastingInsertAsPlainText('zss_editor_content');
918 918
 
919
-				zss_editor.focusContent();
919
+				// zss_editor.focusContent();
920 920
 
921 921
 				setTimeout(function() {
922 922
 					ReactNativeWebView.postMessage(JSON.stringify({type: 'ZSS_INITIALIZED'}))
@@ -1355,6 +1355,7 @@
1355 1355
 			zss_editor.insertEmoji = function(url) {
1356 1356
 				zss_editor.restorerange();
1357 1357
 				document.execCommand('insertHTML', false, '<img class="emoji" src="' + encodeHtmlEntities(url) + '"/>');
1358
+				zss_editor.blurContentEditor()
1358 1359
 				zss_editor.enabledEditingItems();
1359 1360
 			}
1360 1361
 
@@ -1626,6 +1627,11 @@
1626 1627
 				editor.focus(callbackHandler);
1627 1628
 			}
1628 1629
 
1630
+			function addBlurEvent(editorId, callbackHandler) {
1631
+				var editor = $('#' + editorId);
1632
+				editor.blur(callbackHandler);
1633
+			}
1634
+
1629 1635
 			zss_editor.setTitleFocusHandler = function() {
1630 1636
 				addFocusEvent('zss_editor_title', function() {
1631 1637
 					ReactNativeWebView.postMessage(JSON.stringify({type: 'TITLE_FOCUSED'}))
@@ -1638,6 +1644,12 @@
1638 1644
 				});
1639 1645
 			}
1640 1646
 
1647
+			zss_editor.setContentBlurHandler = function() {
1648
+				addBlurEvent('zss_editor_content', function() {
1649
+					ReactNativeWebView.postMessage(JSON.stringify({type: 'CONTENT_BLUR'}))
1650
+				});
1651
+			}
1652
+
1641 1653
 			zss_editor.setEditorHeight = function(editorHeight) {
1642 1654
 				zss_editor.editorHeight = editorHeight;
1643 1655
 			}
@@ -1695,6 +1707,7 @@
1695 1707
 				padding-left: 10px;
1696 1708
 				padding-right: 10px;
1697 1709
 				line-height: 20px;
1710
+				caret-color:rgb(90, 149, 211)
1698 1711
 			}
1699 1712
 
1700 1713
 			#zss_editor_title {