From c08524c977ceb912ff716db7ab858e30d51b8990 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 3 Feb 2019 00:12:57 +0100 Subject: [PATCH] fix CSS class of user theme --- src/public/stylesheets/style.css | 2 +- src/routes/api/options.js | 27 ++++++++++++++++++++------- src/services/attributes.js | 1 + 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index fbdc5b9a6..163a542c7 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -597,7 +597,7 @@ button.icon-button { max-width: 100%; } -pre { +pre:not(.CodeMirror-line) { color: var(--main-text-color) !important; } diff --git a/src/routes/api/options.js b/src/routes/api/options.js index 98f9ab001..4a931af28 100644 --- a/src/routes/api/options.js +++ b/src/routes/api/options.js @@ -43,14 +43,27 @@ async function update(name, value) { } async function getUserThemes() { - return (await attributes.getNotesWithLabel('appTheme')) - .map(note => { - return { - val: note.title, - title: note.title, - noteId: note.noteId - }; + const notes = await attributes.getNotesWithLabel('appTheme'); + + const ret = []; + + for (const note of notes) { + let value; + + if (await note.hasLabel('appThemeClass')) { + value = await note.getLabelValue('appThemeClass'); + } else { + value = note.title.toLowerCase().replace(/[^a-z0-9]/gi, '-'); + } + + ret.push({ + val: value, + title: note.title, + noteId: note.noteId }); + } + + return ret; } module.exports = { diff --git a/src/services/attributes.js b/src/services/attributes.js index 57825d736..1cdfea4a6 100644 --- a/src/services/attributes.js +++ b/src/services/attributes.js @@ -16,6 +16,7 @@ const BUILTIN_ATTRIBUTES = [ { type: 'label', name: 'disableInclusion' }, { type: 'label', name: 'appCss' }, { type: 'label', name: 'appTheme' }, + { type: 'label', name: 'appThemeClass' }, { type: 'label', name: 'hideChildrenOverview' }, { type: 'label', name: 'hidePromotedAttributes' }, { type: 'label', name: 'readOnly' },