@@ -40,8 +40,6 @@ import {
40
40
mdiEyeOutline ,
41
41
mdiViewSplitVertical ,
42
42
mdiDotsHorizontal ,
43
- mdiCloudOffOutline ,
44
- mdiCloudSyncOutline ,
45
43
} from '@mdi/js'
46
44
import EditorToolButton from './EditorToolButton'
47
45
import { not } from 'ramda'
@@ -101,6 +99,7 @@ import CustomizedMarkdownPreviewer from '../MarkdownView/CustomizedMarkdownPrevi
101
99
import BottomBarButton from '../BottomBarButton'
102
100
import { YText } from 'yjs/dist/src/internals'
103
101
import { useLocalSnapshot } from '../../lib/stores/localSnapshots'
102
+ import SyncStatus from '../Topbar/SyncStatus'
104
103
105
104
type LayoutMode = 'split' | 'preview' | 'editor'
106
105
@@ -159,6 +158,8 @@ const Editor = ({
159
158
: 'preview'
160
159
)
161
160
const [ editorContent , setEditorContent ] = useState ( '' )
161
+ const [ showingConnectIssueMessage , setShowingShowingConnectIssueMessage ] =
162
+ useState < boolean > ( false )
162
163
const docRef = useRef < string > ( '' )
163
164
const router = useRouter ( )
164
165
const { state } = router
@@ -485,6 +486,16 @@ const Editor = ({
485
486
} )
486
487
} , [ openModal , onTemplatePickCallback ] )
487
488
489
+ useEffect ( ( ) => {
490
+ if ( connState == 'reconnecting' ) {
491
+ setShowingShowingConnectIssueMessage ( true )
492
+ } else if ( connState == 'disconnected' ) {
493
+ setShowingShowingConnectIssueMessage ( true )
494
+ } else {
495
+ setShowingShowingConnectIssueMessage ( false )
496
+ }
497
+ } , [ connState ] )
498
+
488
499
const toggleScrollSync = useCallback ( ( ) => {
489
500
setScrollSync ( not )
490
501
} , [ ] )
@@ -846,57 +857,6 @@ const Editor = ({
846
857
{
847
858
type : 'separator' ,
848
859
} ,
849
- ...( connState === 'reconnecting'
850
- ? [
851
- {
852
- type : 'button' ,
853
- iconPath : mdiCloudSyncOutline ,
854
- variant : 'danger' ,
855
- disabled : true ,
856
- label : translate ( lngKeys . EditorReconnectAttempt ) ,
857
- tooltip : (
858
- < >
859
- { translate ( lngKeys . EditorReconnectAttempt1 ) }
860
- < br />
861
- { translate ( lngKeys . EditorReconnectAttempt2 ) }
862
- </ >
863
- ) ,
864
- } ,
865
- ]
866
- : connState === 'disconnected'
867
- ? [
868
- {
869
- type : 'button' ,
870
- iconPath : mdiCloudOffOutline ,
871
- variant : 'danger' ,
872
- onClick : ( ) => realtime . connect ( ) ,
873
- label : translate ( lngKeys . EditorReconnectDisconnected ) ,
874
- tooltip : (
875
- < >
876
- { translate ( lngKeys . EditorReconnectDisconnected1 ) }
877
- < br />
878
- { translate ( lngKeys . EditorReconnectDisconnected2 ) }
879
- </ >
880
- ) ,
881
- } ,
882
- ]
883
- : connState === 'loaded'
884
- ? [
885
- {
886
- type : 'button' ,
887
- variant : 'secondary' as const ,
888
- disabled : true ,
889
- label : translate ( lngKeys . EditorReconnectSyncing ) ,
890
- tooltip : (
891
- < >
892
- { translate ( lngKeys . EditorReconnectSyncing1 ) }
893
- < br />
894
- { translate ( lngKeys . EditorReconnectSyncing2 ) }
895
- </ >
896
- ) ,
897
- } ,
898
- ]
899
- : [ ] ) ,
900
860
...( docIsEditable && currentUserIsCoreMember
901
861
? [
902
862
{
@@ -1069,6 +1029,9 @@ const Editor = ({
1069
1029
) }
1070
1030
</ Container >
1071
1031
</ EditorLayout >
1032
+ { showingConnectIssueMessage && (
1033
+ < SyncStatus provider = { realtime } connState = { connState } />
1034
+ ) }
1072
1035
</ ApplicationContent >
1073
1036
</ ApplicationPage >
1074
1037
)
@@ -1102,6 +1065,7 @@ const StyledBottomBar = styled.div`
1102
1065
height: 24px;
1103
1066
background-color: ${ ( { theme } ) => theme . colors . background . primary } ;
1104
1067
box-sizing: content-box;
1068
+
1105
1069
& > :first-child {
1106
1070
flex: 1;
1107
1071
}
@@ -1142,6 +1106,7 @@ const StyledShortcodeConvertMenu = styled.div`
1142
1106
1143
1107
const StyledLayoutDimensions = styled . div `
1144
1108
width: 100%;
1109
+
1145
1110
&.preview,
1146
1111
.preview {
1147
1112
width: 100%;
@@ -1163,17 +1128,21 @@ const ToolbarRow = styled.div`
1163
1128
border: solid 1px ${ ( { theme } ) => theme . colors . border . second } ;
1164
1129
border-radius: 5px;
1165
1130
`
1131
+
1166
1132
interface FontOptionsProps {
1167
1133
fontSize : string
1168
1134
fontFamily : string
1169
1135
}
1136
+
1170
1137
const StyledEditorWrapper = styled . div < BaseTheme & FontOptionsProps > `
1171
1138
position: relative;
1172
1139
height: auto;
1173
1140
width: 50%;
1141
+
1174
1142
&.layout-editor {
1175
1143
width: 100%;
1176
1144
}
1145
+
1177
1146
&.layout-preview {
1178
1147
display: none;
1179
1148
}
@@ -1189,19 +1158,23 @@ const StyledEditorWrapper = styled.div<BaseTheme & FontOptionsProps>`
1189
1158
const StyledPreview = styled . div `
1190
1159
height: 100%;
1191
1160
width: 50%;
1161
+
1192
1162
&.layout-split {
1193
1163
width: 50%;
1164
+
1194
1165
.scroller {
1195
1166
height: 100%;
1196
1167
overflow: auto;
1197
1168
border-left: 1px solid ${ ( { theme } ) => theme . colors . border . main } ;
1198
1169
}
1199
1170
}
1171
+
1200
1172
&.layout-preview {
1201
1173
padding-top: ${ ( { theme } ) => theme . sizes . spaces . sm } px;
1202
1174
margin: 0 auto;
1203
1175
width: 100%;
1204
1176
}
1177
+
1205
1178
&.layout-editor {
1206
1179
display: none;
1207
1180
}
@@ -1223,21 +1196,25 @@ const StyledEditor = styled.div`
1223
1196
height: auto;
1224
1197
min-height: 0;
1225
1198
font-size: 15px;
1199
+
1226
1200
&.preview,
1227
1201
.preview {
1228
1202
${ rightSidePageLayout } ;
1229
1203
margin: auto;
1230
1204
}
1205
+
1231
1206
& .CodeMirrorWrapper {
1232
1207
height: 100%;
1233
1208
word-break: break-word;
1234
1209
}
1210
+
1235
1211
& .CodeMirror {
1236
1212
width: 100%;
1237
1213
height: 100%;
1238
1214
position: relative;
1239
1215
z-index: 0 !important;
1240
1216
line-height: 1.4em;
1217
+
1241
1218
.CodeMirror-hints {
1242
1219
position: absolute;
1243
1220
z-index: 10;
@@ -1254,6 +1231,7 @@ const StyledEditor = styled.div`
1254
1231
font-family: monospace;
1255
1232
list-style: none;
1256
1233
}
1234
+
1257
1235
.CodeMirror-hint {
1258
1236
position: relative;
1259
1237
margin: 0;
@@ -1264,8 +1242,10 @@ const StyledEditor = styled.div`
1264
1242
cursor: pointer;
1265
1243
font-size: ${ ( { theme } ) => theme . sizes . fonts . xsm } px;
1266
1244
}
1245
+
1267
1246
li.CodeMirror-hint-active {
1268
1247
color: ${ ( { theme } ) => theme . colors . variants . primary . base } ;
1248
+
1269
1249
&:before {
1270
1250
content: '';
1271
1251
display: block;
@@ -1277,15 +1257,18 @@ const StyledEditor = styled.div`
1277
1257
background-color: ${ ( { theme } ) => theme . colors . variants . primary . base } ;
1278
1258
}
1279
1259
}
1260
+
1280
1261
& .remote-caret {
1281
1262
position: relative;
1282
1263
border-left: 1px solid black;
1283
1264
margin-left: -1px;
1284
1265
box-sizing: border-box;
1266
+
1285
1267
&:hover > div {
1286
1268
opacity: 1;
1287
1269
transition-delay: 0s;
1288
1270
}
1271
+
1289
1272
& > div {
1290
1273
position: absolute;
1291
1274
left: -1px;
@@ -1307,15 +1290,18 @@ const StyledEditor = styled.div`
1307
1290
}
1308
1291
}
1309
1292
}
1293
+
1310
1294
.CodeMirror-scroll {
1311
1295
position: relative;
1312
1296
z-index: 0;
1313
1297
width: 100%;
1314
1298
}
1299
+
1315
1300
.CodeMirror-code,
1316
1301
.CodeMirror-gutters {
1317
1302
padding-bottom: 32px;
1318
1303
}
1304
+
1319
1305
& .file-loading-widget {
1320
1306
transform: translate3d(0, -100%, 0);
1321
1307
}
0 commit comments