File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,17 @@ export default class RichTextEditor extends Component {
85
85
}
86
86
}
87
87
break ;
88
+ case messages . TITLE_TEXT_RESPONSE :
89
+ if ( this . titleTextResolve ) {
90
+ this . titleTextResolve ( message . data ) ;
91
+ this . titleTextResolve = undefined ;
92
+ this . titleTextReject = undefined ;
93
+ if ( this . pendingTitleText ) {
94
+ clearTimeout ( this . pendingTitleText ) ;
95
+ this . pendingTitleText = undefined ;
96
+ }
97
+ }
98
+ break ;
88
99
case messages . CONTENT_HTML_RESPONSE :
89
100
if ( this . contentResolve ) {
90
101
this . contentResolve ( message . data ) ;
@@ -440,6 +451,20 @@ export default class RichTextEditor extends Component {
440
451
} ) ;
441
452
}
442
453
454
+ async getTitleText ( ) {
455
+ return new Promise ( ( resolve , reject ) => {
456
+ this . titleTextResolve = resolve ;
457
+ this . titleTextReject = reject ;
458
+ this . _sendAction ( actions . getTitleText ) ;
459
+
460
+ this . pendingTitleText = setTimeout ( ( ) => {
461
+ if ( this . titleTextReject ) {
462
+ this . titleTextReject ( 'timeout' ) ;
463
+ }
464
+ } , 5000 ) ;
465
+ } ) ;
466
+ }
467
+
443
468
async getContentHtml ( ) {
444
469
return new Promise ( ( resolve , reject ) => {
445
470
this . contentResolve = resolve ;
Original file line number Diff line number Diff line change @@ -104,6 +104,10 @@ export const InjectedMessageHandler = `
104
104
var html = zss_editor.getTitleHTML();
105
105
WebViewBridge.send(JSON.stringify({type: '${ messages . TITLE_HTML_RESPONSE } ', data: html}));
106
106
break;
107
+ case '${ actions . getTitleText } ':
108
+ var html = zss_editor.getTitleText();
109
+ WebViewBridge.send(JSON.stringify({type: '${ messages . TITLE_TEXT_RESPONSE } ', data: html}));
110
+ break;
107
111
case '${ actions . getContentHtml } ':
108
112
var html = zss_editor.getContentHTML();
109
113
WebViewBridge.send(JSON.stringify({type: '${ messages . CONTENT_HTML_RESPONSE } ', data: html}));
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ export const actions = {
2
2
setTitleHtml : 'SET_TITLE_HTML' ,
3
3
setContentHtml : 'SET_CONTENT_HTML' ,
4
4
getTitleHtml : 'GET_TITLE_HTML' ,
5
+ getTitleText : 'GET_TITLE_TEXT' ,
5
6
getContentHtml : 'GET_CONTENT_HTML' ,
6
7
blurTitleEditor : 'BLUR_TITLE_EDITOR' ,
7
8
blurContentEditor : 'BLUR_CONTENT_EDITOR' ,
@@ -48,6 +49,7 @@ export const actions = {
48
49
49
50
export const messages = {
50
51
TITLE_HTML_RESPONSE : 'TITLE_HTML_RESPONSE' ,
52
+ TITLE_TEXT_RESPONSE : 'TITLE_TEXT_RESPONSE' ,
51
53
CONTENT_HTML_RESPONSE : 'CONTENT_HTML_RESPONSE' ,
52
54
ZSS_INITIALIZED : 'ZSS_INITIALIZED' ,
53
55
SCROLL : 'SCROLL' ,
You can’t perform that action at this time.
0 commit comments