1.1.5 • Published 3 years ago

@doist/todoist-quickadd v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

todoist-quickadd

Add the powerful Todoist Quick Add anywhere on the web. The experience is simple, beautiful, and fast.

The Todoist Quick Add also supports all of the powerful features, such as natural language parsing.

Installation

Use npm or yarn to install:

npm install @doist/todoist-quickadd
# or
yarn add @doist/todoist-quickadd

Usage (vanilla JavaScript)

import { showQuickAdd } from '@doist/todoist-quickadd'

showQuickAdd({
    content: 'Hello world',
    priority: 3,
    date: 'today',
})

Usage (React)

import { useState, useEffect } from 'react'

import { showQuickAdd } from '@doist/todoist-quickadd'

function Todoist() {
    const [content, setContent] = (useState < string) | (null > null)

    // Set up store listener
    useEffect(() => {
        const todoistListener = Store.addListener(() => {
            setContent(TodoistStore.getState().content)
        })
        return () => todoistListener && todoistListener.remove()
    }, [])

    // Handle content change
    useEffect(() => {
        function onLoadingError() {
            alert('Could not load Todoist Quick Add. Please try again later.')
        }

        if (content) {
            StoreActions.resetContent()

            showQuickAdd({
                content: content,
                onLoadingError: onLoadingError,
            })
        }
    }, [content])

    return null
}

showQuickAdd API

The showQuickAdd function can take the following parameters. All of them are optional:

NameTypeDescription
contentstringThe preset content
prioritynumber between 1 and 4The preset priority
themenumber between 1 and 11Force a specific Todoist theme (e.g, 2 for Todoist Red,and 11 for Todoist Darkmode)
project_idnumberThe preset project (by default it's the Inbox)
onAdd(item: any) => voidCallback that will be called when a task is added.
onClose() => voidCallback that will be called when the Quick Add is closed
onLoadingError() => voidCallback that will be called when the Quick Add fails to load
todoistHoststringAn optional Todoist host, e.g. staging.todoist.com

Changelog

We're maintaining a changelog in this repository. Our versioning follows semantic versioning.

Releasing

A new version of todoist-quickadd is published both on npm and GitHub Package Registry whenever a new release on GitHub is created. A GitHub Action will automatically perform all the necessary steps.

The Action will release the version number that's specified inside the package.json's version field so make sure that it reflects the version you want to publish. Additionally, the Action can be triggered manually in case something went wrong in the automation.

Contributing

Contributions are welcome.

License

This project is distributed under the MIT License.