@@ -41,6 +41,40 @@ function initComposeEditor(id, content, readOnly = false)
4141 composeEditor = editor ;
4242}
4343// ---------------------------------------------------------------------------------------------
44+ function composeEditorPlaceholder ( containerId , placeholder )
45+ {
46+ if ( ! placeholder ) {
47+ return ;
48+ }
49+
50+ const container = document . getElementById ( containerId ) ;
51+ const overlay = document . createElement ( 'div' ) ;
52+
53+ overlay . className = 'compose-placeholder' ;
54+ overlay . textContent = placeholder ;
55+ container . appendChild ( overlay ) ;
56+
57+ const position = ( ) => {
58+ if ( ! composeEditor || ! composeEditor . renderer ) {
59+ return ;
60+ }
61+ const pos = composeEditor . renderer . textToScreenCoordinates ( 0 , 0 ) ;
62+ const rect = container . getBoundingClientRect ( ) ;
63+ overlay . style . left = ( pos . pageX - rect . left ) + 'px' ;
64+ overlay . style . top = ( pos . pageY - rect . top ) + 'px' ;
65+ } ;
66+
67+ const update = ( ) => {
68+ overlay . style . display = composeEditor && composeEditor . getValue ( ) === '' ? 'block' : 'none' ;
69+ } ;
70+
71+ composeEditor . on ( 'change' , update ) ;
72+ composeEditor . renderer . on ( 'changeGutterWidth' , position ) ;
73+ composeEditor . renderer . on ( 'resize' , position ) ;
74+ window . setTimeout ( position , 0 ) ;
75+ update ( ) ;
76+ }
77+ // ---------------------------------------------------------------------------------------------
4478function openComposeAdd ( )
4579{
4680 $ . ajax ( {
@@ -54,7 +88,8 @@ function openComposeAdd()
5488 size : 'lg' ,
5589 body : resultData ,
5690 onOpen : function ( ) {
57- initComposeEditor ( 'compose-add-editor' , $ ( '#compose-add-data' ) . val ( ) ) ;
91+ initComposeEditor ( 'compose-add-editor' , '' ) ;
92+ composeEditorPlaceholder ( 'compose-add-editor' , $ ( '#compose-add-editor' ) . data ( 'placeholder' ) ) ;
5893 } ,
5994 onClose : function ( ) {
6095 if ( composeEditor ) {
@@ -214,9 +249,9 @@ function composeStream(path, action)
214249 socket . close ( ) ;
215250 if ( data . code === 0 ) {
216251 toast ( 'Compose' , label + ' was completed' , 'success' ) ;
217- $ ( '#compose-stream-output' ) . text ( $ ( '#compose-stream-output' ) . text ( ) + '\n[complete]' ) ;
252+ $ ( '#compose-stream-output' ) . text ( $ ( '#compose-stream-output' ) . text ( ) + '\n[complete]\r\nAuto closing in 10s.. ' ) ;
218253
219- setTimeout ( ( ) => dialogClose ( 'composeStream' ) , 300 ) ;
254+ setTimeout ( ( ) => dialogClose ( 'composeStream' ) , 10e3 ) ;
220255 } else {
221256 toast ( 'Compose' , label + ' failed<br>' + ( data . message || 'unknown error' ) , 'error' ) ;
222257 $ ( '#compose-stream-output' ) . text ( $ ( '#compose-stream-output' ) . text ( ) + '\n[failed]' ) ;
0 commit comments