Sfoglia il codice sorgente

Added focusContent() and focusTitle()

Yedidya Kennard 7 anni fa
parent
commit
ba698796fb

+ 8
- 0
src/RichTextEditor.js Vedi File

@@ -114,6 +114,14 @@ export default class RichTextEditor extends Component {
114 114
   //-------------------------------------------------------------------------------
115 115
   //--------------- Public API
116 116
 
117
+  focusTitle() {
118
+    this._sendAction(actions.focusTitle);
119
+  }wewe
120
+
121
+  focusContent() {
122
+    this._sendAction(actions.focusContent);
123
+  }
124
+
117 125
   registerToolbar(listener) {
118 126
     this.setState({
119 127
       listeners: [...this.state.listeners, listener]

+ 6
- 0
src/WebviewMessageHandler.js Vedi File

@@ -114,6 +114,12 @@ export const InjectedMessageHandler = `
114 114
         case '${actions.setContentFocusHandler}':
115 115
           zss_editor.setContentFocusHandler();
116 116
           break;
117
+        case '${actions.focusContent}':
118
+          zss_editor.focusContent();
119
+          break;
120
+        case '${actions.focusTitle}':
121
+          zss_editor.focusTitle();
122
+          break;
117 123
       }
118 124
     };
119 125
   }

+ 8
- 0
src/ZSSRichTextEditor/ZSSRichTextEditor.js Vedi File

@@ -702,6 +702,14 @@ zss_editor.enabledEditingItems = function(e) {
702 702
     WebViewBridge.send(JSON.stringify({type: 'SELECTION_CHANGE', data: {items}}))
703 703
 }
704 704
 
705
+zss_editor.focusContent = function() {
706
+    zss_editor.focusEditor('zss_editor_content');
707
+}
708
+
709
+zss_editor.focusTitle = function() {
710
+    zss_editor.focusEditor('zss_editor_title');
711
+}
712
+
705 713
 zss_editor.focusEditor = function(editorId) {
706 714
     
707 715
     // the following was taken from http://stackoverflow.com/questions/1125292/how-to-move-cursor-to-end-of-contenteditable-entity/3866442#3866442

+ 2
- 0
src/const.js Vedi File

@@ -5,6 +5,8 @@ export const actions = {
5 5
   getContentHtml: 'GET_CONTENT_HTML',
6 6
   blurTitleEditor: 'BLUR_TITLE_EDITOR',
7 7
   blurContentEditor: 'BLUR_CONTENT_EDITOR',
8
+  focusTitle: 'FOCUS_TITLE',
9
+  focusContent: 'FOCUS_CONTENT',
8 10
 
9 11
   setBold: 'bold',
10 12
   setItalic: 'italic',