bible-note 0.4.7 → 0.6.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.
@@ -1,11 +1,30 @@
1
1
  import type { ReactNode } from 'react';
2
+ /** A host-supplied button in the editor's footer. */
2
3
  export type BibleNoteFooterActionButton = {
4
+ /** Unique per editor; adding a button with an existing id replaces it in place. */
3
5
  id: string;
6
+ /**
7
+ * What the button does. Used as the button's tooltip when the button element
8
+ * has no `title` of its own.
9
+ */
4
10
  description?: string;
11
+ /**
12
+ * A keyboard shortcut that clicks the button from anywhere in the page,
13
+ * written as modifiers plus one key joined by `+`: `"Ctrl+Shift+K"`,
14
+ * `"Cmd+Shift+K"`, `"Alt+Shift+K"` (`Ctrl`/`Control`, `Cmd`/`Command`/`Meta`,
15
+ * `Alt`/`Option`, `Shift`). It is appended to the tooltip and set as
16
+ * `aria-keyshortcuts`.
17
+ */
5
18
  shortcutKey?: string;
19
+ /**
20
+ * The button itself, normally a single `<button>`. When it is a single plain
21
+ * element, the editor adds the tooltip and `aria-keyshortcuts` to it.
22
+ */
6
23
  children: ReactNode;
7
24
  };
25
+ /** Which side of the built-in footer buttons a host button sits on. */
8
26
  export type BibleNoteFooterActionButtonPlacement = 'before' | 'after';
