@black-studio/plugin 1.2.0 → 1.3.1

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 +11 -0
  2. package/index.d.ts +40 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -590,6 +590,17 @@ Suggesters work in sandboxed plugins too.
590
590
  why a file can't be read, throw an Error. Book importers need no
591
591
  permission and work in sandboxed plugins. They need `"apiVersion": 7`. The
592
592
  Scrivener and Plottr imports on the list are built this way.
593
+
594
+ For a file that holds several books, `import` can return a series instead
595
+ (`ImportedSeries`, API 13): its `books`, each an `ImportedBook` with an `id`;
596
+ the `characters` and `places` they share, which go in the series bible; the
597
+ `storylines` through the series, with what each does in each book (`beats`,
598
+ by the book's `id`); and the series' `notes`. Bläck Studio makes it a new
599
+ series, and each book gets a sheet linked to the bible for every shared
600
+ character and place its scenes name (or its `shared` list names). Only
601
+ Bläck Studio with API 13 or later reads a series, so check
602
+ `this.app.apiVersion` and return a single book to older versions, as the
603
+ Plottr import does. Its manifest can then keep `"apiVersion": 7`.
593
604
  - **`styles.css`:** if it's next to the manifest, Bläck Studio loads it with
594
605
  the plugin and removes it when the plugin is removed. Put your plugin's id
595
606
  in your class names, so they don't clash with Bläck Studio's or another
package/index.d.ts CHANGED
@@ -132,7 +132,8 @@ export interface Manifest {
132
132
  }
133
133
 
134
134
  /** `entry` is a sheet of a kind a plugin defines (defineKind, API 12). */
135
- export type NodeType = 'text' | 'folder' | 'character' | 'place' | 'note' | 'research' | 'file' | 'entry'
135
+ /** `chapter` is a chapter line in the manuscript, which starts a chapter and names it (its title, or '' for its number only). */
136
+ export type NodeType = 'text' | 'folder' | 'character' | 'place' | 'note' | 'research' | 'file' | 'entry' | 'chapter'
136
137
 
137
138
  /** The icons a kind of entry may use, from the app's own. API 12. */
138
139
  export type KindIcon =
@@ -789,7 +790,7 @@ export interface ImportSource {
789
790
  }
790
791
 
791
792
  /**
792
- * An item in an imported book's binder. `id` is only for other items in the import to refer to it, such as a
793
+ * An item in an imported book's navigator. `id` is only for other items in the import to refer to it, such as a
793
794
  * scene's cast or a beat's scene. The app assigns its own id. API 7.
794
795
  */
795
796
  export interface ImportedItem {
@@ -863,6 +864,39 @@ export interface ImportedBook {
863
864
  beats?: { storyline: string; scene?: string; title: string; description?: string }[]
864
865
  /** Kinds of entry, as you'd give them to defineKind (API 12). Items use them with `type: 'entry'` and `kind`. */
865
866
  kinds?: KindDefinition[]
867
+ /** In a series: the book's id in the import, for the series' storylines to refer to it (API 13). */
868
+ id?: string
869
+ /**
870
+ * In a series: the shared characters and places this book has a sheet for, by their ids in the series, besides
871
+ * those its scenes name in `cast` and `place` (API 13).
872
+ */
873
+ shared?: string[]
874
+ }
875
+
876
+ /**
877
+ * What a book importer returns for a file that holds several books, such as a Plottr file of a series (API 13).
878
+ * Bläck Studio makes it a new project with one book for each of `books`, in order. The writer can't add it to the
879
+ * open book.
880
+ *
881
+ * - `characters` and `places` are shared in the series bible. Each book gets a sheet, linked to the bible, for every
882
+ * one its scenes name in `cast` and `place`, and for those its `shared` list names. A book's own `characters` and
883
+ * `places` stay in that book.
884
+ * - `storylines` run through the series. `beats` says what each one does in each book, by the book's `id`.
885
+ * - `notes` are the series' notes, as plain text.
886
+ *
887
+ * Only Bläck Studio with API 13 or later reads it. Check `app.apiVersion`, and return an ImportedBook to an older
888
+ * version.
889
+ */
890
+ export interface ImportedSeries {
891
+ title: string
892
+ author?: string
893
+ /** A summary of what was imported, shown in the dialog before the writer chooses. */
894
+ about?: string
895
+ books: ImportedBook[]
896
+ characters?: ImportedItem[]
897
+ places?: ImportedItem[]
898
+ storylines?: { name: string; color?: string; beats?: Record<string, string> }[]
899
+ notes?: { title: string; text: string }[]
866
900
  }
867
901
 
868
902
  export declare class Plugin {
@@ -954,7 +988,7 @@ export declare class Plugin {
954
988
  refreshHighlights(): void
955
989
  /** Adds TipTap extensions to every editor. Window only. */
956
990
  registerEditorExtension(extension: AnyExtension | AnyExtension[]): () => void
957
- /** Adds a panel to the sidebar, beside the binder. Window only. */
991
+ /** Adds a panel to the sidebar, beside the navigator. Window only. */
958
992
  addSidebarPanel(panel: { id: string; name: string; render: () => ReactNode }): () => void
959
993
  /** Adds a button to the editor's toolbar. In a sandboxed plugin, the icon is text, such as an emoji. */
960
994
  addToolbarButton(button: {
@@ -994,6 +1028,8 @@ export declare class Plugin {
994
1028
  * The app asks for the file or folder, passes it to `import`, and shows the writer the result. The writer can
995
1029
  * then make it a new book or add it to the open one. To explain why a file can't be read, throw an Error: the
996
1030
  * writer sees its message. This needs no permission, because it reads only what the writer picked. API 7.
1031
+ *
1032
+ * For a file of several books, `import` can return an ImportedSeries instead, which becomes a new series (API 13).
997
1033
  */
998
1034
  addBookImporter(importer: {
999
1035
  id: string
@@ -1005,7 +1041,7 @@ export declare class Plugin {
1005
1041
  extensions: string[]
1006
1042
  /** True if it reads a folder (a .scriv), not a file. Phones can't choose folders, so the writer chooses a zip of it. */
1007
1043
  folder?: boolean
1008
- import: (source: ImportSource) => ImportedBook | Promise<ImportedBook>
1044
+ import: (source: ImportSource) => ImportedBook | ImportedSeries | Promise<ImportedBook | ImportedSeries>
1009
1045
  }): () => void
1010
1046
  /**
1011
1047
  * Adds a card to the welcome screen's dashboard, shown while no book is open. `size` is 'half' (the default) or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@black-studio/plugin",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
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/",