Skip to content

Commit eddff9e

Browse files
committed
Added editor placeholder and auto set mode by content existence
1 parent 5c0a36f commit eddff9e

5 files changed

Lines changed: 31 additions & 14 deletions

File tree

public/css/html.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ body {
1919
overflow-y: hidden !important;
2020
-webkit-overflow-scrolling: touch;
2121
}
22+
.CodeMirror-placeholder {
23+
color: #777 !important;
24+
}
2225
.CodeMirror-scroll {
2326
overflow-x: hidden !important;
2427
overflow-y: auto !important;

public/js/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ var editor = CodeMirror.fromTextArea(textit, {
236236
extraKeys: defaultExtraKeys,
237237
flattenSpans: true,
238238
addModeClass: true,
239-
readOnly: true
239+
readOnly: true,
240+
placeholder: "← Start by enter title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)"
240241
});
241242
var inlineAttach = inlineAttachment.editors.codemirror4.attach(editor);
242243
defaultTextHeight = parseInt($(".CodeMirror").css('line-height'));
@@ -1214,7 +1215,18 @@ socket.on('refresh', function (data) {
12141215
updateLastChange();
12151216
updateLastChangeUser(data);
12161217
if (!loaded) {
1218+
var nocontent = editor.getValue().length <= 0;
1219+
if (nocontent) {
1220+
if (visibleXS)
1221+
currentMode = modeType.edit;
1222+
else
1223+
currentMode = modeType.both;
1224+
}
12171225
changeMode(currentMode);
1226+
if (nocontent) {
1227+
editor.focus();
1228+
editor.refresh();
1229+
}
12181230
loaded = true;
12191231
emitUserStatus(); //send first user status
12201232
updateOnlineStatus(); //update first online status

public/vendor/codemirror/codemirror.min.js

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/vendor/codemirror/compress.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ addon/search/match-highlighter.js \
1111
addon/scroll/simplescrollbars.js \
1212
addon/scroll/annotatescrollbar.js \
1313
addon/display/panel.js \
14+
addon/display/placeholder.js \
1415
addon/dialog/dialog.js \
1516
addon/edit/matchbrackets.js \
1617
addon/edit/closebrackets.js \

0 commit comments

Comments
 (0)