mirror of https://github.com/status-im/codimd.git
Update to make editor mode setting to a default variable
This commit is contained in:
parent
f6f469d0fe
commit
e4b40d11a2
|
@ -1,6 +1,7 @@
|
||||||
var defaultTextHeight = 20;
|
var defaultTextHeight = 20;
|
||||||
var viewportMargin = 20;
|
var viewportMargin = 20;
|
||||||
var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
|
var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
|
||||||
|
var defaultEditorMode = 'gfm';
|
||||||
var defaultExtraKeys = {
|
var defaultExtraKeys = {
|
||||||
"F10": function (cm) {
|
"F10": function (cm) {
|
||||||
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
|
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
|
||||||
|
@ -359,8 +360,8 @@ var fileTypes = {
|
||||||
var textit = document.getElementById("textit");
|
var textit = document.getElementById("textit");
|
||||||
if (!textit) throw new Error("There was no textit area!");
|
if (!textit) throw new Error("There was no textit area!");
|
||||||
var editor = CodeMirror.fromTextArea(textit, {
|
var editor = CodeMirror.fromTextArea(textit, {
|
||||||
mode: 'gfm',
|
mode: defaultEditorMode,
|
||||||
backdrop: 'gfm',
|
backdrop: defaultEditorMode,
|
||||||
keyMap: "sublime",
|
keyMap: "sublime",
|
||||||
viewportMargin: viewportMargin,
|
viewportMargin: viewportMargin,
|
||||||
styleActiveLine: true,
|
styleActiveLine: true,
|
||||||
|
@ -603,7 +604,7 @@ function setSpellcheck() {
|
||||||
if (cookieSpellcheck === 'true' || cookieSpellcheck === true) {
|
if (cookieSpellcheck === 'true' || cookieSpellcheck === true) {
|
||||||
mode = 'spell-checker';
|
mode = 'spell-checker';
|
||||||
} else {
|
} else {
|
||||||
mode = 'gfm';
|
mode = defaultEditorMode;
|
||||||
}
|
}
|
||||||
if (mode && mode !== editor.getOption('mode')) {
|
if (mode && mode !== editor.getOption('mode')) {
|
||||||
editor.setOption('mode', mode);
|
editor.setOption('mode', mode);
|
||||||
|
@ -613,10 +614,10 @@ function setSpellcheck() {
|
||||||
var spellcheckToggle = statusSpellcheck.find('.ui-spellcheck-toggle');
|
var spellcheckToggle = statusSpellcheck.find('.ui-spellcheck-toggle');
|
||||||
spellcheckToggle.click(function () {
|
spellcheckToggle.click(function () {
|
||||||
var mode = editor.getOption('mode');
|
var mode = editor.getOption('mode');
|
||||||
if (mode == "gfm") {
|
if (mode == defaultEditorMode) {
|
||||||
mode = "spell-checker";
|
mode = "spell-checker";
|
||||||
} else {
|
} else {
|
||||||
mode = "gfm";
|
mode = defaultEditorMode;
|
||||||
}
|
}
|
||||||
if (mode && mode !== editor.getOption('mode')) {
|
if (mode && mode !== editor.getOption('mode')) {
|
||||||
editor.setOption('mode', mode);
|
editor.setOption('mode', mode);
|
||||||
|
@ -628,7 +629,7 @@ function setSpellcheck() {
|
||||||
});
|
});
|
||||||
function checkSpellcheck() {
|
function checkSpellcheck() {
|
||||||
var mode = editor.getOption('mode');
|
var mode = editor.getOption('mode');
|
||||||
if (mode == "gfm") {
|
if (mode == defaultEditorMode) {
|
||||||
spellcheckToggle.removeClass('active');
|
spellcheckToggle.removeClass('active');
|
||||||
} else {
|
} else {
|
||||||
spellcheckToggle.addClass('active');
|
spellcheckToggle.addClass('active');
|
||||||
|
@ -1756,7 +1757,7 @@ function initRevisionViewer() {
|
||||||
if (revisionViewer) return;
|
if (revisionViewer) return;
|
||||||
var revisionViewerTextArea = document.getElementById("revisionViewer");
|
var revisionViewerTextArea = document.getElementById("revisionViewer");
|
||||||
revisionViewer = CodeMirror.fromTextArea(revisionViewerTextArea, {
|
revisionViewer = CodeMirror.fromTextArea(revisionViewerTextArea, {
|
||||||
mode: 'gfm',
|
mode: defaultEditorMode,
|
||||||
viewportMargin: viewportMargin,
|
viewportMargin: viewportMargin,
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
lineWrapping: true,
|
lineWrapping: true,
|
||||||
|
|
Loading…
Reference in New Issue