From f4acd63c80918b8c8ba92846e00a29da19bb1df3 Mon Sep 17 00:00:00 2001 From: benni3-1415 Date: Sun, 7 Mar 2021 15:11:22 +0100 Subject: [PATCH 1/4] checkboxes in editor's style --- lib/renderer.js | 10 ++++++++-- styles/markdown-preview-github.less | 8 ++++++++ styles/markdown-preview.less | 7 +------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/renderer.js b/lib/renderer.js index ecc9139..a40258f 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -56,9 +56,15 @@ var render = function (text, filePath) { renderer = new marked.Renderer() renderer.listitem = function (text, isTask) { - const listAttributes = isTask ? ' class="task-list-item"' : '' + if (isTask) { + const textOnly = text.replace(/^/, "").trim() + const isChecked = /checked=""/.test(text) - return `
  • ${text}
  • \n` + const checkbox = `` + return `
  • ${checkbox} ${textOnly}
  • \n` + } + + return `
  • ${text}
  • \n` } } diff --git a/styles/markdown-preview-github.less b/styles/markdown-preview-github.less index fedb5cb..d131638 100644 --- a/styles/markdown-preview-github.less +++ b/styles/markdown-preview-github.less @@ -37,4 +37,12 @@ border-radius: 4px; overflow: auto; } + + .task-list-item input[type=checkbox] { + -webkit-appearance: checkbox; + + &::before, &:after { + display: none; + } + } } diff --git a/styles/markdown-preview.less b/styles/markdown-preview.less index bff8cec..99ac95e 100644 --- a/styles/markdown-preview.less +++ b/styles/markdown-preview.less @@ -19,12 +19,7 @@ user-select: auto; } - // move task list checkboxes - .task-list-item input[type=checkbox] { - position: absolute; - margin: .25em 0 0 -1.4em; - } - + // remove task list bullets .task-list-item { list-style-type: none; } From c01e87baeeb73c1907bcc8b16852b0ccdf157cab Mon Sep 17 00:00:00 2001 From: benni3-1415 Date: Sun, 7 Mar 2021 16:06:17 +0100 Subject: [PATCH 2/4] aligning checkboxes for different themes --- styles/markdown-preview-default.less | 37 ++++++++++++++++++++++++++++ styles/markdown-preview-github.less | 4 +++ 2 files changed, 41 insertions(+) diff --git a/styles/markdown-preview-default.less b/styles/markdown-preview-default.less index 25f7ade..eb40b52 100644 --- a/styles/markdown-preview-default.less +++ b/styles/markdown-preview-default.less @@ -154,3 +154,40 @@ } } + +// Align task list checkboxes -------------------- +.checkbox-position(@x, @y, @margin: 0) { + .markdown-preview:not([data-use-github-style]) { + .task-list-item .input-checkbox { + position: absolute; + transform: translate(~"calc(-50% - @{x})", ~"calc(-50% + @{y})"); + } + + .task-list-item { + margin: @margin 0 !important; + } + } +} + + +.checkbox-position(13px, 10px); + +.theme-atom-dark-ui, .theme-atom-light-ui { + .checkbox-position(13px, 10px, .1em); +} + +.theme-atom-material-ui { + .checkbox-position(15px, 9px, .4em); +} + +.theme-nucleus-dark-ui { + .checkbox-position(14px, 12px); +} + +.theme-solarized-dark-ui { + .checkbox-position(13px, 9px, .1em); +} + +.theme-solarized-light-ui { + .checkbox-position(14px, 12px, .1em); +} diff --git a/styles/markdown-preview-github.less b/styles/markdown-preview-github.less index d131638..da75083 100644 --- a/styles/markdown-preview-github.less +++ b/styles/markdown-preview-github.less @@ -39,6 +39,10 @@ } .task-list-item input[type=checkbox] { + margin: 0 .45em .25em -1.6em; + vertical-align: middle; + height: initial; width: initial; + -webkit-appearance: checkbox; &::before, &:after { From 4e1ae33dc41897391d688cdd55e33e02086a1cc4 Mon Sep 17 00:00:00 2001 From: benni3-1415 Date: Sun, 7 Mar 2021 16:40:55 +0100 Subject: [PATCH 3/4] correction for GitHub's theme --- styles/markdown-preview-github.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/markdown-preview-github.less b/styles/markdown-preview-github.less index da75083..9d34e4a 100644 --- a/styles/markdown-preview-github.less +++ b/styles/markdown-preview-github.less @@ -39,7 +39,7 @@ } .task-list-item input[type=checkbox] { - margin: 0 .45em .25em -1.6em; + margin: 0 .5em .25em -1.6em; vertical-align: middle; height: initial; width: initial; From ac3fe6a9f192485a6cdb76754b00965def0388cb Mon Sep 17 00:00:00 2001 From: benni3-1415 Date: Mon, 8 Mar 2021 17:30:57 +0100 Subject: [PATCH 4/4] using single quotes --- lib/renderer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/renderer.js b/lib/renderer.js index a40258f..03e8c8f 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -57,10 +57,10 @@ var render = function (text, filePath) { renderer = new marked.Renderer() renderer.listitem = function (text, isTask) { if (isTask) { - const textOnly = text.replace(/^/, "").trim() + const textOnly = text.replace(/^/, '').trim() const isChecked = /checked=""/.test(text) - const checkbox = `` + const checkbox = `` return `
  • ${checkbox} ${textOnly}
  • \n` }