@black-studio/plugin 1.2.0 → 1.3.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 +11 -0
  2. package/index.d.ts +38 -3
  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
@@ -789,7 +789,7 @@ export interface ImportSource {
789
789
  }
790
790
 
791
791
  /**
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
792
+ * 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
793
  * scene's cast or a beat's scene. The app assigns its own id. API 7.
794
794
  */
795
795
  export interface ImportedItem {
@@ -863,6 +863,39 @@ export interface ImportedBook {
863
863
  beats?: { storyline: string; scene?: string; title: string; description?: string }[]
864
864
  /** Kinds of entry, as you'd give them to defineKind (API 12). Items use them with `type: 'entry'` and `kind`. */
865
865
  kinds?: KindDefinition[]
866
+ /** In a series: the book's id in the import, for the series' storylines to refer to it (API 13). */
867
+ id?: string
868
+ /**
869
+ * In a series: the shared characters and places this book has a sheet for, by their ids in the series, besides
870
+ * those its scenes name in `cast` and `place` (API 13).
871
+ */
872
+ shared?: string[]
873
+ }
874
+
875
+ /**
876
+ * What a book importer returns for a file that holds several books, such as a Plottr file of a series (API 13).
877
+ * 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
878
+ * open book.
879
+ *
880
+ * - `characters` and `places` are shared in the series bible. Each book gets a sheet, linked to the bible, for every
881
+ * one its scenes name in `cast` and `place`, and for those its `shared` list names. A book's own `characters` and
882
+ * `places` stay in that book.
883
+ * - `storylines` run through the series. `beats` says what each one does in each book, by the book's `id`.
884
+ * - `notes` are the series' notes, as plain text.
885
+ *
886
+ * Only Bläck Studio with API 13 or later reads it. Check `app.apiVersion`, and return an ImportedBook to an older
887
+ * version.
888
+ */
889
+ export interface ImportedSeries {
890
+ title: string
891
+ author?: string
892
+ /** A summary of what was imported, shown in the dialog before the writer chooses. */
893
+ about?: string
894
+ books: ImportedBook[]
895
+ characters?: ImportedItem[]
896
+ places?: ImportedItem[]
897
+ storylines?: { name: string; color?: string; beats?: Record<string, string> }[]
898
+ notes?: { title: string; text: string }[]
866
899
  }
867
900
 
868
901
  export declare class Plugin {
@@ -954,7 +987,7 @@ export declare class Plugin {
954
987
  refreshHighlights(): void
955
988
  /** Adds TipTap extensions to every editor. Window only. */
956
989
  registerEditorExtension(extension: AnyExtension | AnyExtension[]): () => void
957
- /** Adds a panel to the sidebar, beside the binder. Window only. */
990
+ /** Adds a panel to the sidebar, beside the navigator. Window only. */
958
991
  addSidebarPanel(panel: { id: string; name: string; render: () => ReactNode }): () => void
959
992
  /** Adds a button to the editor's toolbar. In a sandboxed plugin, the icon is text, such as an emoji. */
960
993
  addToolbarButton(button: {
@@ -994,6 +1027,8 @@ export declare class Plugin {
994
1027
  * The app asks for the file or folder, passes it to `import`, and shows the writer the result. The writer can
995
1028
  * 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
1029
  * writer sees its message. This needs no permission, because it reads only what the writer picked. API 7.
1030
+ *
1031
+ * For a file of several books, `import` can return an ImportedSeries instead, which becomes a new series (API 13).
997
1032
  */
998
1033
  addBookImporter(importer: {
999
1034
  id: string
@@ -1005,7 +1040,7 @@ export declare class Plugin {
1005
1040
  extensions: string[]
1006
1041
  /** 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
1042
  folder?: boolean
1008
- import: (source: ImportSource) => ImportedBook | Promise<ImportedBook>
1043
+ import: (source: ImportSource) => ImportedBook | ImportedSeries | Promise<ImportedBook | ImportedSeries>
1009
1044
  }): () => void
1010
1045
  /**
1011
1046
  * 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.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/",