bookish-press 0.4.23 → 0.4.25
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/components/Auth.svelte +11 -13
- package/components/BookPreview.svelte +12 -14
- package/components/app/Feedback.svelte +12 -10
- package/components/app/Head.svelte +4 -1
- package/components/app/Head.svelte.d.ts +6 -15
- package/components/app/Paragraph.svelte +1 -0
- package/components/app/{Writing.svelte → Section.svelte} +0 -1
- package/components/app/Section.svelte.d.ts +27 -0
- package/components/app/TextInput.svelte +1 -0
- package/components/chapter/Block.svelte +3 -1
- package/components/chapter/CaptionedCode.svelte +2 -2
- package/components/chapter/ChapterBody.svelte +2 -1
- package/components/chapter/ChapterBody.svelte.d.ts +1 -0
- package/components/chapter/Comment.svelte +2 -2
- package/components/chapter/Embed.svelte +3 -3
- package/components/chapter/Embed.svelte.d.ts +1 -0
- package/components/chapter/Figure.svelte +2 -2
- package/components/chapter/Format.svelte +5 -3
- package/components/chapter/Format.svelte.d.ts +1 -0
- package/components/chapter/InlineCode.svelte +2 -2
- package/components/chapter/Label.svelte +2 -2
- package/components/chapter/Link.svelte +2 -2
- package/components/chapter/Marginal.svelte +2 -2
- package/components/chapter/Paragraph.svelte +5 -0
- package/components/chapter/Table.svelte +2 -2
- package/components/chapter/Text.svelte +2 -2
- package/components/editor/BookishEditor.svelte +51 -28
- package/components/editor/BookishEditor.svelte.d.ts +4 -1
- package/components/editor/CaretView.svelte +3 -1
- package/components/editor/CaretView.svelte.d.ts +1 -0
- package/components/editor/ConfirmButton.svelte +1 -1
- package/components/editor/Note.svelte +1 -0
- package/components/editor/Permissions.svelte +95 -0
- package/components/editor/Permissions.svelte.d.ts +20 -0
- package/components/editor/Toolbar.svelte +0 -1
- package/components/editor/ToolbarGroup.svelte +0 -1
- package/components/page/Acknowledgements.svelte +13 -11
- package/components/page/Authors.svelte +5 -8
- package/components/page/Authors.svelte.d.ts +1 -0
- package/components/page/BookLoader.svelte +59 -0
- package/components/page/BookLoader.svelte.d.ts +16 -0
- package/components/page/BulkReferenceEditor.svelte +8 -8
- package/components/page/Chapter.svelte +43 -10
- package/components/page/Contexts.d.ts +14 -5
- package/components/page/Contexts.js +88 -6
- package/components/page/DefinitionView.svelte +18 -8
- package/components/page/Description.svelte +12 -9
- package/components/page/Edition.svelte +8 -8
- package/components/page/Edition.svelte.d.ts +0 -1
- package/components/page/EditionLoader.svelte +99 -0
- package/components/page/EditionLoader.svelte.d.ts +18 -0
- package/components/page/Editions.svelte +92 -143
- package/components/page/Glossary.svelte +13 -6
- package/components/page/Header.svelte +22 -20
- package/components/page/Header.svelte.d.ts +2 -0
- package/components/page/Index.svelte +6 -4
- package/components/page/Instructions.svelte +1 -2
- package/components/page/Instructions.svelte.d.ts +3 -1
- package/components/page/License.svelte +20 -12
- package/components/page/Media.svelte +14 -12
- package/components/page/Publish.svelte +120 -0
- package/components/page/Publish.svelte.d.ts +14 -0
- package/components/page/Reference.svelte +16 -17
- package/components/page/References.svelte +8 -3
- package/components/page/Search.svelte +3 -1
- package/components/page/Status.svelte +18 -19
- package/components/page/SubdomainEditor.svelte +3 -2
- package/components/page/TableOfContents.svelte +70 -30
- package/components/page/TableOfContentsRow.svelte +4 -4
- package/components/page/ThemeEditor.svelte +8 -5
- package/components/page/Unknown.svelte +5 -2
- package/models/CRUD.d.ts +19 -11
- package/models/CRUD.js +177 -122
- package/models/Firebase.js +12 -8
- package/models/book/Book.d.ts +19 -14
- package/models/book/Book.js +47 -54
- package/models/book/Chapter.d.ts +5 -1
- package/models/book/Chapter.js +24 -15
- package/models/book/Edition.d.ts +31 -7
- package/models/book/Edition.js +101 -32
- package/models/chapter/Parser.d.ts +2 -2
- package/models/chapter/Parser.js +26 -24
- package/package.json +18 -15
- package/components/app/Writing.svelte.d.ts +0 -27
- package/models/loadEdition.d.ts +0 -5
- package/models/loadEdition.js +0 -20
package/models/book/Book.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { readEdition } from '../CRUD';
|
|
2
1
|
import BookMedia from './BookMedia';
|
|
3
2
|
export default class Book {
|
|
4
3
|
ref;
|
|
@@ -6,17 +5,21 @@ export default class Book {
|
|
|
6
5
|
authors;
|
|
7
6
|
description;
|
|
8
7
|
cover;
|
|
8
|
+
published;
|
|
9
9
|
editions;
|
|
10
10
|
domain;
|
|
11
11
|
uids;
|
|
12
12
|
media;
|
|
13
|
-
constructor(ref, title, authors, description, cover,
|
|
13
|
+
constructor(ref, title, authors, description, cover, editions, domain, uids) {
|
|
14
14
|
this.ref = ref;
|
|
15
15
|
this.title = title;
|
|
16
16
|
this.authors = authors;
|
|
17
17
|
this.description = description;
|
|
18
18
|
this.cover = cover;
|
|
19
|
-
|
|
19
|
+
// The published state is always true if some edition's published flag isn't null.
|
|
20
|
+
this.published = editions.some((edition) => edition.published !== null);
|
|
21
|
+
// We always keep editions in reversed edition number for easy reference.
|
|
22
|
+
this.editions = editions.sort((a, b) => a.number - b.number);
|
|
20
23
|
this.domain = domain;
|
|
21
24
|
this.uids = uids;
|
|
22
25
|
this.media = new BookMedia(this);
|
|
@@ -33,18 +36,24 @@ export default class Book {
|
|
|
33
36
|
authors: this.authors,
|
|
34
37
|
description: this.description,
|
|
35
38
|
cover: this.cover,
|
|
39
|
+
published: this.published,
|
|
40
|
+
domain: this.domain,
|
|
36
41
|
editions: this.editions,
|
|
37
42
|
uids: this.uids,
|
|
43
|
+
readuids: Array.from(new Set(this.editions
|
|
44
|
+
.map((edition) => [
|
|
45
|
+
...edition.editionuids,
|
|
46
|
+
...edition.chapteruids,
|
|
47
|
+
])
|
|
48
|
+
.flat())),
|
|
38
49
|
};
|
|
39
|
-
if (this.domain !== undefined)
|
|
40
|
-
json.domain = this.domain;
|
|
41
50
|
return json;
|
|
42
51
|
}
|
|
43
52
|
getSubdomain() {
|
|
44
53
|
return this.domain;
|
|
45
54
|
}
|
|
46
55
|
withSubdomain(domain) {
|
|
47
|
-
return new Book(this.ref, this.title, this.authors, this.description, this.cover, this.editions, domain.length === 0 ?
|
|
56
|
+
return new Book(this.ref, this.title, this.authors, this.description, this.cover, this.editions, domain.length === 0 ? null : domain, this.uids);
|
|
48
57
|
}
|
|
49
58
|
getTitle() {
|
|
50
59
|
return this.title;
|
|
@@ -76,26 +85,13 @@ export default class Book {
|
|
|
76
85
|
getRefID() {
|
|
77
86
|
return this.ref.id;
|
|
78
87
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
isValidEditionNumber(edition) {
|
|
85
|
-
return this.getEditionNumber(edition) !== undefined;
|
|
86
|
-
}
|
|
87
|
-
/* Note: editions are numbered 1-n, but stored in reverse chronological order. */
|
|
88
|
-
getEditionNumber(number) {
|
|
89
|
-
return number < 1 || number > this.editions.length
|
|
90
|
-
? undefined
|
|
91
|
-
: readEdition(this.editions[this.editions.length - number].ref.id);
|
|
92
|
-
}
|
|
93
|
-
getLatestPublishedEdition() {
|
|
94
|
-
const latest = this.getLatestPublishedEditionID();
|
|
95
|
-
return latest === undefined ? undefined : readEdition(latest);
|
|
88
|
+
getEditionNumberID(number) {
|
|
89
|
+
// Get the ID corresponding to this number.
|
|
90
|
+
const edition = this.editions.find((ed) => ed.number === number);
|
|
91
|
+
return edition ? edition.ref.id : undefined;
|
|
96
92
|
}
|
|
97
93
|
getLatestPublishedEditionID() {
|
|
98
|
-
return this.editions.
|
|
94
|
+
return this.editions.filter((ed) => ed.published !== null)[0]?.ref.id;
|
|
99
95
|
}
|
|
100
96
|
getLatestEditionID() {
|
|
101
97
|
return this.editions[0]?.ref.id;
|
|
@@ -103,40 +99,37 @@ export default class Book {
|
|
|
103
99
|
getEditions() {
|
|
104
100
|
return this.editions.slice();
|
|
105
101
|
}
|
|
106
|
-
|
|
102
|
+
getPublishedEditionCount() {
|
|
103
|
+
return this.editions.filter((edition) => edition.published).length;
|
|
104
|
+
}
|
|
105
|
+
isEditor(uid) {
|
|
106
|
+
return this.uids.includes(uid);
|
|
107
|
+
}
|
|
108
|
+
withEditors(uids) {
|
|
109
|
+
return new Book(this.ref, this.title, this.authors, this.description, this.cover, this.editions, this.domain, uids);
|
|
110
|
+
}
|
|
111
|
+
withEditions(revisions) {
|
|
107
112
|
return new Book(this.ref, this.title, this.authors, this.description, this.cover, revisions, this.domain, this.uids);
|
|
108
113
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return this.withRevisions([
|
|
114
|
-
...this.editions.slice(0, index),
|
|
115
|
-
{
|
|
116
|
-
ref: revision.ref,
|
|
117
|
-
time: revision.time,
|
|
118
|
-
summary,
|
|
119
|
-
published: revision.published,
|
|
120
|
-
},
|
|
121
|
-
...this.editions.slice(index + 1),
|
|
122
|
-
]);
|
|
123
|
-
}
|
|
124
|
-
withEditionAsPublished(published, editionNumber) {
|
|
125
|
-
if (editionNumber < 0 || editionNumber >= this.editions.length)
|
|
114
|
+
withRevisedEdition(previous, revised) {
|
|
115
|
+
// Get the new info.
|
|
116
|
+
const info = revised.getInfo();
|
|
117
|
+
if (info === undefined)
|
|
126
118
|
return this;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
...this.editions
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
119
|
+
// If no previous addition, just add it.
|
|
120
|
+
if (previous === undefined)
|
|
121
|
+
return this.withEditions([...this.editions, info]);
|
|
122
|
+
// Find the corresponding edition.
|
|
123
|
+
const index = this.editions.findIndex((edition) => edition.number === previous.number);
|
|
124
|
+
return index < 0
|
|
125
|
+
? this
|
|
126
|
+
: this.withEditions([
|
|
127
|
+
...this.editions.slice(0, index),
|
|
128
|
+
info,
|
|
129
|
+
...this.editions.slice(index + 1),
|
|
130
|
+
]);
|
|
138
131
|
}
|
|
139
132
|
hasPublishedEdition() {
|
|
140
|
-
return
|
|
133
|
+
return this.editions.some((revision) => revision.published !== null);
|
|
141
134
|
}
|
|
142
135
|
}
|
package/models/book/Chapter.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type ChapterSpecification = {
|
|
|
11
11
|
forthcoming: boolean;
|
|
12
12
|
section?: string;
|
|
13
13
|
text?: string;
|
|
14
|
+
uids: string[];
|
|
14
15
|
};
|
|
15
16
|
export type ChapterContent = {
|
|
16
17
|
text: string;
|
|
@@ -30,6 +31,7 @@ export default class Chapter {
|
|
|
30
31
|
readonly forthcoming: boolean;
|
|
31
32
|
readonly section: string | undefined;
|
|
32
33
|
readonly text: string;
|
|
34
|
+
readonly uids: string[];
|
|
33
35
|
_ast: ChapterNode | undefined;
|
|
34
36
|
_index: Record<string, Array<Match>> | undefined;
|
|
35
37
|
_wordCount: number | undefined;
|
|
@@ -39,7 +41,7 @@ export default class Chapter {
|
|
|
39
41
|
}[];
|
|
40
42
|
lastEdit: number;
|
|
41
43
|
listeners: Set<(text: string) => void>;
|
|
42
|
-
constructor(ref: DocumentReference | undefined, id: string, title: string, authors: string[], image: string | null, numbered: boolean, forthcoming: boolean, section: string | undefined, text: string);
|
|
44
|
+
constructor(ref: DocumentReference | undefined, id: string, title: string, authors: string[], image: string | null, numbered: boolean, forthcoming: boolean, section: string | undefined, text: string, uids: string[]);
|
|
43
45
|
/**
|
|
44
46
|
* Convert a chapter spec and it's text into a chapter object.
|
|
45
47
|
* The spec may contain the text itself, but it may not, so we require it to be
|
|
@@ -48,6 +50,7 @@ export default class Chapter {
|
|
|
48
50
|
static fromJSON(spec: ChapterSpecification, text: string): Chapter;
|
|
49
51
|
toJSON(): ChapterSpecification;
|
|
50
52
|
getRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
|
|
53
|
+
withEditors(uids: string[]): Chapter;
|
|
51
54
|
withRef(ref: DocumentReference): Chapter;
|
|
52
55
|
withoutRef(): Chapter;
|
|
53
56
|
getID(): string;
|
|
@@ -58,6 +61,7 @@ export default class Chapter {
|
|
|
58
61
|
asForthcoming(forthcoming: boolean): Chapter;
|
|
59
62
|
isNumbered(): boolean;
|
|
60
63
|
asNumbered(numbered: boolean): Chapter;
|
|
64
|
+
isEditor(uid: string): boolean;
|
|
61
65
|
getText(): string;
|
|
62
66
|
withText(text: string): Chapter;
|
|
63
67
|
withAST(ast: ChapterNode): Chapter;
|
package/models/book/Chapter.js
CHANGED
|
@@ -11,6 +11,7 @@ export default class Chapter {
|
|
|
11
11
|
forthcoming;
|
|
12
12
|
section;
|
|
13
13
|
text;
|
|
14
|
+
uids;
|
|
14
15
|
// Derived values
|
|
15
16
|
_ast = undefined;
|
|
16
17
|
_index = undefined;
|
|
@@ -21,7 +22,7 @@ export default class Chapter {
|
|
|
21
22
|
lastEdit = 0;
|
|
22
23
|
// A set of listeners that are notified when the chapter text changes.
|
|
23
24
|
listeners = new Set();
|
|
24
|
-
constructor(ref, id, title, authors, image, numbered, forthcoming, section, text) {
|
|
25
|
+
constructor(ref, id, title, authors, image, numbered, forthcoming, section, text, uids) {
|
|
25
26
|
this.ref = ref;
|
|
26
27
|
this.id = id;
|
|
27
28
|
this.title = title;
|
|
@@ -31,6 +32,7 @@ export default class Chapter {
|
|
|
31
32
|
this.forthcoming = forthcoming;
|
|
32
33
|
this.section = section;
|
|
33
34
|
this.text = text;
|
|
35
|
+
this.uids = uids;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* Convert a chapter spec and it's text into a chapter object.
|
|
@@ -39,7 +41,7 @@ export default class Chapter {
|
|
|
39
41
|
*/
|
|
40
42
|
static fromJSON(spec, text) {
|
|
41
43
|
// Copy the spec, filling in defaults as necessary.
|
|
42
|
-
return new Chapter(spec.ref, spec.id, spec.title, spec.authors ?? [], spec.image ?? null, spec.numbered === true || spec.numbered === undefined, spec.forthcoming === true, spec.section, spec.text ?? text);
|
|
44
|
+
return new Chapter(spec.ref, spec.id, spec.title, spec.authors ?? [], spec.image ?? null, spec.numbered === true || spec.numbered === undefined, spec.forthcoming === true, spec.section, spec.text ?? text, spec.uids);
|
|
43
45
|
}
|
|
44
46
|
toJSON() {
|
|
45
47
|
// Note that we don't include the chapter text in the payload; that's stored in the chapters subcollection.
|
|
@@ -51,6 +53,7 @@ export default class Chapter {
|
|
|
51
53
|
image: this.image,
|
|
52
54
|
numbered: this.numbered,
|
|
53
55
|
forthcoming: this.forthcoming,
|
|
56
|
+
uids: this.uids,
|
|
54
57
|
};
|
|
55
58
|
if (this.ref)
|
|
56
59
|
json.ref = this.ref;
|
|
@@ -61,44 +64,50 @@ export default class Chapter {
|
|
|
61
64
|
getRef() {
|
|
62
65
|
return this.ref;
|
|
63
66
|
}
|
|
67
|
+
withEditors(uids) {
|
|
68
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, uids);
|
|
69
|
+
}
|
|
64
70
|
withRef(ref) {
|
|
65
|
-
return new Chapter(ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text);
|
|
71
|
+
return new Chapter(ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
66
72
|
}
|
|
67
73
|
withoutRef() {
|
|
68
|
-
return new Chapter(undefined, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text);
|
|
74
|
+
return new Chapter(undefined, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
69
75
|
}
|
|
70
76
|
getID() {
|
|
71
77
|
return this.id;
|
|
72
78
|
}
|
|
73
79
|
withChapterID(id) {
|
|
74
|
-
return new Chapter(this.ref, id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text);
|
|
80
|
+
return new Chapter(this.ref, id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
75
81
|
}
|
|
76
82
|
getSection() {
|
|
77
83
|
return this.section;
|
|
78
84
|
}
|
|
79
85
|
withSection(section) {
|
|
80
|
-
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, section, this.text);
|
|
86
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, section, this.text, this.uids);
|
|
81
87
|
}
|
|
82
88
|
isForthcoming() {
|
|
83
89
|
return this.forthcoming;
|
|
84
90
|
}
|
|
85
91
|
asForthcoming(forthcoming) {
|
|
86
|
-
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, forthcoming, this.section, this.text);
|
|
92
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, forthcoming, this.section, this.text, this.uids);
|
|
87
93
|
}
|
|
88
94
|
isNumbered() {
|
|
89
95
|
return this.numbered;
|
|
90
96
|
}
|
|
91
97
|
asNumbered(numbered) {
|
|
92
|
-
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, numbered, this.forthcoming, this.section, this.text);
|
|
98
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
99
|
+
}
|
|
100
|
+
isEditor(uid) {
|
|
101
|
+
return this.uids.includes(uid);
|
|
93
102
|
}
|
|
94
103
|
getText() {
|
|
95
104
|
return this.text;
|
|
96
105
|
}
|
|
97
106
|
withText(text) {
|
|
98
|
-
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, text);
|
|
107
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, text, this.uids);
|
|
99
108
|
}
|
|
100
109
|
withAST(ast) {
|
|
101
|
-
const newChapter = new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, ast.toBookdown());
|
|
110
|
+
const newChapter = new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, ast.toBookdown(), this.uids);
|
|
102
111
|
newChapter._ast = ast;
|
|
103
112
|
return newChapter;
|
|
104
113
|
}
|
|
@@ -106,7 +115,7 @@ export default class Chapter {
|
|
|
106
115
|
return this.authors;
|
|
107
116
|
}
|
|
108
117
|
withAuthor(name) {
|
|
109
|
-
return new Chapter(this.ref, this.id, this.title, [...this.authors, name], this.image, this.numbered, this.forthcoming, this.section, this.text);
|
|
118
|
+
return new Chapter(this.ref, this.id, this.title, [...this.authors, name], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
110
119
|
}
|
|
111
120
|
withRenamedAuthor(index, name) {
|
|
112
121
|
if (index < 0 || index >= this.authors.length)
|
|
@@ -115,24 +124,24 @@ export default class Chapter {
|
|
|
115
124
|
...this.authors.slice(0, index),
|
|
116
125
|
name,
|
|
117
126
|
...this.authors.slice(index + 1),
|
|
118
|
-
], this.image, this.numbered, this.forthcoming, this.section, this.text);
|
|
127
|
+
], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
119
128
|
}
|
|
120
129
|
withoutAuthor(index) {
|
|
121
130
|
if (index < 0 || index >= this.authors.length)
|
|
122
131
|
return this;
|
|
123
|
-
return new Chapter(this.ref, this.id, this.title, [...this.authors.slice(0, index), ...this.authors.slice(index + 1)], this.image, this.numbered, this.forthcoming, this.section, this.text);
|
|
132
|
+
return new Chapter(this.ref, this.id, this.title, [...this.authors.slice(0, index), ...this.authors.slice(index + 1)], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
124
133
|
}
|
|
125
134
|
getTitle() {
|
|
126
135
|
return this.title;
|
|
127
136
|
}
|
|
128
137
|
withTitle(title) {
|
|
129
|
-
return new Chapter(this.ref, this.id, title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text);
|
|
138
|
+
return new Chapter(this.ref, this.id, title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
130
139
|
}
|
|
131
140
|
getImage() {
|
|
132
141
|
return this.image;
|
|
133
142
|
}
|
|
134
143
|
withImage(image) {
|
|
135
|
-
return new Chapter(this.ref, this.id, this.title, this.authors, image, this.numbered, this.forthcoming, this.section, this.text);
|
|
144
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
136
145
|
}
|
|
137
146
|
getAST(edition) {
|
|
138
147
|
// Compute the cache if necessary
|
package/models/book/Edition.d.ts
CHANGED
|
@@ -7,9 +7,13 @@ import type Definition from './Definition.js';
|
|
|
7
7
|
import type { DocumentReference } from 'firebase/firestore';
|
|
8
8
|
import type Book from './Book';
|
|
9
9
|
import type FormatNode from '../chapter/FormatNode';
|
|
10
|
+
import type { EditionInfo } from './Book';
|
|
10
11
|
export type EditionSpecification = {
|
|
11
|
-
bookRef
|
|
12
|
+
bookRef: DocumentReference;
|
|
12
13
|
title: string;
|
|
14
|
+
number: number;
|
|
15
|
+
summary: string;
|
|
16
|
+
published: number | null;
|
|
13
17
|
authors: string[];
|
|
14
18
|
images: Record<string, string | null>;
|
|
15
19
|
description: string;
|
|
@@ -23,13 +27,18 @@ export type EditionSpecification = {
|
|
|
23
27
|
glossary: Record<string, Definition>;
|
|
24
28
|
theme: Theme | null;
|
|
25
29
|
uids: string[];
|
|
30
|
+
chapteruids: string[];
|
|
31
|
+
active: Record<string, string>;
|
|
26
32
|
};
|
|
27
33
|
export default class Edition {
|
|
28
|
-
readonly bookRef: DocumentReference
|
|
34
|
+
readonly bookRef: DocumentReference;
|
|
29
35
|
readonly editionRef: DocumentReference | undefined;
|
|
30
36
|
readonly uids: string[];
|
|
31
37
|
readonly title: string;
|
|
32
38
|
readonly authors: string[];
|
|
39
|
+
readonly number: number;
|
|
40
|
+
readonly summary: string;
|
|
41
|
+
readonly published: number | null;
|
|
33
42
|
readonly images: Record<string, string | null>;
|
|
34
43
|
readonly description: string;
|
|
35
44
|
readonly chapters: Chapter[];
|
|
@@ -41,18 +50,23 @@ export default class Edition {
|
|
|
41
50
|
readonly symbols: Record<string, string>;
|
|
42
51
|
readonly glossary: Record<string, Definition>;
|
|
43
52
|
readonly theme: Theme | null;
|
|
44
|
-
|
|
53
|
+
readonly active: Record<string, string>;
|
|
54
|
+
constructor(bookRef: DocumentReference, editionRef: DocumentReference | undefined, uids: string[], title: string, authors: string[], number: number, summary: string, published: number | null, images: Record<string, string | null>, description: string, chapters: Chapter[], license: string, acknowledgements: string, tags: string[], sources: Record<string, string>, references: Record<string, string | string[]> | Record<string, FormatNode | Reference>, symbols: Record<string, string>, glossary: Record<string, Definition>, theme: Theme | null, active: Record<string, string>);
|
|
45
55
|
static fromJSON(editionRef: DocumentReference | undefined, spec: EditionSpecification): Edition;
|
|
46
56
|
static parseReference(citationID: string, ref: string | string[], edition: Edition, short?: boolean): FormatNode | Reference;
|
|
47
57
|
toObject(): EditionSpecification;
|
|
48
|
-
|
|
58
|
+
getBookRef(): DocumentReference<import("@firebase/firestore").DocumentData>;
|
|
59
|
+
getEditionRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
|
|
60
|
+
getChapterUIDS(): string[];
|
|
49
61
|
withRef(editionRef: DocumentReference | undefined): Edition;
|
|
50
62
|
getTitle(): string;
|
|
51
63
|
withTitle(title: string): Edition;
|
|
52
64
|
getDescription(): string;
|
|
53
65
|
setDescription(description: string): Edition;
|
|
54
66
|
getAcknowledgements(): string;
|
|
55
|
-
|
|
67
|
+
withAcknowledgements(acks: string): Edition;
|
|
68
|
+
withSummary(summary: string): Edition;
|
|
69
|
+
asPublished(published: boolean): Edition;
|
|
56
70
|
getLicense(): string;
|
|
57
71
|
setLicense(license: string): Edition;
|
|
58
72
|
getChapters(): Chapter[];
|
|
@@ -62,8 +76,10 @@ export default class Edition {
|
|
|
62
76
|
getChapterPosition(chapterID: string): number | undefined;
|
|
63
77
|
getChapterCount(): number;
|
|
64
78
|
withChapters(chapters: Chapter[]): Edition;
|
|
79
|
+
withChapterText(text: [DocumentReference, string][]): Edition;
|
|
65
80
|
withRevisedChapter(previous: Chapter, edited: Chapter): Edition;
|
|
66
81
|
withoutRefs(): Edition;
|
|
82
|
+
withIncrementedEditionNumber(): Edition;
|
|
67
83
|
withNewChapter(): Edition;
|
|
68
84
|
withoutChapter(chapterID: string): Edition;
|
|
69
85
|
withMovedChapter(chapterID: string, increment: number): Edition;
|
|
@@ -93,9 +109,16 @@ export default class Edition {
|
|
|
93
109
|
withAuthor(name: string): Edition;
|
|
94
110
|
withAuthorName(index: number, name: string): Edition;
|
|
95
111
|
withoutAuthor(index: number): Edition;
|
|
112
|
+
withEditors(uids: string[]): Edition;
|
|
96
113
|
hasImage(id: string): boolean;
|
|
97
114
|
getImage(id: string): string | null;
|
|
98
115
|
withImage(id: string, embed: string | null): Edition;
|
|
116
|
+
isEditor(uid: string): boolean;
|
|
117
|
+
isChapterEditor(uid: string): boolean;
|
|
118
|
+
getLeasee(content: string): string | undefined;
|
|
119
|
+
hasLease(uid: string, content: string): boolean;
|
|
120
|
+
isLeased(contentID: string): boolean;
|
|
121
|
+
withLock(uid: string, content: string, lock: boolean): Edition;
|
|
99
122
|
getBookReadingTime(): number | undefined;
|
|
100
123
|
getChapterNumber(chapterID: string): undefined;
|
|
101
124
|
getSource(sourceID: string): string | null;
|
|
@@ -108,6 +131,7 @@ export default class Edition {
|
|
|
108
131
|
getEmbeds(): EmbedNode[];
|
|
109
132
|
isLatestEdition(book: Book): boolean;
|
|
110
133
|
isLatestPublishedEdition(book: Book): boolean;
|
|
111
|
-
getEditionNumber(
|
|
112
|
-
getEditionLabel(
|
|
134
|
+
getEditionNumber(): number;
|
|
135
|
+
getEditionLabel(): string;
|
|
136
|
+
getInfo(): EditionInfo | undefined;
|
|
113
137
|
}
|