Skip to content

Notebooks

Notebooks is a note-taking and writing app. Protocol Launcher allows you to generate Notebooks URL scheme links for opening documents, adding notes, searching, creating items, appending text, importing URLs, and starting sharing or sync.

Usage

There are two ways to use this library:

  • On-Demand import from subpaths enables tree-shaking and keeps bundles small.
  • Full Import from the root package is convenient but includes all app modules.

Pick On-Demand for production builds; Full Import is fine for quick scripts or demos.

Select Installation Method

On-Demand
Recommended. Optimized for production.
Full Import
Convenient. Good for quick scripts.

Open Documents

Notebooks documents two forms for opening a document: notebooks://show/<path> and the direct internal-link form notebooks://<path>. Paths are relative to the Notebooks root.

On-Demand
ts
import { openDocument, openInternalLink } from 'protocol-launcher/notebooks'

const showUrl = openDocument({
  path: 'escaped path to document',
})

const internalUrl = openInternalLink({
  path: 'escaped path to document',
})

Add, Search, and Append

Use addNote() for notebooks://addnote/, search() for notebooks://search/, and append() for notebooks://append/. The optional parent, scope, and doc values are Notebooks paths.

On-Demand
ts
import { addNote, search, append } from 'protocol-launcher/notebooks'

const noteUrl = addNote({
  text: 'note body',
  title: 'Title is optional',
  parent: 'path to parent',
})

const searchUrl = search({
  term: 'term to search for',
  scope: 'book/to/search',
})

const appendUrl = append({
  text: 'text to add',
  doc: 'path to document.txt',
})

New Document, Task, and Sketch

Notebooks documents addNewDoc, addNewTask, and addNewSketch. Each can optionally include a parent book path.

On-Demand
ts
import { newDocument, newTask, newSketch } from 'protocol-launcher/notebooks'

const documentUrl = newDocument({
  parent: 'path to parent',
})

const taskUrl = newTask({
  parent: 'path to parent',
})

const sketchUrl = newSketch({
  parent: 'path to parent',
})

Import, Sharing, and Sync

Use grab() to import a document from a URL. On iPhone and iPad, Notebooks also documents wifi_sharing and webdav_sync, each optionally scoped to a book path.

On-Demand
ts
import { grab, wifiSharing, webdavSync } from 'protocol-launcher/notebooks'

const grabUrl = grab({
  url: 'URL',
  title: 'Title of document',
  parent: 'Path to target book',
})

const sharingUrl = wifiSharing({
  path: 'Path To Book To Share',
})

const syncUrl = webdavSync({
  path: 'Path To Book To Sync',
})

Generated URLs

ts
openDocument({ path: 'escaped path to document' })
// => 'notebooks://show/escaped%20path%20to%20document'

openInternalLink({ path: 'escaped path to document' })
// => 'notebooks://escaped%20path%20to%20document'

addNote({ text: 'note body', title: 'Title is optional', parent: 'path to parent' })
// => 'notebooks://addnote/note%20body&title=Title%20is%20optional&parent=path%20to%20parent'

addNote({ text: 'note body', title: 'title for document' })
// => 'notebooks://addnote/note%20body&title=title%20for%20document'

addNote({ text: 'note body' })
// => 'notebooks://addnote/note%20body'

search({ term: 'term to search for', scope: 'book/to/search' })
// => 'notebooks://search/term%20to%20search%20for&scope=book/to/search'

newDocument({ parent: 'path to parent' })
// => 'notebooks://addNewDoc&parent=path%20to%20parent'

newDocument()
// => 'notebooks://addNewDoc'

newTask({ parent: 'path to parent' })
// => 'notebooks://addNewTask&parent=path%20to%20parent'

newSketch({ parent: 'path to parent' })
// => 'notebooks://addNewSketch&parent=path%20to%20parent'

append({ text: 'text to add', doc: 'path to document.txt' })
// => 'notebooks://append/text%20to%20add&doc=path%20to%20document.txt'

grab({ url: 'URL', title: 'Title of document' })
// => 'notebooks://grab/URL&title=Title%20of%20document'

grab({ url: 'URL', title: 'Title of document', parent: 'Path to target book' })
// => 'notebooks://grab/URL&title=Title%20of%20document&parent=Path%20to%20target%20book'

grab({ url: 'URL' })
// => 'notebooks://grab/URL'

wifiSharing({ path: 'Path To Book To Share' })
// => 'notebooks://wifi_sharing/Path%20To%20Book%20To%20Share'

wifiSharing()
// => 'notebooks://wifi_sharing'

webdavSync({ path: 'Path To Book To Sync' })
// => 'notebooks://webdav_sync/Path%20To%20Book%20To%20Sync'

References