Plugin: Schedule work blocks

name

Work blocks

description

Select the text of a task and generate multiple work blocks for that task.

instructions


Best used in Calendar Mode. Select the entire text of a task, then from the floating toolbar that appears select the Work Blocks plugin. Use the prompt to type in how many instances of the task you want to generate.

Useful for time-blocking multiple work sessions on a single task/project.

setting

Note UUID to add tasks to

{
replaceText: {
"Schedule work blocks": async function(app, text) {
const destinationNote = await app.notes.find(app.settings["Note UUID to add tasks to"]);
const task_count = await app.prompt("How many work blocks would you like to generate?");
 
if (!this._isStringAnInteger(task_count)) {
app.alert("Not an integer number of work blocks.");
return null;
}
 
for (let i = 0; i < task_count; i++) {
destinationNote.insertTask({content: text, startAt: this._getNow()})
}
},
},
 
_getNow() {
const unixTimestamp = Math.floor(Date.now() / 1000);
return unixTimestamp;
},
 
_isStringAnInteger(str) {
const integerRegex = /^\d+$/;
return integerRegex.test(str);
},
}