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/Edition.js
CHANGED
|
@@ -9,6 +9,9 @@ export default class Edition {
|
|
|
9
9
|
uids;
|
|
10
10
|
title;
|
|
11
11
|
authors;
|
|
12
|
+
number;
|
|
13
|
+
summary;
|
|
14
|
+
published;
|
|
12
15
|
images;
|
|
13
16
|
description;
|
|
14
17
|
chapters;
|
|
@@ -20,14 +23,18 @@ export default class Edition {
|
|
|
20
23
|
symbols;
|
|
21
24
|
glossary;
|
|
22
25
|
theme;
|
|
26
|
+
active;
|
|
23
27
|
// Given an object with a valid specification and an object mapping chapter IDs to chapter text,
|
|
24
28
|
// construct an object representing a book.
|
|
25
|
-
constructor(bookRef, editionRef, uids, title, authors, images, description, chapters, license, acknowledgements, tags, sources, references, symbols, glossary, theme) {
|
|
29
|
+
constructor(bookRef, editionRef, uids, title, authors, number, summary, published, images, description, chapters, license, acknowledgements, tags, sources, references, symbols, glossary, theme, active) {
|
|
26
30
|
this.bookRef = bookRef;
|
|
27
31
|
this.editionRef = editionRef;
|
|
28
32
|
this.uids = uids;
|
|
29
33
|
this.title = title;
|
|
30
34
|
this.authors = authors;
|
|
35
|
+
this.number = number;
|
|
36
|
+
this.summary = summary;
|
|
37
|
+
this.published = published;
|
|
31
38
|
this.images = images;
|
|
32
39
|
this.description = description;
|
|
33
40
|
this.chapters = chapters.slice();
|
|
@@ -45,11 +52,12 @@ export default class Edition {
|
|
|
45
52
|
this.symbols = Object.assign({}, symbols);
|
|
46
53
|
this.glossary = Object.assign({}, glossary);
|
|
47
54
|
this.theme = theme;
|
|
55
|
+
this.active = active;
|
|
48
56
|
}
|
|
49
57
|
static fromJSON(editionRef, spec) {
|
|
50
58
|
// Copy all of the specification metadata to fields.
|
|
51
59
|
// Choose suitable defaults if the spec is lacking a field.
|
|
52
|
-
return new Edition(spec.bookRef, editionRef, spec.uids, spec.title, spec.authors, spec.images, spec.description, spec.chapters.map((chap) => Chapter.fromJSON(chap, '')), spec.license, spec.acknowledgements, spec.tags, spec.sources, spec.references, spec.symbols, spec.glossary, spec.theme);
|
|
60
|
+
return new Edition(spec.bookRef, editionRef, spec.uids, spec.title, spec.authors, spec.number, spec.summary, spec.published, spec.images, spec.description, spec.chapters.map((chap) => Chapter.fromJSON(chap, '')), spec.license, spec.acknowledgements, spec.tags, spec.sources, spec.references, spec.symbols, spec.glossary, spec.theme, spec.active);
|
|
53
61
|
}
|
|
54
62
|
static parseReference(citationID, ref, edition, short = false) {
|
|
55
63
|
if (typeof ref === 'string')
|
|
@@ -72,8 +80,12 @@ export default class Edition {
|
|
|
72
80
|
references[citationID] =
|
|
73
81
|
ref instanceof Reference ? ref.toList() : ref.toBookdown();
|
|
74
82
|
const editionJSON = {
|
|
83
|
+
bookRef: this.bookRef,
|
|
75
84
|
title: this.title,
|
|
76
85
|
authors: this.authors,
|
|
86
|
+
number: this.number,
|
|
87
|
+
summary: this.summary,
|
|
88
|
+
published: this.published,
|
|
77
89
|
images: Object.assign({}, this.images),
|
|
78
90
|
description: this.description,
|
|
79
91
|
chapters: this.chapters.map((chap) => chap.toJSON()),
|
|
@@ -86,40 +98,52 @@ export default class Edition {
|
|
|
86
98
|
glossary: Object.assign({}, this.glossary),
|
|
87
99
|
theme: this.theme,
|
|
88
100
|
uids: this.uids.slice(),
|
|
101
|
+
chapteruids: this.getChapterUIDS(),
|
|
102
|
+
active: this.active,
|
|
89
103
|
};
|
|
90
|
-
if (this.bookRef)
|
|
91
|
-
editionJSON.bookRef = this.bookRef;
|
|
92
104
|
return editionJSON;
|
|
93
105
|
}
|
|
94
|
-
|
|
106
|
+
getBookRef() {
|
|
107
|
+
return this.bookRef;
|
|
108
|
+
}
|
|
109
|
+
getEditionRef() {
|
|
95
110
|
return this.editionRef;
|
|
96
111
|
}
|
|
112
|
+
getChapterUIDS() {
|
|
113
|
+
return Array.from(new Set(this.chapters.map((chapter) => chapter.uids).flat()));
|
|
114
|
+
}
|
|
97
115
|
withRef(editionRef) {
|
|
98
|
-
return new Edition(this.bookRef, editionRef, this.uids, this.title, this.authors, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
116
|
+
return new Edition(this.bookRef, editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
99
117
|
}
|
|
100
118
|
getTitle() {
|
|
101
119
|
return this.title;
|
|
102
120
|
}
|
|
103
121
|
withTitle(title) {
|
|
104
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, title, this.authors, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
122
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
105
123
|
}
|
|
106
124
|
getDescription() {
|
|
107
125
|
return this.description;
|
|
108
126
|
}
|
|
109
127
|
setDescription(description) {
|
|
110
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.images, description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
128
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
111
129
|
}
|
|
112
130
|
getAcknowledgements() {
|
|
113
131
|
return this.acknowledgements;
|
|
114
132
|
}
|
|
115
|
-
|
|
116
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.images, this.description, this.chapters, this.license, acks, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
133
|
+
withAcknowledgements(acks) {
|
|
134
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, acks, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
135
|
+
}
|
|
136
|
+
withSummary(summary) {
|
|
137
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
138
|
+
}
|
|
139
|
+
asPublished(published) {
|
|
140
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, published ? Date.now() : null, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
117
141
|
}
|
|
118
142
|
getLicense() {
|
|
119
143
|
return this.license;
|
|
120
144
|
}
|
|
121
145
|
setLicense(license) {
|
|
122
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.images, this.description, this.chapters, license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
146
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
123
147
|
}
|
|
124
148
|
getChapters() {
|
|
125
149
|
return this.chapters.slice();
|
|
@@ -145,7 +169,18 @@ export default class Edition {
|
|
|
145
169
|
return this.chapters.length;
|
|
146
170
|
}
|
|
147
171
|
withChapters(chapters) {
|
|
148
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.images, this.description, chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
172
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
173
|
+
}
|
|
174
|
+
withChapterText(text) {
|
|
175
|
+
return this.withChapters(this.chapters.map((chapter) => {
|
|
176
|
+
if (chapter.ref === undefined)
|
|
177
|
+
return chapter;
|
|
178
|
+
const match = text.find(([ref, text]) => chapter.ref !== undefined &&
|
|
179
|
+
chapter.ref.id === ref.id &&
|
|
180
|
+
chapter.text !== text &&
|
|
181
|
+
text !== undefined);
|
|
182
|
+
return match ? chapter.withText(match[1]) : chapter;
|
|
183
|
+
}));
|
|
149
184
|
}
|
|
150
185
|
withRevisedChapter(previous, edited) {
|
|
151
186
|
const index = this.chapters.indexOf(previous);
|
|
@@ -160,13 +195,16 @@ export default class Edition {
|
|
|
160
195
|
withoutRefs() {
|
|
161
196
|
return this.withRef(undefined).withChapters(this.chapters.map((chap) => chap.withoutRef()));
|
|
162
197
|
}
|
|
198
|
+
withIncrementedEditionNumber() {
|
|
199
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number + 1, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
200
|
+
}
|
|
163
201
|
withNewChapter() {
|
|
164
202
|
// Synthesize a chapter ID placeholder that doesn't overlap with existing chapter names
|
|
165
203
|
let number = 1;
|
|
166
204
|
while (this.hasChapter('chapter' + number))
|
|
167
205
|
number++;
|
|
168
206
|
// Create a default chapter on this model. Remember the document reference so we can modify it later.
|
|
169
|
-
const newChapter = new Chapter(undefined, `chapter${number}`, 'Untitled Chapter', [], null, true, false, undefined, '');
|
|
207
|
+
const newChapter = new Chapter(undefined, `chapter${number}`, 'Untitled Chapter', [], null, true, false, undefined, '', []);
|
|
170
208
|
return this.withChapters([...this.chapters, newChapter]);
|
|
171
209
|
}
|
|
172
210
|
withoutChapter(chapterID) {
|
|
@@ -187,7 +225,7 @@ export default class Edition {
|
|
|
187
225
|
const temp = newChapters[index + increment];
|
|
188
226
|
newChapters[index + increment] = newChapters[index];
|
|
189
227
|
newChapters[index] = temp;
|
|
190
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.images, this.description, newChapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
228
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, newChapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
191
229
|
}
|
|
192
230
|
getSymbols() {
|
|
193
231
|
return this.symbols;
|
|
@@ -204,7 +242,7 @@ export default class Edition {
|
|
|
204
242
|
: undefined;
|
|
205
243
|
}
|
|
206
244
|
withReferences(newReferences) {
|
|
207
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, newReferences, this.symbols, this.glossary, this.theme);
|
|
245
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, newReferences, this.symbols, this.glossary, this.theme, this.active);
|
|
208
246
|
}
|
|
209
247
|
withNewReferences(references) {
|
|
210
248
|
const newReferences = Object.assign({}, this.references);
|
|
@@ -245,7 +283,7 @@ export default class Edition {
|
|
|
245
283
|
return id in this.glossary;
|
|
246
284
|
}
|
|
247
285
|
withGlossary(glossary) {
|
|
248
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, glossary, this.theme);
|
|
286
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, glossary, this.theme, this.active);
|
|
249
287
|
}
|
|
250
288
|
withDefinition(id, phrase, definition, synonyms) {
|
|
251
289
|
const newGlossary = Object.assign({}, this.glossary);
|
|
@@ -282,7 +320,7 @@ export default class Edition {
|
|
|
282
320
|
return this.theme;
|
|
283
321
|
}
|
|
284
322
|
withTheme(theme) {
|
|
285
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, theme);
|
|
323
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, theme, this.active);
|
|
286
324
|
}
|
|
287
325
|
withThemeValue(group, name, value) {
|
|
288
326
|
if (this.theme === null)
|
|
@@ -300,7 +338,7 @@ export default class Edition {
|
|
|
300
338
|
return [...this.authors];
|
|
301
339
|
}
|
|
302
340
|
withAuthors(authors) {
|
|
303
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, authors, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
341
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
304
342
|
}
|
|
305
343
|
withAuthor(name) {
|
|
306
344
|
return this.withAuthors([...this.authors, name]);
|
|
@@ -322,6 +360,9 @@ export default class Edition {
|
|
|
322
360
|
...this.authors.slice(index + 1),
|
|
323
361
|
]);
|
|
324
362
|
}
|
|
363
|
+
withEditors(uids) {
|
|
364
|
+
return new Edition(this.bookRef, this.editionRef, uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
365
|
+
}
|
|
325
366
|
hasImage(id) {
|
|
326
367
|
return this.images[id] !== null;
|
|
327
368
|
}
|
|
@@ -331,7 +372,30 @@ export default class Edition {
|
|
|
331
372
|
withImage(id, embed) {
|
|
332
373
|
const newImages = Object.assign({}, this.images);
|
|
333
374
|
newImages[id] = embed;
|
|
334
|
-
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, newImages, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme);
|
|
375
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, newImages, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.active);
|
|
376
|
+
}
|
|
377
|
+
isEditor(uid) {
|
|
378
|
+
return this.uids.includes(uid);
|
|
379
|
+
}
|
|
380
|
+
isChapterEditor(uid) {
|
|
381
|
+
return this.getChapterUIDS().includes(uid);
|
|
382
|
+
}
|
|
383
|
+
getLeasee(content) {
|
|
384
|
+
return this.active[content];
|
|
385
|
+
}
|
|
386
|
+
hasLease(uid, content) {
|
|
387
|
+
return this.active[content] === uid;
|
|
388
|
+
}
|
|
389
|
+
isLeased(contentID) {
|
|
390
|
+
return contentID in this.active;
|
|
391
|
+
}
|
|
392
|
+
withLock(uid, content, lock) {
|
|
393
|
+
const newActive = Object.assign({}, this.active);
|
|
394
|
+
if (lock)
|
|
395
|
+
newActive[content] = uid;
|
|
396
|
+
else
|
|
397
|
+
delete newActive[content];
|
|
398
|
+
return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, newActive);
|
|
335
399
|
}
|
|
336
400
|
getBookReadingTime() {
|
|
337
401
|
return this.chapters
|
|
@@ -531,18 +595,23 @@ export default class Edition {
|
|
|
531
595
|
return (latestEditionID !== undefined &&
|
|
532
596
|
latestEditionID === this.editionRef?.id);
|
|
533
597
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
return undefined
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
598
|
+
getEditionNumber() {
|
|
599
|
+
return this.number;
|
|
600
|
+
}
|
|
601
|
+
getEditionLabel() {
|
|
602
|
+
const num = this.number;
|
|
603
|
+
return `${num}${num === 1 ? 'st' : num === 2 ? 'nd' : num === 3 ? 'rd' : ''}`;
|
|
604
|
+
}
|
|
605
|
+
getInfo() {
|
|
606
|
+
return this.editionRef === undefined
|
|
607
|
+
? undefined
|
|
608
|
+
: {
|
|
609
|
+
ref: this.editionRef,
|
|
610
|
+
summary: this.summary,
|
|
611
|
+
number: this.number,
|
|
612
|
+
published: this.published,
|
|
613
|
+
editionuids: this.uids,
|
|
614
|
+
chapteruids: Array.from(new Set(this.chapters.map((chapter) => chapter.uids).flat())),
|
|
615
|
+
};
|
|
547
616
|
}
|
|
548
617
|
}
|
|
@@ -31,7 +31,7 @@ export default class Parser {
|
|
|
31
31
|
static preprocessSymbols(book: Edition, text: string): string;
|
|
32
32
|
static parseChapter(book: Edition | undefined, text: string): ChapterNode;
|
|
33
33
|
static parseFormat(book: Edition | undefined, text: string): FormatNode;
|
|
34
|
-
static parseEmbed(book: Edition | undefined, text: string): EmbedNode
|
|
34
|
+
static parseEmbed(book: Edition | undefined, text: string): EmbedNode;
|
|
35
35
|
peek(): string | null;
|
|
36
36
|
more(): boolean;
|
|
37
37
|
nextIsEmptyParagraph(): boolean;
|
|
@@ -62,7 +62,7 @@ export default class Parser {
|
|
|
62
62
|
parseCallout(): CalloutNode;
|
|
63
63
|
parseTable(): TableNode;
|
|
64
64
|
parseFormat(awaiting?: string): FormatNode;
|
|
65
|
-
parseEmbed(): EmbedNode
|
|
65
|
+
parseEmbed(): EmbedNode;
|
|
66
66
|
parseComment(): CommentNode;
|
|
67
67
|
parseLabel(): LabelNode | ErrorNode;
|
|
68
68
|
parseStyle(awaiting: string): FormatNode | ErrorNode;
|
package/models/chapter/Parser.js
CHANGED
|
@@ -639,32 +639,34 @@ export default class Parser {
|
|
|
639
639
|
this.read();
|
|
640
640
|
// Read the URL
|
|
641
641
|
const url = this.readUntilNewlineOr('|');
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
this.
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
642
|
+
let description;
|
|
643
|
+
let caption;
|
|
644
|
+
let credit;
|
|
645
|
+
if (this.peek() === '|') {
|
|
646
|
+
// Read a |
|
|
647
|
+
this.read();
|
|
648
|
+
// Read the description
|
|
649
|
+
description = this.readUntilNewlineOr('|');
|
|
650
|
+
if (this.peek() === '|') {
|
|
651
|
+
// Read a |
|
|
652
|
+
this.read();
|
|
653
|
+
// Parse the caption
|
|
654
|
+
caption = this.parseFormat('|');
|
|
655
|
+
if (this.peek() === '|') {
|
|
656
|
+
// Read a |
|
|
657
|
+
this.read();
|
|
658
|
+
// Parse the credit
|
|
659
|
+
credit = this.parseFormat('|');
|
|
660
|
+
// Check for the closing delimeter
|
|
661
|
+
if (this.peek() === '|')
|
|
662
|
+
// Read a |
|
|
663
|
+
this.read();
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
665
667
|
// Is there a position indicator?
|
|
666
668
|
const position = this.parsePosition();
|
|
667
|
-
return new EmbedNode(url, description, caption, credit, position);
|
|
669
|
+
return new EmbedNode(url, description ?? '', caption, credit, position);
|
|
668
670
|
}
|
|
669
671
|
parseComment() {
|
|
670
672
|
// Consume the opening %
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bookish-press",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.25",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A platform for reading and writing readable, accessible, beautiful online books.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": "https://github.com/amyjko/bookish.git",
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@sveltejs/adapter-static": "^1.0.
|
|
11
|
-
"@sveltejs/kit": "^1.
|
|
12
|
-
"@sveltejs/package": "^1.0.
|
|
10
|
+
"@sveltejs/adapter-static": "^1.0.5",
|
|
11
|
+
"@sveltejs/kit": "^1.3.2",
|
|
12
|
+
"@sveltejs/package": "^1.0.2",
|
|
13
13
|
"@types/prismjs": "^1.26.0",
|
|
14
14
|
"@types/smoothscroll-polyfill": "^0.3.1",
|
|
15
15
|
"@types/uuid": "^9.0.0",
|
|
16
|
-
"prettier": "^2.8.
|
|
16
|
+
"prettier": "^2.8.3",
|
|
17
17
|
"prettier-plugin-svelte": "^2.9.0",
|
|
18
|
-
"svelte-check": "^3.0.
|
|
19
|
-
"svelte-preprocess": "^5.0.
|
|
20
|
-
"tslib": "^2.
|
|
18
|
+
"svelte-check": "^3.0.3",
|
|
19
|
+
"svelte-preprocess": "^5.0.1",
|
|
20
|
+
"tslib": "^2.5.0",
|
|
21
21
|
"typescript": "^4.9.4",
|
|
22
|
-
"vite": "^4.0.
|
|
23
|
-
"vitest": "^0.
|
|
22
|
+
"vite": "^4.0.4",
|
|
23
|
+
"vitest": "^0.28.3"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"ajv": "^8.
|
|
26
|
+
"ajv": "^8.12.0",
|
|
27
27
|
"ajv-formats": "^2.1.1",
|
|
28
28
|
"firebase": "latest",
|
|
29
|
-
"firebase-functions": "^4.
|
|
29
|
+
"firebase-functions": "^4.2.0",
|
|
30
30
|
"prismjs": "^1.29.0",
|
|
31
31
|
"smoothscroll-polyfill": "^0.4.4",
|
|
32
|
-
"svelte": "^3.55.
|
|
32
|
+
"svelte": "^3.55.1",
|
|
33
33
|
"uuid": "^9.0.0"
|
|
34
34
|
},
|
|
35
35
|
"types": "./src/lib/index.d.ts",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"./components/app/Link.svelte": "./components/app/Link.svelte",
|
|
50
50
|
"./components/app/Options.svelte": "./components/app/Options.svelte",
|
|
51
51
|
"./components/app/Paragraph.svelte": "./components/app/Paragraph.svelte",
|
|
52
|
+
"./components/app/Section.svelte": "./components/app/Section.svelte",
|
|
52
53
|
"./components/app/Table.svelte": "./components/app/Table.svelte",
|
|
53
54
|
"./components/app/TextInput.svelte": "./components/app/TextInput.svelte",
|
|
54
|
-
"./components/app/Writing.svelte": "./components/app/Writing.svelte",
|
|
55
55
|
"./components/chapter/Atom.svelte": "./components/chapter/Atom.svelte",
|
|
56
56
|
"./components/chapter/Block.svelte": "./components/chapter/Block.svelte",
|
|
57
57
|
"./components/chapter/Callout.svelte": "./components/chapter/Callout.svelte",
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
"./components/editor/LanguageEditor.svelte": "./components/editor/LanguageEditor.svelte",
|
|
103
103
|
"./components/editor/LinkEditor.svelte": "./components/editor/LinkEditor.svelte",
|
|
104
104
|
"./components/editor/Note.svelte": "./components/editor/Note.svelte",
|
|
105
|
+
"./components/editor/Permissions.svelte": "./components/editor/Permissions.svelte",
|
|
105
106
|
"./components/editor/PositionEditor.svelte": "./components/editor/PositionEditor.svelte",
|
|
106
107
|
"./components/editor/QuoteEditor.svelte": "./components/editor/QuoteEditor.svelte",
|
|
107
108
|
"./components/editor/Switch.svelte": "./components/editor/Switch.svelte",
|
|
@@ -163,6 +164,7 @@
|
|
|
163
164
|
"./components/editor/icons/unlink.svg": "./components/editor/icons/unlink.svg",
|
|
164
165
|
"./components/page/Acknowledgements.svelte": "./components/page/Acknowledgements.svelte",
|
|
165
166
|
"./components/page/Authors.svelte": "./components/page/Authors.svelte",
|
|
167
|
+
"./components/page/BookLoader.svelte": "./components/page/BookLoader.svelte",
|
|
166
168
|
"./components/page/BulkReferenceEditor.svelte": "./components/page/BulkReferenceEditor.svelte",
|
|
167
169
|
"./components/page/Chapter.svelte": "./components/page/Chapter.svelte",
|
|
168
170
|
"./components/page/ChapterContext": "./components/page/ChapterContext.js",
|
|
@@ -172,6 +174,7 @@
|
|
|
172
174
|
"./components/page/DefinitionView.svelte": "./components/page/DefinitionView.svelte",
|
|
173
175
|
"./components/page/Description.svelte": "./components/page/Description.svelte",
|
|
174
176
|
"./components/page/Edition.svelte": "./components/page/Edition.svelte",
|
|
177
|
+
"./components/page/EditionLoader.svelte": "./components/page/EditionLoader.svelte",
|
|
175
178
|
"./components/page/Editions.svelte": "./components/page/Editions.svelte",
|
|
176
179
|
"./components/page/Glossary.svelte": "./components/page/Glossary.svelte",
|
|
177
180
|
"./components/page/Header.svelte": "./components/page/Header.svelte",
|
|
@@ -189,6 +192,7 @@
|
|
|
189
192
|
"./components/page/PossibleChapter.svelte": "./components/page/PossibleChapter.svelte",
|
|
190
193
|
"./components/page/PossibleReference.svelte": "./components/page/PossibleReference.svelte",
|
|
191
194
|
"./components/page/Print.svelte": "./components/page/Print.svelte",
|
|
195
|
+
"./components/page/Publish.svelte": "./components/page/Publish.svelte",
|
|
192
196
|
"./components/page/Reference.svelte": "./components/page/Reference.svelte",
|
|
193
197
|
"./components/page/References.svelte": "./components/page/References.svelte",
|
|
194
198
|
"./components/page/Rows.svelte": "./components/page/Rows.svelte",
|
|
@@ -258,7 +262,6 @@
|
|
|
258
262
|
"./models/chapter/TableNode": "./models/chapter/TableNode.js",
|
|
259
263
|
"./models/chapter/TextNode.test": "./models/chapter/TextNode.test.js",
|
|
260
264
|
"./models/chapter/TextNode": "./models/chapter/TextNode.js",
|
|
261
|
-
"./models/loadEdition": "./models/loadEdition.js",
|
|
262
265
|
"./util/getSubdomain": "./util/getSubdomain.js",
|
|
263
266
|
"./util/isMobile": "./util/isMobile.js",
|
|
264
267
|
"./util/mineReference": "./util/mineReference.js",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} WritingProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} WritingEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} WritingSlots */
|
|
4
|
-
export default class Writing extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: never;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {
|
|
9
|
-
default: {};
|
|
10
|
-
}> {
|
|
11
|
-
}
|
|
12
|
-
export type WritingProps = typeof __propDef.props;
|
|
13
|
-
export type WritingEvents = typeof __propDef.events;
|
|
14
|
-
export type WritingSlots = typeof __propDef.slots;
|
|
15
|
-
import { SvelteComponentTyped } from "svelte";
|
|
16
|
-
declare const __propDef: {
|
|
17
|
-
props: {
|
|
18
|
-
[x: string]: never;
|
|
19
|
-
};
|
|
20
|
-
events: {
|
|
21
|
-
[evt: string]: CustomEvent<any>;
|
|
22
|
-
};
|
|
23
|
-
slots: {
|
|
24
|
-
default: {};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export {};
|
package/models/loadEdition.d.ts
DELETED
package/models/loadEdition.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { getBookFromIDOrName } from './CRUD';
|
|
2
|
-
export default async function loadEdition(bookIDOrName, editionID, latestPublished) {
|
|
3
|
-
const getEditionNumber = editionID === undefined ? undefined : parseInt(editionID);
|
|
4
|
-
const book = await getBookFromIDOrName(bookIDOrName);
|
|
5
|
-
if (book === null)
|
|
6
|
-
return null;
|
|
7
|
-
const unspecifiedEdition = getEditionNumber === undefined ||
|
|
8
|
-
isNaN(getEditionNumber) ||
|
|
9
|
-
!book.isValidEditionNumber(getEditionNumber);
|
|
10
|
-
const edition = unspecifiedEdition
|
|
11
|
-
? await (latestPublished
|
|
12
|
-
? book.getLatestPublishedEdition()
|
|
13
|
-
: book.getDraftEdition())
|
|
14
|
-
: await book.getEditionNumber(getEditionNumber);
|
|
15
|
-
return {
|
|
16
|
-
book: book,
|
|
17
|
-
edition: edition,
|
|
18
|
-
latest: unspecifiedEdition,
|
|
19
|
-
};
|
|
20
|
-
}
|