Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
karelklima committed May 12, 2023
1 parent 67f70e8 commit 0ffc361
Showing 1 changed file with 88 additions and 10 deletions.
98 changes: 88 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,107 @@
# WorkFlowy API

This is an unofficial WorkFlowy API for Deno. It is experimental and may change
significantly in the future.
This is a [WorkFlowy](https://workflowy.com) client for Deno and Node. The goal
of this library is to enable WorkFlowy power users to access WorkFlowy lists
programatically and perhaps create some new automations and integrations.

Node.JS version is comming in the very near future.
## Features

## Usage
- Reading and updating WorkFlowy lists
- Export of lists to JSON or formatted plain text
- Basic search of items in lists
- Support for live copies (mirrors)

## Basic usage

### Fetching a WorkFlowy document

```typescript
import { WorkFlowy } from "https://deno.land/x/workflowy@0.0.1/mod.ts";
import { WorkFlowy } from "https://deno.land/x/workflowy@0.0.4/mod.ts";

const workflowy = new WorkFlowy("your@email.com", "your-password");
// Loads WorkFlowy outline into an interactive document structure
const document = await workflowy.getDocument();
// this is the root of the WorkFlowy outline
const homeNode = document.getHome();

const myProject = homeNode.projects[0];
console.log(myProject.name);
// Returns the the very first list in your WorkFlowy home
const myList = document.items[0];
// Prints information about the list
console.log(myList.name);
console.log(myList.note);

myProject.setName("Some new name of the node");
myList.setName("Some new name of the node");

// saves all the changes in the document
await document.save();
```

### Finding lists in a document

```typescript
const rootList = document.root;
const topLevelLists = document.items; // array of lists in the root
const myList = topLevelLists[0];

myList.findOne(/^Needle/); // Finds a sublist using a RegExp
myList.findAll(/^Needle/); // Finds all sublists using a RegExp
```

### Accessing basic list properties

```typescript
const rootList = document.root;
const myList = document.items[0];

myList.name; // name of the list
myList.note; // note of the list
myList.isCompleted; // whether or not the list or item is completed
myList.items; // items and sublists
```

### Editing lists

```typescript
myList.setName("New name").setNote("New note"); // sets a name and a note
const sublist = myList.createList(); // Creates a sublist
const subitem = myList.createItem(); // Alias for createList

myList.move(targetList); // moves a list or item to a different list
myList.delete(); // deletes the list
```

### Saving the changes to WorkFlowy

```typescript
if (document.isDirty()) {
// Saves the changes if there are any
await document.save();
}
```

## Installation

### From `npm` (Node/Bun)

```
npm install workflowy # npm
yarn add workflowy # yarn
bun add workflowy # bun
pnpm add workflowy # pnpm
```

### From `deno.land/x` (Deno)

Unlike Node, Deno relies on direct URL imports instead of a package manager like
NPM. The latest Deno version can be imported like so:

```typescript
import { WorkFlowy } from "https://deno.land/x/workflowy/mod.ts";
```

## Acknowledgements

Big thanks to [Mike Robertson](https://github.com/mikerobe) for providing the
`workflowy` NPM package name!

## License

MIT

0 comments on commit 0ffc361

Please sign in to comment.