mirror of
https://github.com/l7cy/obsidian-dynamic-timetable.git
synced 2026-07-22 07:40:29 +00:00
Compare commits
8 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cb10eb8dc | ||
|
|
6172371b21 | ||
|
|
6c9a235128 | ||
|
|
e7e8551679 | ||
|
|
4e1610ae66 | ||
|
|
f4f2169655 | ||
|
|
f3ec100666 | ||
|
|
bff62e9fa5 |
8 changed files with 34 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "dynamic-timetable",
|
||||
"name": "Dynamic Timetable",
|
||||
"version": "4.5.0",
|
||||
"version": "4.6.1",
|
||||
"minAppVersion": "1.2.8",
|
||||
"description": "Calculate the estimated time of completion from the estimated time of the task and dynamically create a timetable.",
|
||||
"author": "L7Cy",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "dynamic-timetable",
|
||||
"name": "Dynamic Timetable",
|
||||
"version": "4.5.0",
|
||||
"version": "4.6.1",
|
||||
"minAppVersion": "1.2.8",
|
||||
"description": "Calculate the estimated time of completion from the estimated time of the task and dynamically create a timetable.",
|
||||
"author": "L7Cy",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dynamic-timetable",
|
||||
"version": "4.5.0",
|
||||
"version": "4.6.1",
|
||||
"description": "Calculate the estimated time of completion from the estimated time of the task and dynamically create a timetable.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -4,11 +4,17 @@ type BufferTimeRowProps = {
|
|||
bufferTime: number | null;
|
||||
};
|
||||
|
||||
const formatTime = (minutes: number): string => {
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const remainingMinutes = minutes % 60;
|
||||
return `${hours}h${remainingMinutes}min`;
|
||||
};
|
||||
|
||||
const BufferTimeRow: React.FC<BufferTimeRowProps> = ({ bufferTime }) => (
|
||||
<tr className="buffer-time dt-buffer-time">
|
||||
<td>Buffer Time</td>
|
||||
<td colSpan={3} style={{ textAlign: 'center' }}>
|
||||
{bufferTime ? bufferTime : 0}min
|
||||
{bufferTime !== null ? formatTime(bufferTime) : '0h0min'}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,11 @@ export class DynamicTimetableSettingTab extends PluginSettingTab {
|
|||
'Enter a regex that matches the delimiter for a new day.',
|
||||
'^---$'
|
||||
);
|
||||
this.createTextSetting(
|
||||
'Show Until Regex',
|
||||
'showUntilRegex',
|
||||
'Enter a regex. Tasks will be shown until a line matching this regex is found.'
|
||||
);
|
||||
const headerNames = Array.isArray(this.plugin.settings.headerNames)
|
||||
? this.plugin.settings.headerNames.join(', ')
|
||||
: '';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export interface Task {
|
|||
|
||||
export class TaskParser {
|
||||
private dateDelimiter: RegExp;
|
||||
private showUntilRegex: RegExp;
|
||||
|
||||
constructor(
|
||||
private separator: string,
|
||||
|
|
@ -20,9 +21,13 @@ export class TaskParser {
|
|||
dateDelimiter: string,
|
||||
private showStartTimeInTaskName: boolean,
|
||||
private showEstimateInTaskName: boolean,
|
||||
private showCategoryNamesInTask: boolean
|
||||
private showCategoryNamesInTask: boolean,
|
||||
showUntilRegex: string
|
||||
) {
|
||||
this.dateDelimiter = dateDelimiter ? new RegExp(dateDelimiter) : /(?!x)x/;
|
||||
this.showUntilRegex = showUntilRegex
|
||||
? new RegExp(showUntilRegex)
|
||||
: /(?!x)x/;
|
||||
}
|
||||
|
||||
static fromSettings(settings: DynamicTimetableSettings): TaskParser {
|
||||
|
|
@ -32,7 +37,8 @@ export class TaskParser {
|
|||
settings.dateDelimiter,
|
||||
settings.showStartTimeInTaskName,
|
||||
settings.showEstimateInTaskName,
|
||||
settings.showCategoryNamesInTask
|
||||
settings.showCategoryNamesInTask,
|
||||
settings.showUntilRegex
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -41,18 +47,24 @@ export class TaskParser {
|
|||
let firstUncompletedTaskFound = false;
|
||||
let nextDay = 0;
|
||||
let dateDelimiterFound = false;
|
||||
let stopParsing = false;
|
||||
|
||||
const yamlStartTime = this.getYamlStartTime(content);
|
||||
const tasks = content
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.reduce((acc: Task[], task) => {
|
||||
if (stopParsing) return acc;
|
||||
if (this.isDateDelimiterLine(task)) {
|
||||
if (firstUncompletedTaskFound) {
|
||||
dateDelimiterFound = true;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
if (this.showUntilRegex.test(task)) {
|
||||
stopParsing = true;
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (
|
||||
!task.startsWith('- [ ]') &&
|
||||
|
|
|
|||
|
|
@ -115,10 +115,10 @@ const TimetableViewComponent = forwardRef<
|
|||
}
|
||||
newBackgroundColors[category] = color;
|
||||
document.documentElement.style.setProperty(`--${className}-bg`, color);
|
||||
if (!plugin.isCategoryColorsReady) {
|
||||
plugin.isCategoryColorsReady = true;
|
||||
}
|
||||
});
|
||||
if (!plugin.isCategoryColorsReady) {
|
||||
plugin.isCategoryColorsReady = true;
|
||||
}
|
||||
});
|
||||
|
||||
setCategoryBackgroundColors(newBackgroundColors);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ export interface DynamicTimetableSettings {
|
|||
pathToDictionary: string;
|
||||
showRemainingTime: boolean;
|
||||
customUrlScheme: string;
|
||||
showUntilRegex: string;
|
||||
[key: string]:
|
||||
| string
|
||||
| boolean
|
||||
|
|
@ -74,6 +75,7 @@ export default class DynamicTimetable extends Plugin {
|
|||
pathToDictionary: '',
|
||||
showRemainingTime: true,
|
||||
customUrlScheme: '',
|
||||
showUntilRegex: '',
|
||||
};
|
||||
|
||||
async onload() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue