Focus the editable content when opening a codemirror pad

pull/1/head
yflory 7 years ago
parent bafa401473
commit 47cfa0cf45

@ -163,14 +163,6 @@ define([
content: textValue, content: textValue,
metadata: metadataMgr.getMetadataLazy() metadata: metadataMgr.getMetadataLazy()
}; };
/* metadata: {
users: UserList.userData,
defaultTitle: Title.defaultTitle
}
};
if (!initializing) {
obj.metadata.title = Title.title;
}*/
// set mode too... // set mode too...
obj.highlightMode = CodeMirror.highlightMode; obj.highlightMode = CodeMirror.highlightMode;
@ -428,9 +420,6 @@ define([
//console.log("%s => %s", CodeMirror.highlightMode, CodeMirror.$language.val()); //console.log("%s => %s", CodeMirror.highlightMode, CodeMirror.$language.val());
} }
// Update the user list (metadata) from the hyperjson
//Metadata.update(userDoc);
if (newDoc) { if (newDoc) {
editor.setValue(newDoc); editor.setValue(newDoc);
} }

@ -49,6 +49,7 @@ define([
readOnly: true readOnly: true
}); });
editor.setValue(Messages.codeInitialState); editor.setValue(Messages.codeInitialState);
editor.focus();
var setMode = exp.setMode = function (mode, cb) { var setMode = exp.setMode = function (mode, cb) {
exp.highlightMode = mode; exp.highlightMode = mode;

@ -454,9 +454,13 @@ define([
var metadataMgr = common.getMetadataMgr(); var metadataMgr = common.getMetadataMgr();
var type = metadataMgr.getMetadataLazy().type; var type = metadataMgr.getMetadataLazy().type;
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var focus;
var onConfirm = function (yes) { var onConfirm = function (yes) {
if (!yes) { return; } if (!yes) {
if (focus) { focus.focus(); }
return;
}
var first = true; // We can only pick a template once (for a new document) var first = true; // We can only pick a template once (for a new document)
var fileDialogCfg = { var fileDialogCfg = {
onSelect: function (data) { onSelect: function (data) {
@ -467,6 +471,7 @@ define([
Cryptpad.removeLoadingScreen(); Cryptpad.removeLoadingScreen();
common.feedback('TEMPLATE_USED'); common.feedback('TEMPLATE_USED');
}); });
if (focus) { focus.focus(); }
return; return;
} }
} }
@ -481,6 +486,7 @@ define([
sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) { sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) {
if (data) { if (data) {
focus = document.activeElement;
Cryptpad.confirm(Messages.useTemplate, onConfirm, { Cryptpad.confirm(Messages.useTemplate, onConfirm, {
ok: Messages.useTemplateOK, ok: Messages.useTemplateOK,
cancel: Messages.useTemplateCancel, cancel: Messages.useTemplateCancel,

Loading…
Cancel
Save