fix: Show tasks completion on document list items (#2342)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
@@ -34,6 +34,9 @@
|
||||
"only you": "only you",
|
||||
"person": "person",
|
||||
"people": "people",
|
||||
"{{ total }} tasks": "{{ total }} tasks",
|
||||
"{{ completed }} tasks done": "{{ completed }} tasks done",
|
||||
"{{ completed }} of {{ total }} tasks": "{{ completed }} of {{ total }} tasks",
|
||||
"Currently editing": "Currently editing",
|
||||
"Currently viewing": "Currently viewing",
|
||||
"Viewed {{ timeAgo }} ago": "Viewed {{ timeAgo }} ago",
|
||||
|
||||
@@ -179,6 +179,7 @@ export const light = {
|
||||
|
||||
noticeInfoBackground: colors.warmGrey,
|
||||
noticeInfoText: colors.almostBlack,
|
||||
progressBarBackground: colors.slateLight,
|
||||
|
||||
scrollbarBackground: colors.smoke,
|
||||
scrollbarThumb: darken(0.15, colors.smokeDark),
|
||||
@@ -241,6 +242,7 @@ export const dark = {
|
||||
|
||||
noticeInfoBackground: colors.white10,
|
||||
noticeInfoText: colors.almostWhite,
|
||||
progressBarBackground: colors.slate,
|
||||
|
||||
scrollbarBackground: colors.black,
|
||||
scrollbarThumb: colors.lightBlack,
|
||||
|
||||
21
shared/utils/getTasks.js
Normal file
21
shared/utils/getTasks.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// @flow
|
||||
|
||||
const CHECKBOX_REGEX = /\[(X|\s|_|-)\]\s(.*)?/gi;
|
||||
|
||||
export default function getTasks(text: string) {
|
||||
const matches = [...text.matchAll(CHECKBOX_REGEX)];
|
||||
let total = matches.length;
|
||||
if (!total) {
|
||||
return {
|
||||
completed: 0,
|
||||
total: 0,
|
||||
};
|
||||
} else {
|
||||
const notCompleted = matches.reduce(
|
||||
(accumulator, match) =>
|
||||
match[1] === " " ? accumulator + 1 : accumulator,
|
||||
0
|
||||
);
|
||||
return { completed: total - notCompleted, total };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user