@black-studio/plugin 1.3.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +19 -1
  2. package/index.d.ts +28 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -94,6 +94,13 @@ var __blackPlugin = class extends __black.require('@black/plugin').Plugin {
94
94
  - 10: `app.folder` and `project:folder`, `network:ask`,
95
95
  `app.net.streamBytes`, `during`, `addVersionHistory`, `project.flush` and
96
96
  `project.getProjectData`
97
+ - 11: data kept with one item and with the whole project, and text fields
98
+ merged letter by letter
99
+ - 12: entries of a kind the plugin defines, `project.addToDictionary`,
100
+ `project.picture`, `project.storyTime` and continuity checks
101
+ - 13: series from book importers
102
+ - 14: `app.ui.sprint` and `app.format`
103
+ - 15: snapshots, and comments' authors and dates, from book importers
97
104
  - **`sandboxed`:** runs the plugin in a separate worker, apart from the
98
105
  window (see below).
99
106
  - **`locales`:** the plugin's name and description in other languages, by
@@ -581,7 +588,12 @@ Suggesters work in sandboxed plugins too.
581
588
  synopsis, notes, keywords, label and status. In the HTML, a footnote is
582
589
  `<sup data-footnote="its text"></sup>` where its number goes, and the text
583
590
  a comment is about is `<span data-comment="id">…</span>`, with the comment
584
- itself in the item's `comments` (API 12);
591
+ itself in the item's `comments` (API 12), with who wrote it (`by`) and
592
+ when (`created`, API 15);
593
+ - a document's earlier versions as its `snapshots`, each with a `title`,
594
+ the date it was `taken` and its `html` (API 15). An older app leaves
595
+ them out, so check `this.app.apiVersion` and tell the writer, as the
596
+ Scrivener import does;
585
597
  - beats on the storylines.
586
598
 
587
599
  Items refer to each other (a scene's cast and place, a beat's scene) by ids
@@ -641,6 +653,12 @@ export default class WordsToday extends Plugin {
641
653
  - `open(path, { select? })`: opens one of these books, at one of its
642
654
  documents.
643
655
  - **`app.ui.startSprint(minutes)`**: starts a writing sprint in the open book.
656
+ - **`app.ui.sprint()`** (API 14): the length of sprint the writer chose last,
657
+ to offer them, and the sprint running in the open book, if any. Start the
658
+ app's sprint at that length rather than keeping a timer of your own.
659
+ - **`app.format`** (API 14): `number(n)` and `date(iso)`, written as the app
660
+ writes them for the writer's region ("1 500" or "1,500"). Use them for
661
+ figures the writer sees beside the app's own.
644
662
 
645
663
  Draw cards with Bläck Studio's classes, so they look like the rest of the
646
664
  dashboard:
package/index.d.ts CHANGED
@@ -252,7 +252,7 @@ export interface LibraryBook {
252
252
  /** The word target (0 for none) and the deadline (YYYY-MM-DD, or '' for none). */
253
253
  target: number
254
254
  deadline: string
255
- /** The daily writing goal (0 for none). */
255
+ /** The daily target (0 for none). */
256
256
  sessionTarget: number
257
257
  /** Words written per day, keyed by date (YYYY-MM-DD, in the writer's time zone). Empty for a book that isn't counted. */
258
258
  history: Record<string, number>
@@ -282,6 +282,16 @@ export interface App {
282
282
  readonly apiVersion: number
283
283
  /** The language of the app's interface: 'en', 'sv'… */
284
284
  readonly language: string
285
+ /**
286
+ * Numbers and dates written as the app writes them. The app follows the writer's region, which can differ from the
287
+ * interface's language: "1 500" in a Swedish region, "1,500" in a British one. Use it for every number the writer
288
+ * reads beside the app's own. API 14: check that it exists.
289
+ */
290
+ readonly format?: {
291
+ number(n: number): string
292
+ /** A date (an ISO date or date and time) with the month as a word: "4 Dec 2026". */
293
+ date(iso: string): string
294
+ }
285
295
 
286
296
  /**
287
297
  * The open book. Changing it needs "project:write". Every change can be undone, and the app takes a snapshot
@@ -452,6 +462,13 @@ export interface App {
452
462
  choose(opts: { title: string; options: { value: string; label: string; detail?: string }[] }): Promise<string | null>
453
463
  /** Starts a writing sprint of 1 to 600 minutes in the open book, like the status bar's sprint. Throws if no book is open. API 2. */
454
464
  startSprint(minutes: number): void
465
+ /**
466
+ * The writer's sprint: `minutes` is the length they chose last in the app (25 if they never have), which is the
467
+ * length to offer them. `running` is the sprint going in the open book, if there is one, with when it ends (ISO)
468
+ * and the words written in it so far. Start a sprint with startSprint(minutes) rather than a timer of your own, so
469
+ * the status bar shows it and Statistics keeps it. API 14: check that it exists.
470
+ */
471
+ sprint?(): Promise<{ minutes: number; running: { minutes: number; endsAt: string; words: number } | null }>
455
472
  /**
456
473
  * Shows a list of the marks from one of this plugin's highlighters in the current document, each with its
457
474
  * surrounding text. The app selects the mark the writer picks. Resolves to false if there are no marks or
@@ -809,8 +826,16 @@ export interface ImportedItem {
809
826
  * `<span data-comment="id">…</span>`, with the comment in `comments` (API 12).
810
827
  */
811
828
  html?: string
812
- /** Comments on the text, each anchored by its `id` in `html`. The writer sees them in the margin (API 12). */
813
- comments?: { id: string; text: string; by?: string }[]
829
+ /**
830
+ * Comments on the text, each anchored by its `id` in `html`. The writer sees them in the margin (API 12). `by` is who
831
+ * wrote it, and `created` when, as an ISO date (API 15; before, the import's date). Without `by`, it's the writer's.
832
+ */
833
+ comments?: { id: string; text: string; by?: string; created?: string }[]
834
+ /**
835
+ * Earlier versions of the text, which become the document's snapshots: each with its name, when it was taken (an ISO
836
+ * date; the import's date if not given) and its text as HTML (API 15). An older app leaves them out.
837
+ */
838
+ snapshots?: { title: string; taken?: string; html: string }[]
814
839
  synopsis?: string
815
840
  notes?: string
816
841
  keywords?: string[]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@black-studio/plugin",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "Write plugins for Bläck Studio: the plugin API's types, and a build that turns TypeScript or JSX source into a plugin folder.",
5
5
  "keywords": ["black-studio", "plugin", "writing"],
6
6
  "homepage": "https://blackstudio.app/developers/",