27
+ /** The host footer buttons on each side of the built-in ones, in order. */
9
28
  export type BibleNoteFooterActionButtons = Readonly<{
10
29
  before: ReadonlyArray<BibleNoteFooterActionButton>;
11
30
  after: ReadonlyArray<BibleNoteFooterActionButton>;
package/types/lib.d.ts CHANGED
@@ -13,6 +13,7 @@ export { EDITOR_STATE_LOCAL_STORAGE_KEY } from './editorStateStorage';
13
13
  export { applyBibleNoteColorScheme, clearBibleNoteColorScheme, } from './params/colorScheme';
14
14
  export { BIBLE_NOTE_STORAGE_MANAGER_KEYS, createBrowserStorageManager, } from './storageManager';
15
15
  export { getLookupRecordValues, getMentionKjvName, LocationsLookupManager, NamesLookupManager, normalizeMentionNameType, parseMentionLocationMatch, parseMentionLocationMatches, parseMentionNameMatch, parseMentionNameMatches, } from './LookupManager';
16
+ export type { BibleNoteFloatingActionButton, BibleNoteFloatingActionButtonClickEvent, BibleNoteFloatingActionButtons, BibleNoteSelectionPoint, BibleNoteTextSelection, } from './floatingActionButtons';
16
17
  export type { BibleNoteFooterActionButton, BibleNoteFooterActionButtonPlacement, BibleNoteFooterActionButtons, } from './footerActionButtons';
17
18
  export type { BibleNoteProps, BibleNoteRenderOptions, } from './bibleNoteHelpers';
18
19
  export type { LocationsLookupManagerDataMap, LocationsLookupManagerLangData, LookupManagerStyle, LookupPaginationOptions, LookupPaginationResult, LookupSearchOptions, MentionLocationCoordinates, MentionLocationLink, MentionLocationMatch, MentionLocationPreview, MentionNameLink, MentionNameMatch, MentionNamePreview, MentionNameType, MentionNameYearRange, NamesLookupManagerDataMap, NamesLookupManagerLangData, NamesLookupPaginationOptions, NamesLookupSearchOptions, NameTypeCount, VerseRecordIdsMap, } from './LookupManager';
@@ -21,17 +21,28 @@ export type MentionNameType = 'person' | 'concept' | 'place' | 'group' | 'deity'
21
21
  * used for untyped name records.
22
22
  */
23
23
  export declare function normalizeMentionNameType(type: string | null | undefined): MentionNameType;
24
+ /** A dated span in a person's life, e.g. a reign. */
24
25
  export type MentionNameYearRange = {
26
+ /** What the span is, e.g. `reign` or `coregency`. */
25
27
  type: string;
26
28
  start: number;
27
29
  end: number;
28
30
  };
31
+ /** An external reference about a record. */
29
32
  export type MentionNameLink = {
33
+ /** The source, e.g. `wikipedia`, `easton`, `newadvent`. */
30
34
  type: string;
31
35
  url: string;
32
36
  };
37
+ /**
38
+ * One person/name record — what `NamesLookupManager` searches and returns, and
39
+ * what an `@` mention shows. Fields holding other records (`parents`,
40
+ * `locations`, …) hold their ids; resolve them with `getRecordsByIds`.
41
+ */
33
42
  export type MentionNameMatch = {
43
+ /** Stable record id; mentions in saved notes refer to it. */
34
44
  id: string;
45
+ /** The name as printed in this dataset's Bible text. */
35
46
  name: string;
36
47
  /**
37
48
  * The KJV English name, carried only by translated datasets (the km-BFBS
@@ -43,53 +54,112 @@ export type MentionNameMatch = {
43
54
  * translated name the way a Bible book reads "លោកុប្បត្តិ (Genesis)".
44
55
  */
45
56
  kjvName: string | null;
57
+ /** A former name (e.g. Abram for Abraham), searchable like `name`; `null` when none. */
46
58
  oldName: string | null;
59
+ /**
60
+ * A one-line identification ("prophet who led Israel out of Egypt"). Like
61
+ * `description`, it may carry inline reference links:
62
+ * `[Egypt](location-id://…)`, `[Amram](name-id://…)`,
63
+ * `[Genesis 1:1](verse-key://GEN 1:1)`, `[Genesis](book-key://GEN)`,
64
+ * `[Genesis 14](chapter-key://GEN 14)`.
65
+ */
47
66
  title: string;
67
+ /** A paragraph about the person, with the same inline links as `title`. */
48
68
  description: string;
69
+ /** `male`, `female` or `unknown` in the generated datasets; `''` when absent. */
49
70
  gender: string;
71
+ /** Age as stated in the text (e.g. `120 years`); `''` when unknown. */
50
72
  age: string;
73
+ /** Dated spans such as a king's reign; usually empty. */
51
74
  years: Array<MentionNameYearRange>;
75
+ /** Ids of location records tied to the person. */
52
76
  locations: Array<string>;
77
+ /** Ids of name records. */
53
78
  spouses: Array<string>;
79
+ /** Ids of name records. */
54
80
  children: Array<string>;
81
+ /** Ids of name records. */
55
82
  parents: Array<string>;
83
+ /** Ids of name records. */
56
84
  siblings: Array<string>;
85
+ /** Ids of name records. */
57
86
  cousin: Array<string>;
87
+ /** The raw type; `normalizeMentionNameType` maps it to a {@link MentionNameType}. */
58
88
  type: string;
89
+ /**
90
+ * Short verse keys where the Bible prints the name, e.g. `GEN 1:1` or a
91
+ * collapsed range `1SA 17:1-4` (so the array length is not a verse count).
92
+ */
59
93
  verses: Array<string>;
94
+ /** External references (Wikipedia, Easton's, New Advent…). */
60
95
  links: Array<MentionNameLink>;
96
+ /** The record's Wikipedia URL, or `null`. */
61
97
  wikipedia: string | null;
98
+ /**
99
+ * How much the record matters, ascending: 0 is the most important on this
100
+ * dataset's scale. Orders every listing and breaks ties in search. Records
101
+ * without a rank get `Infinity` and sort to the very end.
102
+ */
62
103
  matterRange: number;
63
104
  };
105
+ /**
106
+ * A name record as the mention UI displays it: the dataset record, or a
107
+ * fallback built from what a mention in the note carries when the dataset has
108
+ * no such record. `id` is `null` when the mention has no record id.
109
+ */
64
110
  export type MentionNamePreview = Omit<MentionNameMatch, 'id'> & {
65
111
  id: string | null;
66
112
  };
113
+ /** WGS 84 decimal degrees. */
67
114
  export type MentionLocationCoordinates = {
68
115
  latitude: number;
69
116
  longitude: number;
70
117
  };
118
+ /** An external reference about a location; same shape as {@link MentionNameLink}. */
71
119
  export type MentionLocationLink = {
72
120
  type: string;
73
121
  url: string;
74
122
  };
123
+ /**
124
+ * One place/location record — what `LocationsLookupManager` searches and
125
+ * returns, and what a `#` mention shows.
126
+ */
75
127
  export type MentionLocationMatch = {
128
+ /** Stable record id; mentions in saved notes refer to it. */
76
129
  id: string;
130
+ /** The name as printed in this dataset's Bible text. */
77
131
  name: string;
78
132
  /** The KJV English name; see {@link MentionNameMatch.kjvName}. */
79
133
  kjvName: string | null;
134
+ /** A former name, searchable like `name`; `null` when none. */
80
135
  oldName: string | null;
136
+ /** A one-line identification, with inline reference links like {@link MentionNameMatch.title}. */
81
137
  title: string;
138
+ /** A paragraph about the place, with the same inline links. */
82
139
  description: string;
140
+ /** The kind of place, e.g. `city`, `region`, `mountain`. */
83
141
  type: string;
142
+ /** Ids of other location records. */
84
143
  relatedLocations: Array<string>;
144
+ /** The modern site or name, when known. */
85
145
  modernIdentification: string | null;
86
146
  coordinates: MentionLocationCoordinates | null;
147
+ /** Short verse keys where the Bible prints the name; ranges are collapsed. */
87
148
  verses: Array<string>;
149
+ /** External references (Wikipedia, Easton's, New Advent…). */
88
150
  links: Array<MentionLocationLink>;
151
+ /** The record's Wikipedia URL, or `null`. */
89
152
  wikipedia: string | null;
153
+ /** `true` when the identification or location is uncertain. */
90
154
  uncertainty: boolean;
155
+ /** Importance rank on the same scale as {@link MentionNameMatch.matterRange}. */
91
156
  matterRange: number;
92
157
  };
158
+ /**
159
+ * A location record as the mention UI displays it: the dataset record, or a
160
+ * fallback built from what a mention in the note carries. `id` is `null` when
161
+ * the mention has no record id.
162
+ */
93
163
  export type MentionLocationPreview = Omit<MentionLocationMatch, 'id'> & {
94
164
  id: string | null;
95
165
  };
@@ -106,6 +176,10 @@ export declare function getMentionKjvName(record: {
106
176
  export declare function getTrimmedString(value: unknown): string;
107
177
  export declare function getNullableTrimmedString(value: unknown): string | null;
108
178
  export declare function getTrimmedStringArray(value: unknown): Array<string>;
179
+ /**
180
+ * The records of a raw dataset collection, whether it is an id-keyed object or
181
+ * a plain array; `[]` for anything else.
182
+ */
109
183
  export declare function getLookupRecordValues(value: unknown): Array<unknown>;
110
184
  /**
111
185
  * Normalizes one raw dataset entry into a {@link MentionNameMatch}, or returns
@@ -1,6 +1,16 @@
1
1
  import type { JSX } from 'react';
2
2
  import type { BibleNoteColorScheme } from './colorScheme';
3
+ /** Props of `BibleNoteSettings`. */
3
4
  export type BibleNoteSettingsProps = {
5
+ /**
6
+ * Called when the Dark Mode switch flips. Pass
7
+ * `(mode) => bibleNote.setColorScheme(mode)` so the instance stays in step.
8
+ */
4
9
  setColorScheme: (mode: BibleNoteColorScheme) => void;
5
10
  };
11
+ /**
12
+ * The editor's settings panel — a gear button that opens the switches (Dark
13
+ * Mode, Table Of Contents, …). Pass it to `render` as `options.settings`;
14
+ * settings persist through the storage manager.
15
+ */
6
16
  export default function BibleNoteSettings({ setColorScheme, }: BibleNoteSettingsProps): JSX.Element;
@@ -1,3 +1,11 @@
1
+ /** The editor's two colour schemes. */
1
2
  export type BibleNoteColorScheme = 'dark' | 'light';
3
+ /**
4
+ * Applies a colour scheme to `body` (default `document.body`): toggles the
5
+ * `playground-theme-dark` / `playground-theme-light` classes and sets
6
+ * `data-bs-theme`, so Bootstrap's own components follow. Prefer
7
+ * `BibleNote#setColorScheme` on a mounted editor; this is the bare DOM step.
8
+ */
2
9
  export declare function applyBibleNoteColorScheme(mode: BibleNoteColorScheme, body?: HTMLElement): void;
10
+ /** Removes the theme classes `applyBibleNoteColorScheme` added (leaves `data-bs-theme`). */
3
11
  export declare function clearBibleNoteColorScheme(body?: HTMLElement): void;
@@ -1,12 +1,32 @@
1
+ /**
2
+ * Where the editor keeps its own state — settings, comments, read-only mode,
3
+ * zoom, panel state — as string values under the keys in
4
+ * `BIBLE_NOTE_STORAGE_MANAGER_KEYS`. The note itself goes through
5
+ * `loadData` / `saveData` instead. Every key is read once, before the editor
6
+ * first renders; writes are fire-and-forget.
7
+ */
1
8
  export type BibleNoteStorageManager = {
9
+ /** Stores `value` (a string, or a value to `JSON.stringify`) under `key`. */
2
10
  setSetting(key: string, value: unknown): Promise<void>;
11
+ /** The value stored under `key`, or `null` when there is none. */
3
12
  getSetting<T = unknown>(key: string): Promise<T | null>;
13
+ /** Removes `key`. */
4
14
  deleteSetting(key: string): Promise<void>;
5
15
  };
6
16
  type BibleNoteStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
17
+ /**
18
+ * Every key the editor reads from its storage manager before it renders. A
19
+ * host-side store that needs to know its keys up front (to prefetch or migrate
20
+ * them) can use this list.
21
+ */
7
22
  export declare const BIBLE_NOTE_STORAGE_MANAGER_KEYS: readonly ["lexical-playground-settings", "lexical-playground-editor-state", "lexical-playground-comments", "lexical-playground-comments-panel-open", "lexical-playground-block-text-links", "lexical-playground-read-only-mode", "lexical-playground-insert-character-picker", "lexical-playground-editor-zoom-percent"];
8
23
  export declare function configureBibleNoteStorageManager(storageManager?: BibleNoteStorageManager): void;
9
24
  export declare function hydrateBibleNoteStorageManager(keys: ReadonlyArray<string>): Promise<void>;
10
25
  export declare function getBibleNoteStorage(): BibleNoteStorage | null;
26
+ /**
27
+ * A `BibleNoteStorageManager` backed by `window.localStorage`. Non-string
28
+ * values are stored as JSON; when `localStorage` is unavailable every call is
29
+ * a no-op.
30
+ */
11
31
  export declare function createBrowserStorageManager(): BibleNoteStorageManager;
12
32
  export {};
@@ -1,8 +1,15 @@
1
+ /** How a media file reached the editor: dropped/pasted, or picked in the media dialog. */
1
2
  export type FilePathSource = 'drop' | 'file-input';
3
+ /** Context passed to a `FilePathResolver`. */
2
4
  export type FilePathResolverContext = Readonly<{
3
5
  source: FilePathSource;
4
6
  }>;
7
+ /**
8
+ * Maps a media file to the path or URL the note should reference. Return
9
+ * `null` (or throw) to let the editor embed the file as a data URL instead.
10
+ */
5
11
  export type FilePathResolver = (file: File, context: FilePathResolverContext) => Promise<string | null> | string | null;
12
+ /** Shows a local media file to the user, e.g. in the system file manager. */
6
13
  export type FileRevealer = (filePath: string) => Promise<void> | void;
7
14
  export declare function getFallbackFilePath(file: File): string;
8
15
  export declare function resolveMediaFilePath(resolver: FilePathResolver | undefined, file: File, source: FilePathSource): Promise<string | null>;
@@ -5,11 +5,17 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
+ /** A font in the toolbar's font menu: `[fontFamily, label, languageCode]`. */
8
9
  export type FontFamilyOption = readonly [
9
10
  fontFamily: string,
10
11
  label: string,
11
12
  language: string
12
13
  ];
14
+ /**
15
+ * A host font added to the editor: `[fontFamily, languageCode]`, e.g.
16
+ * `['Battambang', 'km']`. The language code is what `getLangCode` returns
17
+ * for text that should use this font.
18
+ */
13
19
  export type ExtraFontFamilyOption = readonly [
14
20
  fontFamily: string,
15
21
  language: string