Navigation and bookmarks
Navigation
Section titled “Navigation”These functions move the reader through their history.
stepForward
Section titled “stepForward”Moves the reader forward one step through their history. Does nothing if the reader is already at the latest step.
stepForward(): Promise<void>Example
await stepForward();stepBack
Section titled “stepBack”Moves the reader back one step through their history, restoring the state from that step.
stepBack(): Promise<void>Example
await stepBack();isRewinding
Section titled “isRewinding”Returns true if the reader is currently stepping backward through the story.
isRewinding(): booleanExample
const rewinding = isRewinding();Bookmarks
Section titled “Bookmarks”A bookmark is a saved game. It captures the novel’s state so the reader can come back to it later.
Bookmarks save the state from the last committed beat. Any state changed after that isn’t included. See when to change state.
interface Bookmark { id: string; image: string; time: number; type: "auto" | "quick" | "user";}| Field | Description |
|---|---|
id | The bookmark’s name. |
image | A base64-encoded thumbnail image. |
time | When the bookmark was saved. |
type | Whether the bookmark was saved automatically, as a quicksave, or by the reader. |
getBookmarks
Section titled “getBookmarks”Returns every saved bookmark for the current novel.
getBookmarks(): Promise<Array<Bookmark>>Example
const bookmarks = await getBookmarks();saveBookmark
Section titled “saveBookmark”Saves a bookmark with the state from the last committed beat.
saveBookmark(bookmark: Bookmark): Promise<void>Example
await saveBookmark({ id: "Act III", image: base64EncodedImage, time: Date.now(), type: "auto",});loadBookmark
Section titled “loadBookmark”Loads a saved bookmark, restoring the novel to that point.
loadBookmark(bookmark: Bookmark): Promise<void>Example
const bookmarks = await getBookmarks();await loadBookmark(bookmarks[0]);