Compare commits

...

8 commits

Author SHA1 Message Date
L7Cy
0cb10eb8dc 4.6.1 2023-10-23 12:15:37 +09:00
L7Cy
6172371b21 showUntilRegexに変更 2023-10-23 12:14:50 +09:00
L7Cy
6c9a235128 4.6.0 2023-10-23 11:47:49 +09:00
L7Cy
e7e8551679 表示するタスクを制限する機能を追加 2023-10-23 11:46:18 +09:00
L7Cy
4e1610ae66 Merge branch 'master' of https://github.com/L7Cy/obsidian-dynamic-timetable 2023-10-23 10:45:36 +09:00
L7Cy
f4f2169655
Merge pull request #8 from knukio/master
カテゴリを設定しない場合に無限ループが発生する不具合を修正
2023-10-23 10:44:45 +09:00
knukio
f3ec100666 カテゴリを設定しない場合に無限ループが発生する不具合を修正 2023-10-20 17:55:45 +09:00
L7Cy
bff62e9fa5 buffer timeの表記をHHhMMminに変更 2023-09-11 13:25:18 +09:00
8 changed files with 34 additions and 9 deletions

View file

@ -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",

View file

@ -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",

View file

@ -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": {

View file

@ -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>
);

View file

@ -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(', ')
: '';

View file

@ -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('- [ ]') &&

View file

@ -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);

View file

@ -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() {