Skip to the content
v1.0.1-beta.17

Task lists

Premium add-on. This page covers a premium add-on, included in Scriviamo Pro and Pro + Collaboration. See pricing

The premium tasks add-on makes checklist items tasks. There's no new block: mentioning someone in an item assigns it to them, and a date in it, from the free dates add-on, is its due date.

☐ Draft the contract @ada Dec 2

People write tasks the way they already write checklists, and a document with tasks opens in any editor, with or without this add-on, as a checklist with names and dates in it.

import {Tasks, TaskReview} from "./dist/addons/scriviamo.tasks.js"
import "./dist/addons/scriviamo.dates.js"   // for due dates as chips and their date picker

How an item becomes a task

  • A checklist item that mentions someone, or has a date, is a task; checking it off completes it. Other checklist items are plain checklist items, as in the free edition, and aren't listed.
  • The first person it mentions is its assignee, and anyone else it mentions is mentioned in it. People are mentions from a suggestion provider typed with "@"; see Comments and suggestions.
  • The first date in it is its due date. A task is overdue after that date, until it's done.

A task's text is the item's, without its due date, and without its assignee when the mention is at the start or end; other mentions read as the people's names, such as "Review pricing with Grace Hopper".

In the document, overdue tasks are tinted red, those due today amber, and the current user's own open tasks in the accent color.

Assigning and dating

With the caret in a checklist item, the Tasks tool's Assign To… lists the people to mention, and Due Date… has a date picker, with Today, Tomorrow and Next Week. Each replaces the task's assignee or due date, or adds one; a new assignee goes before the due date. Typing @ and a name, or inserting a date, does the same.

let task = Tasks.all(editor)[0]
Tasks.assign(editor, task, "grace")        // "" unassigns it
Tasks.setDue(editor, task, "2026-12-02")   // "" removes the date
Tasks.setDone(editor, task, true)

Each is one undo step.

Reviewing tasks

Review Tasks in the Tasks tool opens a sheet over the side of the editor, with three views:

  • All: every task in the document;
  • Assigned to Me: tasks whose assignee is the current user;
  • Mentioning Me: tasks that mention the current user without being assigned to them.

Each view shows how many of its tasks are open, and groups them as overdue, due today, upcoming and without a due date; Show Completed adds the completed ones. Check a task off in the sheet, or click it to go to it in the document.

To show the same review somewhere else, such as in your application's sidebar, place a TaskReview:

let review = new TaskReview(document.getElementById("tasks"), editor, {filter: "assigned", showDone: false})
review.filter = "mentioned"
// Later: review.editor = otherEditor, or review.dispose()

The review is also a tab for the inspector, "tasks", which it shows only when its tabs option lists it, since the Tasks tool already has the review:

new Inspector(element, {editor, tabs: ["properties", "comments", "outline", "tasks"]})

TasksPanel is the review as an editor panel, for applications that place panels themselves.

The current user

The views for the current user need to know who that is, as their mentions identify them:

Tasks.setCurrentUser(editor, "ada")   // or Tasks.currentUser = "ada" for every editor

Without one, it's the person among the editor's mention suggestions whose name is the comment author's, editor.annotations.authorName.

For your application

let tasks = Tasks.all(editor)                    // [{text, assignee, mentions, due, done, node, item}]
let mine = Tasks.filtered(editor, "assigned")    // "all", "assigned" or "mentioned"
editor.addEventListener("taskChanged", event => {
  let {task, previous, changes, local, by, byName} = event.detail   // changes: "done", "assignee" and "due"
  if (local && changes.includes("assignee") && task.assignee) notify(task.assignee, `${byName} assigned you: ${task.text}`)
})

taskChanged is raised as the document changes, by anyone, including other people while collaborating. local is true when this user made the change, and by and byName say who did: this user, or, while collaborating, the user whose change arrived, by their identifier among the mention suggestions and by their name. tasksChanged is raised whenever any task might have changed.

While collaborating, every editor with the document open raises taskChanged for each change, so act on it only where local is true, or the people in the document will each send the same notification. For notifications that don't depend on anyone having the document open, use Scriviamo Cloud's task webhooks.

On a server, read tasks from a saved document with a headless editor and the same Tasks.all(editor), such as to list someone's tasks across documents.

With Scriviamo Cloud

Scriviamo Cloud, the hosted collaboration service, reads the tasks in each document as it changes, and sends task.created, task.assigned, task.completed, task.reopened and task.due_changed webhooks with the task, the document, and who changed it. They're sent once per change, however many people have the document open, and whether or not anyone does, so they suit email and chat notifications. Cloud reads tasks from the document itself, so it needs no setting of its own: any checklist item with a mention or a date is one. See Cloud's webhook documentation for the events' contents.

MemberMeaning
Tasks.all(editor), Tasks.filtered(editor, filter)The document's tasks, in document order
Tasks.atCaret(editor)The task the caret is in, or null
Tasks.assign, Tasks.setDue, Tasks.setDoneChange a task; one undo step each
Tasks.isOverdue(task), Tasks.isDueToday(task)A task's state
Tasks.focus(editor, task)Goes to a task in the document
Tasks.toggleSheet(editor, show)Opens or closes the review sheet
Tasks.setCurrentUser(editor, identifier), Tasks.currentUserFor(editor)The current user
Tasks.soonDaysHow many days ahead a due date shows as soon; 3 by default