Added editor placeholder and auto set mode by content existence

This commit is contained in:
Wu Cheng-Han 2016-01-17 09:56:36 -06:00
parent 5c0a36f4d9
commit eddff9e863
5 changed files with 31 additions and 14 deletions

File diff suppressed because one or more lines are too long

View file

@ -19,6 +19,9 @@ body {
overflow-y: hidden !important; overflow-y: hidden !important;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
.CodeMirror-placeholder {
color: #777 !important;
}
.CodeMirror-scroll { .CodeMirror-scroll {
overflow-x: hidden !important; overflow-x: hidden !important;
overflow-y: auto !important; overflow-y: auto !important;

View file

@ -236,7 +236,8 @@ var editor = CodeMirror.fromTextArea(textit, {
extraKeys: defaultExtraKeys, extraKeys: defaultExtraKeys,
flattenSpans: true, flattenSpans: true,
addModeClass: true, addModeClass: true,
readOnly: true readOnly: true,
placeholder: "← Start by enter title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)"
}); });
var inlineAttach = inlineAttachment.editors.codemirror4.attach(editor); var inlineAttach = inlineAttachment.editors.codemirror4.attach(editor);
defaultTextHeight = parseInt($(".CodeMirror").css('line-height')); defaultTextHeight = parseInt($(".CodeMirror").css('line-height'));
@ -1214,7 +1215,18 @@ socket.on('refresh', function (data) {
updateLastChange(); updateLastChange();
updateLastChangeUser(data); updateLastChangeUser(data);
if (!loaded) { if (!loaded) {
var nocontent = editor.getValue().length <= 0;
if (nocontent) {
if (visibleXS)
currentMode = modeType.edit;
else
currentMode = modeType.both;
}
changeMode(currentMode); changeMode(currentMode);
if (nocontent) {
editor.focus();
editor.refresh();
}
loaded = true; loaded = true;
emitUserStatus(); //send first user status emitUserStatus(); //send first user status
updateOnlineStatus(); //update first online status updateOnlineStatus(); //update first online status

File diff suppressed because one or more lines are too long

View file

@ -11,6 +11,7 @@ addon/search/match-highlighter.js \
addon/scroll/simplescrollbars.js \ addon/scroll/simplescrollbars.js \
addon/scroll/annotatescrollbar.js \ addon/scroll/annotatescrollbar.js \
addon/display/panel.js \ addon/display/panel.js \
addon/display/placeholder.js \
addon/dialog/dialog.js \ addon/dialog/dialog.js \
addon/edit/matchbrackets.js \ addon/edit/matchbrackets.js \
addon/edit/closebrackets.js \ addon/edit/closebrackets.js \