bible-note 0.4.4 → 0.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.
- package/README.md +45 -5
- package/knowledge/development.md +1927 -0
- package/knowledge/ui-rag.md +2130 -0
- package/package.json +14 -2
- package/types/BibleNote.d.ts +62 -0
- package/types/LookupManager.d.ts +71 -0
- package/types/bibleNoteHelpers.d.ts +105 -0
- package/types/editorStateStorage.d.ts +5 -0
- package/types/footerActionButtons.d.ts +19 -0
- package/types/lookupTypes.d.ts +74 -0
- package/types/params/BibleNoteSettings.d.ts +10 -0
- package/types/params/colorScheme.d.ts +8 -0
- package/types/storageManager.d.ts +20 -0
- package/types/utils/filePathResolver.d.ts +7 -0
- package/types/utils/fontFamilyOptions.d.ts +6 -0
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bible-note",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A Bible study tool for taking notes and organizing your thoughts.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"author": "raksa <eng.raksa@gmail.com>",
|
|
7
|
+
"homepage": "https://github.com/raksa/bible-note-dist#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/raksa/bible-note-dist.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/raksa/bible-note-dist/issues"
|
|
14
|
+
},
|
|
6
15
|
"type": "module",
|
|
7
16
|
"main": "./dist/bible-note.cjs",
|
|
8
17
|
"module": "./dist/bible-note.mjs",
|
|
@@ -14,11 +23,14 @@
|
|
|
14
23
|
"require": "./dist/bible-note.cjs"
|
|
15
24
|
},
|
|
16
25
|
"./styles.css": "./dist/bible-note.css",
|
|
26
|
+
"./knowledge/development.md": "./knowledge/development.md",
|
|
27
|
+
"./knowledge/ui-rag.md": "./knowledge/ui-rag.md",
|
|
17
28
|
"./package.json": "./package.json"
|
|
18
29
|
},
|
|
19
30
|
"files": [
|
|
20
31
|
"dist",
|
|
21
32
|
"types",
|
|
33
|
+
"knowledge",
|
|
22
34
|
"README.md",
|
|
23
35
|
"LICENSE"
|
|
24
36
|
],
|
|
@@ -41,4 +53,4 @@
|
|
|
41
53
|
"react",
|
|
42
54
|
"notes"
|
|
43
55
|
]
|
|
44
|
-
}
|
|
56
|
+
}
|
package/types/BibleNote.d.ts
CHANGED
|
@@ -2,9 +2,23 @@ import type { BibleNoteFooterActionButton } from './footerActionButtons';
|
|
|
2
2
|
import type { BibleNoteColorScheme } from './params/colorScheme';
|
|
3
3
|
import { type BibleNoteProps, type BibleNoteRenderOptions } from './bibleNoteHelpers';
|
|
4
4
|
export type { BibleNoteFooterActionButton, BibleNoteFooterActionButtons, } from './footerActionButtons';
|
|
5
|
+
/**
|
|
6
|
+
* The BibleNote editor. Construct it with the host's datasets and storage
|
|
7
|
+
* callbacks, then {@link BibleNote.render | render} it into an element.
|
|
8
|
+
*
|
|
9
|
+
* Every editor-backed method (`content`, `addText`, `searchText`, …) can be
|
|
10
|
+
* called before `render`: writes are queued and applied once the editor has
|
|
11
|
+
* mounted, and reads return an empty value until then.
|
|
12
|
+
*/
|
|
5
13
|
declare class BibleNote {
|
|
14
|
+
/** The package version this bundle was built from. */
|
|
6
15
|
static VERSION: string;
|
|
16
|
+
/** The props the instance was constructed with. */
|
|
7
17
|
props: Readonly<BibleNoteProps>;
|
|
18
|
+
/**
|
|
19
|
+
* The colour scheme last applied — by {@link BibleNote.setColorScheme} or the
|
|
20
|
+
* settings panel's Dark Mode switch. Read it; change it with `setColorScheme`.
|
|
21
|
+
*/
|
|
8
22
|
colorScheme: BibleNoteColorScheme;
|
|
9
23
|
private editorController;
|
|
10
24
|
private pendingEditorActions;
|
|
@@ -18,17 +32,56 @@ declare class BibleNote {
|
|
|
18
32
|
private readonly footerActionButtonControllerOwner;
|
|
19
33
|
private readonly storageManager;
|
|
20
34
|
private readonly settingsControllerOwner;
|
|
35
|
+
/** Creates the editor; nothing is rendered until `render` is called. */
|
|
21
36
|
constructor(props: BibleNoteProps);
|
|
37
|
+
/**
|
|
38
|
+
* The note as a serialized Lexical editor state (a JSON string) — the same
|
|
39
|
+
* string `saveData` receives. Reads `''` until the editor has mounted.
|
|
40
|
+
* Assigning replaces the whole document; assigning `''` clears it.
|
|
41
|
+
*/
|
|
22
42
|
get content(): string;
|
|
23
43
|
set content(value: string);
|
|
44
|
+
/**
|
|
45
|
+
* Whether the note is locked against editing. Assigning `true` forces
|
|
46
|
+
* read-only mode: the footer's lock turns into **Read-Only Mode Locked** and
|
|
47
|
+
* the user cannot unlock it. Assigning `false` releases that lock and makes
|
|
48
|
+
* the note editable.
|
|
49
|
+
*/
|
|
24
50
|
get isReadOnly(): boolean;
|
|
25
51
|
set isReadOnly(value: boolean);
|
|
52
|
+
/**
|
|
53
|
+
* Whether the caret is in the editor right now: the window has focus, the
|
|
54
|
+
* editor is the active element, and the selection is a collapsed caret inside
|
|
55
|
+
* it. A host can use this to decide whether to send text to `addText`.
|
|
56
|
+
*/
|
|
26
57
|
getIsFocusing(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Switches the editor between light and dark. Applies the body classes at
|
|
60
|
+
* once (see `applyBibleNoteColorScheme`) and keeps the settings panel's Dark
|
|
61
|
+
* Mode switch in step.
|
|
62
|
+
*/
|
|
27
63
|
setColorScheme(mode: BibleNoteColorScheme): void;
|
|
64
|
+
/**
|
|
65
|
+
* Inserts text at the caret, or at the end of the note when there is no
|
|
66
|
+
* selection, exactly as if the user had pasted it as plain text — so the
|
|
67
|
+
* paste rules apply: Bible text pasted right after a `^` becomes a verse
|
|
68
|
+
* mention. Ignored while the note is read-only or when `text` is empty.
|
|
69
|
+
*/
|
|
28
70
|
addText(text: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* Adds a host button after the footer's built-in buttons. A button whose `id`
|
|
73
|
+
* is already present is replaced in place, keeping its position.
|
|
74
|
+
*/
|
|
29
75
|
appendFooterActionButton(actionButton: BibleNoteFooterActionButton): void;
|
|
76
|
+
/**
|
|
77
|
+
* Adds a host button before the footer's built-in buttons, ahead of any
|
|
78
|
+
* prepended earlier. A button whose `id` is already present is replaced in
|
|
79
|
+
* place, keeping its position.
|
|
80
|
+
*/
|
|
30
81
|
prependFooterActionButton(actionButton: BibleNoteFooterActionButton): void;
|
|
82
|
+
/** The host footer button with this `id`, or `null`. */
|
|
31
83
|
getFooterActionButton(id: string): BibleNoteFooterActionButton | null;
|
|
84
|
+
/** Removes the host footer button with this `id`; `false` when there was none. */
|
|
32
85
|
removeFooterActionButton(id: string): boolean;
|
|
33
86
|
private setFooterActionButton;
|
|
34
87
|
private getFooterActionButtonsSnapshot;
|
|
@@ -44,7 +97,16 @@ declare class BibleNote {
|
|
|
44
97
|
* like the other editor-backed methods.
|
|
45
98
|
*/
|
|
46
99
|
searchText(query: string | null): void;
|
|
100
|
+
/**
|
|
101
|
+
* Mounts the editor into `containerElement` with its own React root.
|
|
102
|
+
* Rendering again unmounts the previous root first, so an instance is only
|
|
103
|
+
* ever mounted once.
|
|
104
|
+
*/
|
|
47
105
|
render(containerElement: HTMLElement, options?: BibleNoteRenderOptions): void;
|
|
106
|
+
/**
|
|
107
|
+
* Unmounts the editor. The instance keeps its props and footer buttons and
|
|
108
|
+
* can be rendered again.
|
|
109
|
+
*/
|
|
48
110
|
unmount(): void;
|
|
49
111
|
/**
|
|
50
112
|
* Every short verse reference (`GEN 1:1`) the given note content mentions, in
|
package/types/LookupManager.d.ts
CHANGED
|
@@ -16,47 +16,72 @@ export { getLookupRecordValues, getMentionKjvName, normalizeMentionNameType, par
|
|
|
16
16
|
* font does not cover; anything a `style` attribute accepts works.
|
|
17
17
|
*/
|
|
18
18
|
export type LookupManagerStyle = CSSProperties;
|
|
19
|
+
/** Options for `searchNames` / `searchLocations`. */
|
|
19
20
|
export type LookupSearchOptions = {
|
|
21
|
+
/** Language to search; falls back to `defaultLang` when absent or unknown. */
|
|
20
22
|
lang?: string;
|
|
23
|
+
/** Maximum number of results; all matches when omitted. */
|
|
21
24
|
limit?: number;
|
|
22
25
|
};
|
|
26
|
+
/** Options for the `…Pagination` searches. */
|
|
23
27
|
export type LookupPaginationOptions = {
|
|
28
|
+
/** Search text; empty or omitted lists every record in importance order. */
|
|
24
29
|
query?: string;
|
|
30
|
+
/** Language to search; falls back to `defaultLang` when absent or unknown. */
|
|
25
31
|
lang?: string;
|
|
32
|
+
/** 1-based page number, clamped to the available pages. Defaults to 1. */
|
|
26
33
|
page?: number;
|
|
34
|
+
/** Records per page (at least 1). Defaults to 20. */
|
|
27
35
|
pageSize?: number;
|
|
28
36
|
};
|
|
37
|
+
/** One page of search results. */
|
|
29
38
|
export type LookupPaginationResult<TRecord> = {
|
|
39
|
+
/** The language actually searched. */
|
|
30
40
|
lang: string;
|
|
41
|
+
/** Matches across all pages. */
|
|
31
42
|
totalRecords: number;
|
|
43
|
+
/** The page returned, after clamping. */
|
|
32
44
|
page: number;
|
|
45
|
+
/** Number of pages; at least 1, even with no matches. */
|
|
33
46
|
totalPages: number;
|
|
34
47
|
pageSize: number;
|
|
48
|
+
/** This page's records. */
|
|
35
49
|
records: Array<TRecord>;
|
|
36
50
|
};
|
|
51
|
+
/** `LookupSearchOptions` plus a name-type filter. */
|
|
37
52
|
export type NamesLookupSearchOptions = LookupSearchOptions & {
|
|
53
|
+
/** Only records of this type; applied before `limit`. */
|
|
38
54
|
type?: MentionNameType;
|
|
39
55
|
};
|
|
56
|
+
/** `LookupPaginationOptions` plus a name-type filter. */
|
|
40
57
|
export type NamesLookupPaginationOptions = LookupPaginationOptions & {
|
|
58
|
+
/** Only records of this type. */
|
|
41
59
|
type?: MentionNameType;
|
|
42
60
|
};
|
|
61
|
+
/** How many records of one name type a dataset holds. */
|
|
43
62
|
export type NameTypeCount = {
|
|
44
63
|
type: MentionNameType;
|
|
45
64
|
count: number;
|
|
46
65
|
};
|
|
66
|
+
/** One language's name dataset, as `NamesLookupManager`'s constructor takes it. */
|
|
47
67
|
export type NamesLookupManagerLangData = {
|
|
68
|
+
/** The normalized records (see `parseMentionNameMatches`). */
|
|
48
69
|
records: ReadonlyArray<MentionNameMatch>;
|
|
49
70
|
/** Short verse key (e.g. `"EXO 6:23"`) to the ids of the names it mentions. */
|
|
50
71
|
versePersonsMap?: VerseRecordIdsMap;
|
|
51
72
|
};
|
|
73
|
+
/** Name datasets keyed by language code, e.g. `{ en: …, km: … }`. */
|
|
52
74
|
export type NamesLookupManagerDataMap = {
|
|
53
75
|
[langCode: string]: NamesLookupManagerLangData;
|
|
54
76
|
};
|
|
77
|
+
/** One language's location dataset, as `LocationsLookupManager`'s constructor takes it. */
|
|
55
78
|
export type LocationsLookupManagerLangData = {
|
|
79
|
+
/** The normalized records (see `parseMentionLocationMatches`). */
|
|
56
80
|
records: ReadonlyArray<MentionLocationMatch>;
|
|
57
81
|
/** Short verse key (e.g. `"EXO 6:23"`) to the ids of the locations it mentions. */
|
|
58
82
|
verseLocationsMap?: VerseRecordIdsMap;
|
|
59
83
|
};
|
|
84
|
+
/** Location datasets keyed by language code, e.g. `{ en: …, km: … }`. */
|
|
60
85
|
export type LocationsLookupManagerDataMap = {
|
|
61
86
|
[langCode: string]: LocationsLookupManagerLangData;
|
|
62
87
|
};
|
|
@@ -103,14 +128,24 @@ declare abstract class LookupManager<TRecord extends LookupRecordLike, TLangData
|
|
|
103
128
|
*/
|
|
104
129
|
get style(): LookupManagerStyle | undefined;
|
|
105
130
|
set style(style: LookupManagerStyle | undefined);
|
|
131
|
+
/**
|
|
132
|
+
* The language used when a call names none (or names one this manager does
|
|
133
|
+
* not hold). Assigning a language the data map lacks throws.
|
|
134
|
+
*/
|
|
106
135
|
get defaultLang(): string;
|
|
107
136
|
set defaultLang(lang: string);
|
|
137
|
+
/** The language codes this manager holds data for. */
|
|
108
138
|
get langs(): ReadonlyArray<string>;
|
|
109
139
|
/** Total number of records in a language, ignoring any query. */
|
|
110
140
|
getRecordCount(lang?: string): number;
|
|
111
141
|
/** Every record in a language, in importance order. */
|
|
112
142
|
getAllRecords(lang?: string): Array<TRecord>;
|
|
143
|
+
/** The record with this id (whitespace-trimmed), or `null`. */
|
|
113
144
|
getRecordById(id: string, lang?: string): TRecord | null;
|
|
145
|
+
/**
|
|
146
|
+
* The records for these ids, in the order given; unknown and repeated ids
|
|
147
|
+
* are skipped.
|
|
148
|
+
*/
|
|
114
149
|
getRecordsByIds(ids: ReadonlyArray<string>, lang?: string): Array<TRecord>;
|
|
115
150
|
/**
|
|
116
151
|
* Every record carrying exactly this name. Names are not unique in the
|
|
@@ -135,8 +170,18 @@ declare abstract class LookupManager<TRecord extends LookupRecordLike, TLangData
|
|
|
135
170
|
protected abstract getVerseRecordIds(langData: TLangData): VerseRecordIdsMap;
|
|
136
171
|
private getRankedMatches;
|
|
137
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Owns the person/name dataset(s): ranked search, id and name lookup,
|
|
175
|
+
* pagination, name-type counts and verse → names lookup. Has no editor
|
|
176
|
+
* dependency, so a host can use it to build its own UI. Indexes are built
|
|
177
|
+
* lazily per language on first use.
|
|
178
|
+
*/
|
|
138
179
|
export declare class NamesLookupManager extends LookupManager<MentionNameMatch, NamesLookupManagerLangData> {
|
|
139
180
|
private readonly nameTypeCounts;
|
|
181
|
+
/**
|
|
182
|
+
* Takes already-normalized records; prefer `fromRawDataset` for the generated
|
|
183
|
+
* dataset files. Throws when `dataMap` has no `defaultLang` entry.
|
|
184
|
+
*/
|
|
140
185
|
constructor(dataMap: NamesLookupManagerDataMap, defaultLang: string, style?: LookupManagerStyle);
|
|
141
186
|
/**
|
|
142
187
|
* Builds a manager straight from the generated dataset files, i.e. whatever
|
|
@@ -155,13 +200,31 @@ export declare class NamesLookupManager extends LookupManager<MentionNameMatch,
|
|
|
155
200
|
getNameTypes(lang?: string): ReadonlyArray<NameTypeCount>;
|
|
156
201
|
/** The name types present in the default language. */
|
|
157
202
|
get nameTypes(): ReadonlyArray<NameTypeCount>;
|
|
203
|
+
/**
|
|
204
|
+
* Names matching `query`. Case-insensitive substring match against the name, the KJV English
|
|
205
|
+
* name (translated datasets) and the former name. Ranked exact, then prefix,
|
|
206
|
+
* then substring — the better of the two names counts — and by importance
|
|
207
|
+
* (`matterRange`, then alphabetical) within a tier. An empty query returns
|
|
208
|
+
* every record in importance order.
|
|
209
|
+
*/
|
|
158
210
|
searchNames(query: string, options?: NamesLookupSearchOptions): Array<MentionNameMatch>;
|
|
211
|
+
/** `searchNames`, one page at a time (20 records per page by default). */
|
|
159
212
|
searchNamesPagination(options?: NamesLookupPaginationOptions): LookupPaginationResult<MentionNameMatch>;
|
|
160
213
|
/** The names a short verse key (e.g. `"EXO 6:23"`) mentions. */
|
|
161
214
|
searchByShortVerse(shortVerse: string, lang?: string): Array<MentionNameMatch>;
|
|
162
215
|
protected getVerseRecordIds(langData: NamesLookupManagerLangData): VerseRecordIdsMap;
|
|
163
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Owns the place/location dataset(s): ranked search, id and name lookup,
|
|
219
|
+
* pagination and verse → locations lookup. Has no editor dependency, so a host
|
|
220
|
+
* can use it to build its own UI. Indexes are built lazily per language on
|
|
221
|
+
* first use.
|
|
222
|
+
*/
|
|
164
223
|
export declare class LocationsLookupManager extends LookupManager<MentionLocationMatch, LocationsLookupManagerLangData> {
|
|
224
|
+
/**
|
|
225
|
+
* Takes already-normalized records; prefer `fromRawDataset` for the generated
|
|
226
|
+
* dataset files. Throws when `dataMap` has no `defaultLang` entry.
|
|
227
|
+
*/
|
|
165
228
|
constructor(dataMap: LocationsLookupManagerDataMap, defaultLang: string, style?: LookupManagerStyle);
|
|
166
229
|
/**
|
|
167
230
|
* Builds a manager straight from the generated dataset files, i.e. whatever
|
|
@@ -174,7 +237,15 @@ export declare class LocationsLookupManager extends LookupManager<MentionLocatio
|
|
|
174
237
|
}, defaultLang: string, style?: LookupManagerStyle): LocationsLookupManager;
|
|
175
238
|
/** An empty manager, used wherever a host has not supplied a dataset yet. */
|
|
176
239
|
static createEmpty(): LocationsLookupManager;
|
|
240
|
+
/**
|
|
241
|
+
* Locations matching `query`. Case-insensitive substring match against the name, the KJV English
|
|
242
|
+
* name (translated datasets) and the former name. Ranked exact, then prefix,
|
|
243
|
+
* then substring — the better of the two names counts — and by importance
|
|
244
|
+
* (`matterRange`, then alphabetical) within a tier. An empty query returns
|
|
245
|
+
* every record in importance order.
|
|
246
|
+
*/
|
|
177
247
|
searchLocations(query: string, options?: LookupSearchOptions): Array<MentionLocationMatch>;
|
|
248
|
+
/** `searchLocations`, one page at a time (20 records per page by default). */
|
|
178
249
|
searchLocationsPagination(options?: LookupPaginationOptions): LookupPaginationResult<MentionLocationMatch>;
|
|
179
250
|
/** The locations a short verse key (e.g. `"EXO 6:23"`) mentions. */
|
|
180
251
|
searchByShortVerse(shortVerse: string, lang?: string): Array<MentionLocationMatch>;
|
|
@@ -12,35 +12,140 @@ export type BibleNoteSettingsController = {
|
|
|
12
12
|
setColorScheme: (mode: BibleNoteColorScheme) => void;
|
|
13
13
|
};
|
|
14
14
|
export type BibleNoteEditorController = Parameters<BibleNoteEditorControllerOwner['connectEditorController']>[0];
|
|
15
|
+
/** A Bible verse as the host renders it: a title line plus the full text. */
|
|
15
16
|
type MentionedBibleDataType = {
|
|
17
|
+
/** The verse reference as displayed, e.g. `(KJV) Genesis 1:1`. */
|
|
16
18
|
title: string;
|
|
19
|
+
/**
|
|
20
|
+
* The title line followed by the verse lines, in the same shape the editor
|
|
21
|
+
* accepts when Bible text is pasted after `^`:
|
|
22
|
+
* `(KJV) Genesis 1:1\n(1): In the beginning…`.
|
|
23
|
+
*/
|
|
17
24
|
fullText: string;
|
|
25
|
+
/** Extra CSS for this verse's text, e.g. a font for a non-Latin version. */
|
|
18
26
|
style?: CSSProperties;
|
|
19
27
|
};
|
|
28
|
+
/** Everything `new BibleNote(props)` needs from the host application. */
|
|
20
29
|
export type BibleNoteProps = {
|
|
30
|
+
/**
|
|
31
|
+
* The person dataset behind `@` mentions, hover cards, the advanced panel
|
|
32
|
+
* and the lookup panel. Build it with `NamesLookupManager.fromRawDataset`.
|
|
33
|
+
*/
|
|
21
34
|
namesLookupManager: NamesLookupManager;
|
|
35
|
+
/**
|
|
36
|
+
* The place dataset behind `#` mentions, hover cards, the advanced panel and
|
|
37
|
+
* the lookup panel. Build it with `LocationsLookupManager.fromRawDataset`.
|
|
38
|
+
*/
|
|
22
39
|
locationsLookupManager: LocationsLookupManager;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the language code of a piece of text (`'en'` for English). Used to
|
|
42
|
+
* pick a font for pasted Bible text and Excalidraw text: when it returns a
|
|
43
|
+
* code other than `'en'`, the editor switches to the first font in
|
|
44
|
+
* `editorExtraFontFamilies` registered for that language.
|
|
45
|
+
*/
|
|
23
46
|
getLangCode: (text: string) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Fonts added to the toolbar's font menu and to Excalidraw, as
|
|
49
|
+
* `[fontFamily, languageCode]` pairs. The host must load the font faces
|
|
50
|
+
* itself; pass `[]` for the built-in fonts only.
|
|
51
|
+
*/
|
|
24
52
|
editorExtraFontFamilies: ReadonlyArray<ExtraFontFamilyOption>;
|
|
53
|
+
/** Extra Excalidraw library items, offered next to the bundled Christian library. */
|
|
25
54
|
excalidrawLibraryItems?: LibraryItems;
|
|
55
|
+
/** Forgets every Excalidraw library file `excalidrawSaveLibrariesFile` stored. */
|
|
26
56
|
excalidrawClearLibrariesFileList?: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the Excalidraw library files saved earlier (each a serialized
|
|
59
|
+
* library JSON string); read each time the Excalidraw editor opens.
|
|
60
|
+
*/
|
|
27
61
|
excalidrawLoadLibrariesFileList?: () => string[];
|
|
62
|
+
/**
|
|
63
|
+
* Persists a library the user imported in Excalidraw (a serialized library
|
|
64
|
+
* JSON string) so `excalidrawLoadLibrariesFileList` can return it next time.
|
|
65
|
+
*/
|
|
28
66
|
excalidrawSaveLibrariesFile?: (librariesFile: string) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Extra CSS font-family values offered in the sticky-note font picker, e.g.
|
|
69
|
+
* `'"Fasthand"'`. Pass `[]` for none.
|
|
70
|
+
*/
|
|
29
71
|
stickyNoteExtraFontFamilies: ReadonlyArray<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Stores every piece of editor state except the note itself: settings,
|
|
74
|
+
* comments, read-only mode, zoom, panel state. `createBrowserStorageManager()`
|
|
75
|
+
* keeps them in `localStorage`. The keys it receives are listed in
|
|
76
|
+
* `BIBLE_NOTE_STORAGE_MANAGER_KEYS`.
|
|
77
|
+
*/
|
|
30
78
|
storageManager: BibleNoteStorageManager;
|
|
79
|
+
/**
|
|
80
|
+
* Saves the note: called with the serialized editor state (a JSON string) on
|
|
81
|
+
* every change to the document — the same string `BibleNote#content`
|
|
82
|
+
* returns. Called with `''` when the stored note could not be parsed and is
|
|
83
|
+
* discarded.
|
|
84
|
+
*/
|
|
31
85
|
saveData: (data: string) => Promise<void> | void;
|
|
86
|
+
/**
|
|
87
|
+
* Loads the note saved by `saveData`. Return `null` or `''` for an empty
|
|
88
|
+
* editor.
|
|
89
|
+
*/
|
|
32
90
|
loadData: () => Promise<string | null> | string | null;
|
|
91
|
+
/**
|
|
92
|
+
* Maps a media file the user dropped or picked to a path or URL to store in
|
|
93
|
+
* the note instead of embedding it as a data URL. Return `null` to fall back
|
|
94
|
+
* to embedding. In a browser there is usually no path to give; in Electron
|
|
95
|
+
* this is where a file's location on disk comes from.
|
|
96
|
+
*/
|
|
33
97
|
resolveFilePath?: FilePathResolver;
|
|
98
|
+
/**
|
|
99
|
+
* Shows a media file's location to the user (e.g. Electron's
|
|
100
|
+
* `shell.showItemInFolder`). When provided, a selected image, video, audio or
|
|
101
|
+
* PDF whose source is a local file path gets a reveal button.
|
|
102
|
+
*/
|
|
34
103
|
revealFile?: FileRevealer;
|
|
104
|
+
/**
|
|
105
|
+
* Replaces the footer Print button's built-in printing, which prints the note
|
|
106
|
+
* laid out at the selected page size.
|
|
107
|
+
*/
|
|
35
108
|
print?: () => void;
|
|
109
|
+
/**
|
|
110
|
+
* The editor is embedded in an app rather than a web page: hides the footer's
|
|
111
|
+
* **Share as Link** and **Convert From Markdown** buttons. Defaults to `false`.
|
|
112
|
+
*/
|
|
36
113
|
isOnApp?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Compact footer: folds Import, Export and Editor Information into a
|
|
116
|
+
* **More actions** menu. Defaults to `false`.
|
|
117
|
+
*/
|
|
37
118
|
isMinimize?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Resolves a short verse key (`GEN 1:1`) to its displayed title and text.
|
|
121
|
+
* Used for verse lists in mention panels and in the Word export's References
|
|
122
|
+
* appendix. Without it, those lists show the bare key.
|
|
123
|
+
*/
|
|
38
124
|
shortToVerseData?: (shortText: string) => Promise<MentionedBibleDataType | null>;
|
|
125
|
+
/**
|
|
126
|
+
* Lists the short verse keys a verse mention covers, given its full text.
|
|
127
|
+
* Enables the people and places mentioned in a verse, shown in that verse's
|
|
128
|
+
* advanced panel and in the Word export.
|
|
129
|
+
*/
|
|
39
130
|
verseFullTextToListShorts?: (fullText: string) => Promise<string[] | null>;
|
|
131
|
+
/**
|
|
132
|
+
* Offers the same verse in another Bible version. When provided, the version
|
|
133
|
+
* label in a verse's advanced panel becomes a button; resolve to the verse in
|
|
134
|
+
* the chosen version to open it in a new panel, or `null` to do nothing.
|
|
135
|
+
*/
|
|
40
136
|
changeBibleKey?: (event: React.MouseEvent<HTMLButtonElement>, verseFullText: string) => Promise<MentionedBibleDataType | null>;
|
|
41
137
|
};
|
|
138
|
+
/** Options for `BibleNote#render`. */
|
|
42
139
|
export type BibleNoteRenderOptions = {
|
|
140
|
+
/**
|
|
141
|
+
* The settings panel to mount, normally `<BibleNoteSettings />`. Omit it and
|
|
142
|
+
* the editor has no settings panel.
|
|
143
|
+
*/
|
|
43
144
|
settings?: ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* Where to portal the `settings` panel. Without it the panel renders inside
|
|
147
|
+
* the editor's own layout.
|
|
148
|
+
*/
|
|
44
149
|
settingsContainerElement?: Element | DocumentFragment;
|
|
45
150
|
};
|
|
46
151
|
export declare function createBibleNoteStorageManager({ loadData, saveData, storageManager, }: BibleNoteProps): BibleNoteStorageManager;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storage key of the note itself. The editor never hands this key to the
|
|
3
|
+
* host's `storageManager`: reads and writes of it go to `loadData` / `saveData`
|
|
4
|
+
* instead.
|
|
5
|
+
*/
|
|
1
6
|
export declare const EDITOR_STATE_LOCAL_STORAGE_KEY = "lexical-playground-editor-state";
|
|
2
7
|
export declare const SHARED_EDITOR_STATE_QUERY_PARAM = "editor-state";
|
|
3
8
|
export declare const SHARED_EDITOR_STATE_PASSWORD_PREFIX = "pwdecrypted:";
|
|
@@ -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/lookupTypes.d.ts
CHANGED
|
@@ -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;
|