New CodeMirror default theme on dark mode

This commit is contained in:
yflory 2021-01-28 18:22:08 +01:00
parent 54e9c4a4b7
commit 519d5d7b5c
7 changed files with 26 additions and 16 deletions

View file

@ -286,7 +286,7 @@
@cp_admin-last-bg: lighten(@cryptpad_color_orange, 25%); @cp_admin-last-bg: lighten(@cryptpad_color_orange, 25%);
// Code // Code
@cp_preview-bg: @cryptpad_color_white; @cp_preview-bg: @cryptpad_color_light_grey;
@cp_preview-fg: @cryptpad_text_col; @cp_preview-fg: @cryptpad_text_col;
// Debug // Debug

View file

@ -123,7 +123,7 @@
@cp_sidebar-hint: @cryptpad_color_hint_grey; @cp_sidebar-hint: @cryptpad_color_hint_grey;
// Drive // Drive
@cp_drive-bg: @cp_sidebar_right-bg; @cp_drive-bg: @cp_sidebar-right-bg;
@cp_drive-fg: @cp_sidebar-right-fg; @cp_drive-fg: @cp_sidebar-right-fg;
@cp_drive-header-fg: @cryptpad_color_dark_grey; @cp_drive-header-fg: @cryptpad_color_dark_grey;
@cp_drive-icon-hover: @cryptpad_color_grey; @cp_drive-icon-hover: @cryptpad_color_grey;

View file

@ -11,6 +11,7 @@
flex-flow: column; flex-flow: column;
max-height: 100%; max-height: 100%;
min-height: auto; min-height: auto;
background-color: @cp_preview-bg;
#cp-app-code-container { #cp-app-code-container {
display: inline-flex; display: inline-flex;

View file

@ -379,10 +379,12 @@ define([
exp.configureTheme = function (Common, cb) { exp.configureTheme = function (Common, cb) {
/* Remember the user's last choice of theme using localStorage */ /* Remember the user's last choice of theme using localStorage */
var themeKey = ['codemirror', 'theme']; var isDark = window.CryptPad_theme === "dark";
var themeKey = ['codemirror', isDark ? 'themedark' : 'theme'];
var defaultTheme = isDark ? 'ansuz' : 'default';
var todo = function (err, lastTheme) { var todo = function (err, lastTheme) {
lastTheme = lastTheme || 'default'; lastTheme = lastTheme || defaultTheme;
var options = []; var options = [];
Themes.forEach(function (l) { Themes.forEach(function (l) {
options.push({ options.push({

View file

@ -249,6 +249,7 @@ define([
editor.refresh(); editor.refresh();
} }
}; };
cm.configureTheme(common, function () {});
SFCodeMirror.mkIndentSettings(editor, framework._.cpNfInner.metadataMgr); SFCodeMirror.mkIndentSettings(editor, framework._.cpNfInner.metadataMgr);
editor.on('change', function () { editor.on('change', function () {
var val = editor.getValue(); var val = editor.getValue();

View file

@ -17,6 +17,7 @@ define([
'/common/common-ui-elements.js', '/common/common-ui-elements.js',
'/common/hyperscript.js', '/common/hyperscript.js',
'/customize/messages.js', '/customize/messages.js',
'/common/sframe-common-codemirror.js',
'cm/lib/codemirror', 'cm/lib/codemirror',
'/common/test.js', '/common/test.js',
@ -48,6 +49,7 @@ define([
UIElements, UIElements,
h, h,
Messages, Messages,
SFCodeMirror,
CMeditor, CMeditor,
Test) Test)
{ {
@ -1330,12 +1332,13 @@ define([
APP.$comments = $('#cp-app-poll-comments-list'); APP.$comments = $('#cp-app-poll-comments-list');
APP.$addComment = $('#cp-app-poll-comments-add'); APP.$addComment = $('#cp-app-poll-comments-add');
APP.editor = CMeditor.fromTextArea(APP.$description[0], { var cm = SFCodeMirror.create("gfm", CMeditor, APP.$description[0]);
lineNumbers: true, var editor = APP.editor = cm.editor;
lineWrapping: true, editor.setOption('lineNumbers', true);
styleActiveLine : true, editor.setOption('lineWrapping', true);
mode: "markdown", editor.setOption('styleActiveLine', true);
}); editor.setOption('readOnly', false);
cm.configureTheme(common, function () {});
APP.$descriptionPublished.click(function (e) { APP.$descriptionPublished.click(function (e) {
if (!e.target) { return; } if (!e.target) { return; }

View file

@ -16,6 +16,7 @@ define([
'/customize/messages.js', '/customize/messages.js',
'/customize/application_config.js', '/customize/application_config.js',
'/bower_components/marked/marked.min.js', '/bower_components/marked/marked.min.js',
'/common/sframe-common-codemirror.js',
'cm/lib/codemirror', 'cm/lib/codemirror',
'cm/mode/markdown/markdown', 'cm/mode/markdown/markdown',
@ -44,6 +45,7 @@ define([
Messages, Messages,
AppConfig, AppConfig,
Marked, Marked,
SFCodeMirror,
CodeMirror CodeMirror
) )
{ {
@ -438,12 +440,13 @@ define([
]); ]);
$block.append(div); $block.append(div);
var editor = APP.editor = CodeMirror.fromTextArea(text, { var cm = SFCodeMirror.create("gfm", CodeMirror, text);
lineNumbers: true, var editor = APP.editor = cm.editor;
lineWrapping: true, editor.setOption('lineNumbers', true);
styleActiveLine : true, editor.setOption('lineWrapping', true);
mode: "markdown", editor.setOption('styleActiveLine', true);
}); editor.setOption('readOnly', false);
cm.configureTheme(common, function () {});
var markdownTb = common.createMarkdownToolbar(editor); var markdownTb = common.createMarkdownToolbar(editor);
$(code).prepend(markdownTb.toolbar); $(code).prepend(markdownTb.toolbar);