From 6a3e7a5a8e76d7441e58f5b3eda9968c109b1dba Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 13 Jan 2019 20:14:33 +0100 Subject: [PATCH] generate css classes for each mime type, #328 --- src/public/javascripts/services/tree_builder.js | 15 +++++++++++++++ src/public/stylesheets/style.css | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/public/javascripts/services/tree_builder.js b/src/public/javascripts/services/tree_builder.js index cee322481..dbab2f260 100644 --- a/src/public/javascripts/services/tree_builder.js +++ b/src/public/javascripts/services/tree_builder.js @@ -168,9 +168,24 @@ async function getExtraClasses(note) { extraClasses.push(note.type); + if (note.mime) { // some notes should not have mime type (e.g. render) + extraClasses.push(getMimeTypeClass(note.mime)); + } + return extraClasses.join(" "); } +function getMimeTypeClass(mime) { + const semicolonIdx = mime.indexOf(';'); + + if (semicolonIdx !== -1) { + // stripping everything following the semicolon + mime = mime.substr(0, semicolonIdx); + } + + return 'mime-' + mime.toLowerCase().replace(/[\W_]+/g,"-"); +} + export default { prepareTree, prepareBranch, diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index edc9c11b0..d44240475 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -801,4 +801,9 @@ div[data-notify="container"] { 100% { transform: rotate(360deg); } +} + +.ck-content .image > figcaption { + color: var(--main-text-color); + background-color: var(--accented-background-color); } \ No newline at end of file