bookish-press 0.6.53 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/components/Auth.svelte.d.ts +2 -0
  2. package/dist/components/BookPreview.svelte.d.ts +3 -1
  3. package/dist/components/Link.svelte.d.ts +3 -1
  4. package/dist/components/app/BookList.svelte.d.ts +2 -0
  5. package/dist/components/app/Button.svelte.d.ts +2 -0
  6. package/dist/components/app/Feedback.svelte.d.ts +3 -1
  7. package/dist/components/app/Head.svelte.d.ts +3 -1
  8. package/dist/components/app/Large.svelte.d.ts +2 -0
  9. package/dist/components/app/Lead.svelte.d.ts +2 -0
  10. package/dist/components/app/Link.svelte.d.ts +3 -1
  11. package/dist/components/app/Options.svelte.d.ts +2 -0
  12. package/dist/components/app/Paragraph.svelte.d.ts +3 -1
  13. package/dist/components/app/Section.svelte.d.ts +2 -0
  14. package/dist/components/app/Table.svelte.d.ts +2 -0
  15. package/dist/components/app/TextInput.svelte.d.ts +5 -3
  16. package/dist/components/chapter/Atom.svelte.d.ts +2 -0
  17. package/dist/components/chapter/Block.svelte.d.ts +2 -0
  18. package/dist/components/chapter/Callout.svelte.d.ts +2 -0
  19. package/dist/components/chapter/CaptionedCode.svelte.d.ts +2 -0
  20. package/dist/components/chapter/ChapterBody.svelte.d.ts +4 -2
  21. package/dist/components/chapter/Citations.svelte.d.ts +2 -0
  22. package/dist/components/chapter/Code.svelte.d.ts +2 -0
  23. package/dist/components/chapter/Comment.svelte.d.ts +2 -0
  24. package/dist/components/chapter/Definition.svelte.d.ts +2 -0
  25. package/dist/components/chapter/Embed.svelte.d.ts +5 -3
  26. package/dist/components/chapter/ErrorMessage.svelte.d.ts +2 -0
  27. package/dist/components/chapter/Figure.svelte.d.ts +3 -1
  28. package/dist/components/chapter/Footnote.svelte.d.ts +2 -0
  29. package/dist/components/chapter/Format.svelte.d.ts +2 -0
  30. package/dist/components/chapter/InlineCode.svelte.d.ts +2 -0
  31. package/dist/components/chapter/Label.svelte.d.ts +2 -0
  32. package/dist/components/chapter/LineBreak.svelte.d.ts +2 -0
  33. package/dist/components/chapter/Link.svelte.d.ts +2 -0
  34. package/dist/components/chapter/List.svelte.d.ts +2 -0
  35. package/dist/components/chapter/Marginal.svelte.d.ts +2 -0
  36. package/dist/components/chapter/Paragraph.svelte.d.ts +2 -0
  37. package/dist/components/chapter/Positioned.svelte.d.ts +2 -0
  38. package/dist/components/chapter/Problem.svelte.d.ts +2 -0
  39. package/dist/components/chapter/Python.svelte.d.ts +2 -0
  40. package/dist/components/chapter/Quote.svelte.d.ts +2 -0
  41. package/dist/components/chapter/Rule.svelte.d.ts +2 -0
  42. package/dist/components/chapter/Table.svelte.d.ts +2 -0
  43. package/dist/components/chapter/Text.svelte.d.ts +2 -0
  44. package/dist/components/controls/DarkToggle.svelte.d.ts +2 -0
  45. package/dist/components/editor/BookishEditor.svelte.d.ts +4 -2
  46. package/dist/components/editor/CalloutEditor.svelte.d.ts +2 -0
  47. package/dist/components/editor/CaptionedCodeEditor.svelte.d.ts +2 -0
  48. package/dist/components/editor/CaretView.svelte.d.ts +2 -0
  49. package/dist/components/editor/CitationsEditor.svelte.d.ts +2 -0
  50. package/dist/components/editor/ConfirmButton.svelte.d.ts +2 -0
  51. package/dist/components/editor/DefinitionEditor.svelte.d.ts +2 -0
  52. package/dist/components/editor/EmbedEditor.svelte.d.ts +2 -0
  53. package/dist/components/editor/Icon.svelte.d.ts +2 -0
  54. package/dist/components/editor/ImageChooser.svelte.d.ts +2 -0
  55. package/dist/components/editor/ImageThumbnail.svelte.d.ts +2 -0
  56. package/dist/components/editor/InlineCodeEditor.svelte.d.ts +2 -0
  57. package/dist/components/editor/LabelEditor.svelte.d.ts +2 -0
  58. package/dist/components/editor/LanguageEditor.svelte.d.ts +2 -0
  59. package/dist/components/editor/LinkEditor.svelte.d.ts +2 -0
  60. package/dist/components/editor/Note.svelte.d.ts +2 -0
  61. package/dist/components/editor/Permissions.svelte.d.ts +2 -0
  62. package/dist/components/editor/PositionEditor.svelte.d.ts +2 -0
  63. package/dist/components/editor/QuoteEditor.svelte.d.ts +2 -0
  64. package/dist/components/editor/Switch.svelte.d.ts +2 -0
  65. package/dist/components/editor/TableEditor.svelte.d.ts +2 -0
  66. package/dist/components/editor/TextEditor.svelte +1 -0
  67. package/dist/components/editor/TextEditor.svelte.d.ts +4 -2
  68. package/dist/components/editor/Toggle.svelte.d.ts +2 -0
  69. package/dist/components/editor/Toolbar.svelte.d.ts +2 -0
  70. package/dist/components/editor/ToolbarGroup.svelte.d.ts +2 -0
  71. package/dist/components/editor/ToolbarSpacer.svelte.d.ts +2 -0
  72. package/dist/components/editor/URLEditor.svelte.d.ts +2 -0
  73. package/dist/components/page/Acknowledgements.svelte +12 -5
  74. package/dist/components/page/Acknowledgements.svelte.d.ts +2 -0
  75. package/dist/components/page/Analytics.svelte.d.ts +3 -1
  76. package/dist/components/page/Authors.svelte.d.ts +3 -1
  77. package/dist/components/page/BookLoader.svelte.d.ts +2 -0
  78. package/dist/components/page/BulkReferenceEditor.svelte.d.ts +2 -0
  79. package/dist/components/page/Chapter.svelte.d.ts +3 -1
  80. package/dist/components/page/ChapterNumber.svelte.d.ts +2 -0
  81. package/dist/components/page/ChapterTitle.svelte.d.ts +2 -0
  82. package/dist/components/page/DefinitionView.svelte.d.ts +2 -0
  83. package/dist/components/page/Description.svelte.d.ts +2 -0
  84. package/dist/components/page/EditableHeader.svelte +25 -0
  85. package/dist/components/page/EditableHeader.svelte.d.ts +20 -0
  86. package/dist/components/page/Edition.svelte.d.ts +3 -1
  87. package/dist/components/page/EditionLoader.svelte.d.ts +2 -0
  88. package/dist/components/page/Editions.svelte.d.ts +3 -1
  89. package/dist/components/page/Glossary.svelte +10 -4
  90. package/dist/components/page/Glossary.svelte.d.ts +2 -0
  91. package/dist/components/page/Header.svelte +1 -0
  92. package/dist/components/page/Header.svelte.d.ts +5 -3
  93. package/dist/components/page/Index.svelte +9 -5
  94. package/dist/components/page/Index.svelte.d.ts +2 -0
  95. package/dist/components/page/Instructions.svelte.d.ts +2 -0
  96. package/dist/components/page/License.svelte +3 -3
  97. package/dist/components/page/License.svelte.d.ts +2 -0
  98. package/dist/components/page/Loading.svelte.d.ts +2 -0
  99. package/dist/components/page/Media.svelte +6 -2
  100. package/dist/components/page/Media.svelte.d.ts +2 -0
  101. package/dist/components/page/MediaPreview.svelte.d.ts +2 -0
  102. package/dist/components/page/Muted.svelte.d.ts +2 -0
  103. package/dist/components/page/Outline.svelte.d.ts +3 -1
  104. package/dist/components/page/Page.svelte.d.ts +2 -0
  105. package/dist/components/page/PageHeader.svelte.d.ts +3 -1
  106. package/dist/components/page/PageParagraph.svelte.d.ts +2 -0
  107. package/dist/components/page/PossibleChapter.svelte.d.ts +2 -0
  108. package/dist/components/page/PossibleReference.svelte.d.ts +2 -0
  109. package/dist/components/page/Print.svelte.d.ts +2 -0
  110. package/dist/components/page/Publish.svelte.d.ts +2 -0
  111. package/dist/components/page/Reference.svelte.d.ts +3 -1
  112. package/dist/components/page/References.svelte +7 -1
  113. package/dist/components/page/References.svelte.d.ts +2 -0
  114. package/dist/components/page/Rows.svelte.d.ts +2 -0
  115. package/dist/components/page/Search.svelte +11 -5
  116. package/dist/components/page/Search.svelte.d.ts +2 -0
  117. package/dist/components/page/Status.svelte.d.ts +2 -0
  118. package/dist/components/page/SubdomainEditor.svelte.d.ts +2 -0
  119. package/dist/components/page/TableOfContents.svelte +9 -16
  120. package/dist/components/page/TableOfContents.svelte.d.ts +2 -0
  121. package/dist/components/page/TableOfContentsImage.svelte.d.ts +2 -0
  122. package/dist/components/page/TableOfContentsRow.svelte +25 -13
  123. package/dist/components/page/TableOfContentsRow.svelte.d.ts +6 -5
  124. package/dist/components/page/ThemeEditor.svelte.d.ts +2 -0
  125. package/dist/components/page/ThemeEditorPreview.svelte.d.ts +2 -0
  126. package/dist/components/page/ThemeSetEditor.svelte.d.ts +2 -0
  127. package/dist/components/page/ThemeVariableEditor.svelte.d.ts +2 -0
  128. package/dist/components/page/Title.svelte.d.ts +2 -0
  129. package/dist/components/page/Unknown.svelte +2 -2
  130. package/dist/components/page/Unknown.svelte.d.ts +2 -0
  131. package/dist/models/CRUD.js +3 -3
  132. package/dist/models/book/ChapterID.d.ts +3 -9
  133. package/dist/models/book/ChapterID.js +1 -1
  134. package/dist/models/book/Edition.d.ts +12 -4
  135. package/dist/models/book/Edition.js +56 -22
  136. package/dist/models/chapter/AtomNode.d.ts +2 -2
  137. package/dist/models/chapter/FormatNode.d.ts +5 -5
  138. package/dist/models/chapter/FormatNode.js +10 -5
  139. package/dist/models/chapter/MetadataNode.d.ts +3 -3
  140. package/package.json +22 -17
@@ -2,7 +2,7 @@ import Chapter from './Chapter';
2
2
  import Parser from '../chapter/Parser';
3
3
  import EmbedNode from '../chapter/EmbedNode';
4
4
  import Reference from './Reference';
5
- import ChapterIDs from './ChapterID.js';
5
+ import ChapterIDs, {} from './ChapterID.js';
6
6
  export default class Edition {
7
7
  bookRef;
8
8
  editionRef;
@@ -13,6 +13,7 @@ export default class Edition {
13
13
  summary;
14
14
  published;
15
15
  images;
16
+ headers;
16
17
  description;
17
18
  chapters;
18
19
  license;
@@ -28,7 +29,7 @@ export default class Edition {
28
29
  gtagid;
29
30
  // Given an object with a valid specification and an object mapping chapter IDs to chapter text,
30
31
  // construct an object representing a book.
31
- constructor(bookRef, editionRef, uids, title, authors, number, summary, published, images, description, chapters, license, acknowledgements, tags, sources, references, symbols, glossary, theme, base, active, gtagid) {
32
+ constructor(bookRef, editionRef, uids, title, authors, number, summary, published, images, headers, description, chapters, license, acknowledgements, tags, sources, references, symbols, glossary, theme, base, active, gtagid) {
32
33
  this.bookRef = bookRef;
33
34
  this.editionRef = editionRef;
34
35
  this.uids = uids;
@@ -38,6 +39,7 @@ export default class Edition {
38
39
  this.summary = summary;
39
40
  this.published = published;
40
41
  this.images = images;
42
+ this.headers = headers;
41
43
  this.description = description;
42
44
  this.chapters = chapters.slice();
43
45
  this.license = license;
@@ -61,7 +63,7 @@ export default class Edition {
61
63
  static fromJSON(editionRef, spec) {
62
64
  // Copy all of the specification metadata to fields.
63
65
  // Choose suitable defaults if the spec is lacking a field.
64
- 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.base, spec.active, spec.gtagid);
66
+ return new Edition(spec.bookRef, editionRef, spec.uids, spec.title, spec.authors, spec.number, spec.summary, spec.published, spec.images, spec.headers, 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.base, spec.active, spec.gtagid);
65
67
  }
66
68
  static parseReference(citationID, ref, edition, short = false) {
67
69
  if (typeof ref === 'string')
@@ -91,6 +93,7 @@ export default class Edition {
91
93
  summary: this.summary,
92
94
  published: this.published,
93
95
  images: Object.assign({}, this.images),
96
+ headers: Object.assign({}, this.headers),
94
97
  description: this.description,
95
98
  chapters: this.chapters.map((chap) => chap.toJSON()),
96
99
  license: this.license,
@@ -119,37 +122,37 @@ export default class Edition {
119
122
  return Array.from(new Set(this.chapters.map((chapter) => chapter.uids).flat()));
120
123
  }
121
124
  withRef(editionRef) {
122
- 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.base, this.active, this.gtagid);
125
+ return new Edition(this.bookRef, editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
123
126
  }
124
127
  getTitle() {
125
128
  return this.title;
126
129
  }
127
130
  withTitle(title) {
128
- 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.base, this.active, this.gtagid);
131
+ return new Edition(this.bookRef, this.editionRef, this.uids, title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
129
132
  }
130
133
  getDescription() {
131
134
  return this.description;
132
135
  }
133
136
  setDescription(description) {
134
- 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.base, this.active, this.gtagid);
137
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
135
138
  }
136
139
  getAcknowledgements() {
137
140
  return this.acknowledgements;
138
141
  }
139
142
  withAcknowledgements(acks) {
140
- 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.base, this.active, this.gtagid);
143
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, acks, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
141
144
  }
142
145
  withSummary(summary) {
143
- 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.base, this.active, this.gtagid);
146
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
144
147
  }
145
148
  asPublished(published) {
146
- 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.base, this.active, this.gtagid);
149
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, published ? Date.now() : null, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
147
150
  }
148
151
  getLicense() {
149
152
  return this.license;
150
153
  }
151
154
  setLicense(license) {
152
- 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.base, this.active, this.gtagid);
155
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
153
156
  }
154
157
  getChapters() {
155
158
  return this.chapters.slice();
@@ -175,7 +178,7 @@ export default class Edition {
175
178
  return this.chapters.length;
176
179
  }
177
180
  withChapters(chapters) {
178
- 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.base, this.active, this.gtagid);
181
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
179
182
  }
180
183
  withChapterText(textByID) {
181
184
  const newChapters = this.chapters.map((chapter) => {
@@ -216,7 +219,7 @@ export default class Edition {
216
219
  return this.withRef(undefined).withChapters(this.chapters.map((chap) => chap.withoutRef()));
217
220
  }
218
221
  withIncrementedEditionNumber() {
219
- 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.base, this.active, this.gtagid);
222
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number + 1, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
220
223
  }
221
224
  withNewChapter() {
222
225
  // Synthesize a chapter ID placeholder that doesn't overlap with existing chapter names
@@ -248,7 +251,7 @@ export default class Edition {
248
251
  const temp = newChapters[index + increment];
249
252
  newChapters[index + increment] = newChapters[index];
250
253
  newChapters[index] = temp;
251
- 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.base, this.active, this.gtagid);
254
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, newChapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
252
255
  }
253
256
  getSymbols() {
254
257
  return this.symbols;
@@ -265,7 +268,7 @@ export default class Edition {
265
268
  : undefined;
266
269
  }
267
270
  withReferences(newReferences) {
268
- 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.base, this.active, this.gtagid);
271
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, newReferences, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
269
272
  }
270
273
  withNewReferences(references) {
271
274
  const newReferences = Object.assign({}, this.references);
@@ -306,7 +309,7 @@ export default class Edition {
306
309
  return id in this.glossary;
307
310
  }
308
311
  withGlossary(glossary) {
309
- 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.base, this.active, this.gtagid);
312
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, glossary, this.theme, this.base, this.active, this.gtagid);
310
313
  }
311
314
  withDefinition(id, phrase, definition, synonyms) {
312
315
  const newGlossary = Object.assign({}, this.glossary);
@@ -343,7 +346,7 @@ export default class Edition {
343
346
  return this.theme;
344
347
  }
345
348
  withTheme(theme) {
346
- 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.base, this.active, this.gtagid);
349
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, theme, this.base, this.active, this.gtagid);
347
350
  }
348
351
  withThemeValue(group, name, value) {
349
352
  if (this.theme === null)
@@ -370,7 +373,7 @@ export default class Edition {
370
373
  .join(', ');
371
374
  }
372
375
  withAuthors(authors) {
373
- 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.base, this.active, this.gtagid);
376
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
374
377
  }
375
378
  withAuthor(name) {
376
379
  return this.withAuthors([...this.authors, name]);
@@ -393,7 +396,7 @@ export default class Edition {
393
396
  ]);
394
397
  }
395
398
  withEditors(uids) {
396
- 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.base, this.active, this.gtagid);
399
+ return new Edition(this.bookRef, this.editionRef, uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
397
400
  }
398
401
  hasImage(id) {
399
402
  return this.images[id] !== null;
@@ -404,7 +407,7 @@ export default class Edition {
404
407
  withImage(id, embed) {
405
408
  const newImages = Object.assign({}, this.images);
406
409
  newImages[id] = embed;
407
- 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.base, this.active, this.gtagid);
410
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, newImages, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
408
411
  }
409
412
  isEditor(uid) {
410
413
  return this.uids.includes(uid);
@@ -427,10 +430,10 @@ export default class Edition {
427
430
  newActive[content] = uid;
428
431
  else
429
432
  delete newActive[content];
430
- 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, this.base, newActive, this.gtagid);
433
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, newActive, this.gtagid);
431
434
  }
432
435
  withGTag(gtagid) {
433
- 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, this.base, this.active, gtagid);
436
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, this.headers, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, gtagid);
434
437
  }
435
438
  getBookReadingTime() {
436
439
  return this.chapters
@@ -609,7 +612,13 @@ export default class Edition {
609
612
  bodyEmbeds.forEach((embed) => embeds.push({ embed, chapterID: c.id }));
610
613
  });
611
614
  // Add the back matter covers
612
- let backmatter = ['references', 'glossary', 'index', 'search', 'media'];
615
+ let backmatter = [
616
+ 'references',
617
+ 'glossary',
618
+ 'index',
619
+ 'search',
620
+ 'media',
621
+ ];
613
622
  backmatter.forEach((id) => {
614
623
  const img = this.getImage(id);
615
624
  if (img) {
@@ -630,6 +639,31 @@ export default class Edition {
630
639
  return (latestEditionID !== undefined &&
631
640
  latestEditionID === this.editionRef?.id);
632
641
  }
642
+ /** Get the custom header, if there is one */
643
+ getHeader(id) {
644
+ const header = this.headers ? this.headers[id] : undefined;
645
+ if (header)
646
+ return header;
647
+ return {
648
+ references: 'References',
649
+ glossary: 'Glossary',
650
+ index: 'Index',
651
+ search: 'Search',
652
+ media: 'Media',
653
+ unknown: 'Oops...',
654
+ acknowledgements: 'Acknowledgements',
655
+ license: 'License',
656
+ print: 'Print',
657
+ citation: 'Citation',
658
+ chapters: 'Chapters',
659
+ cover: 'Cover',
660
+ }[id];
661
+ }
662
+ withHeader(id, header) {
663
+ const newHeaders = Object.assign({}, this.headers);
664
+ newHeaders[id] = header;
665
+ return new Edition(this.bookRef, this.editionRef, this.uids, this.title, this.authors, this.number, this.summary, this.published, this.images, { ...newHeaders }, this.description, this.chapters, this.license, this.acknowledgements, this.tags, this.sources, this.references, this.symbols, this.glossary, this.theme, this.base, this.active, this.gtagid);
666
+ }
633
667
  getEditionNumber() {
634
668
  return this.number;
635
669
  }
@@ -2,7 +2,7 @@ import type Caret from './Caret';
2
2
  import FormatNode from './FormatNode';
3
3
  import Node from './Node';
4
4
  import type RootNode from './RootNode';
5
- export default abstract class AtomNode<MetadataType> extends Node {
5
+ export default abstract class AtomNode<MetadataType = any> extends Node {
6
6
  #private;
7
7
  constructor(meta: MetadataType);
8
8
  getMeta(): MetadataType;
@@ -14,5 +14,5 @@ export default abstract class AtomNode<MetadataType> extends Node {
14
14
  getCaretPositionCount(): number;
15
15
  abstract toBookdown(format?: FormatNode): string;
16
16
  abstract toText(): string;
17
- abstract withMeta(meta: MetadataType): AtomNode<MetadataType>;
17
+ abstract withMeta(meta: MetadataType): AtomNode;
18
18
  }
@@ -8,7 +8,7 @@ import AtomNode from './AtomNode';
8
8
  import type Edit from './Edit';
9
9
  import LineBreakNode from './LineBreakNode';
10
10
  export type Format = '' | '*' | '_' | '^' | 'v';
11
- export type FormatNodeSegmentType = FormatNode | TextNode | LineBreakNode | ErrorNode | MetadataNode<any> | AtomNode<any>;
11
+ export type FormatNodeSegmentType = FormatNode | TextNode | LineBreakNode | ErrorNode | MetadataNode | AtomNode;
12
12
  export default class FormatNode extends Node {
13
13
  #private;
14
14
  constructor(format: Format, segments: FormatNodeSegmentType[]);
@@ -27,10 +27,10 @@ export default class FormatNode extends Node {
27
27
  getLastTextNode(): TextNode;
28
28
  copy(): this;
29
29
  getTextNodes(): TextNode[];
30
- getTextAndAtomNodes(): (TextNode | AtomNode<any>)[];
31
- getAdjacentTextOrAtom(node: TextNode | AtomNode<any>, next: boolean): TextNode | AtomNode<any> | undefined;
32
- getNextTextOrAtom(node: TextNode | AtomNode<any>): TextNode | AtomNode<any> | undefined;
33
- getPreviousTextOrAtom(node: TextNode | AtomNode<any>): TextNode | AtomNode<any> | undefined;
30
+ getTextAndAtomNodes(): (TextNode | AtomNode)[];
31
+ getAdjacentTextOrAtom(node: TextNode | AtomNode, next: boolean): TextNode | AtomNode | undefined;
32
+ getNextTextOrAtom(node: TextNode | AtomNode): TextNode | AtomNode | undefined;
33
+ getPreviousTextOrAtom(node: TextNode | AtomNode): TextNode | AtomNode | undefined;
34
34
  getAdjacentCaret(caret: Caret, next: boolean): Caret | undefined;
35
35
  getFirstCaret(): Caret | undefined;
36
36
  getLastCaret(): Caret | undefined;
@@ -409,7 +409,7 @@ export default class FormatNode extends Node {
409
409
  // and if we're in the selected range, adjust them accordingly based on the current formats
410
410
  // and the requested format. (If this is a range deletion, then we just stick with the existing formats).
411
411
  let formatter = node.getFormat(this);
412
- let desiredFormats = formatter
412
+ const desiredFormats = formatter
413
413
  ? formatter.getFormats(this)
414
414
  : [];
415
415
  if (format !== undefined &&
@@ -418,7 +418,7 @@ export default class FormatNode extends Node {
418
418
  inRange())) {
419
419
  // Remove all formatting if we were asked to.
420
420
  if (format === '')
421
- desiredFormats = [];
421
+ desiredFormats.length = 0;
422
422
  // Apply the formatting if it's not already applied.
423
423
  else if (!alreadyApplied &&
424
424
  !desiredFormats.includes(format))
@@ -461,7 +461,8 @@ export default class FormatNode extends Node {
461
461
  desiredFormats.forEach((desiredFormat) => {
462
462
  // If the current format does not yet include the desired format,
463
463
  // close the text node and start a new format.
464
- if (!getFormats().includes(desiredFormat)) {
464
+ if (desiredFormat !== '' &&
465
+ !getFormats().includes(desiredFormat)) {
465
466
  // Save any text that we've accumulated in the curent format.
466
467
  saveText();
467
468
  // Add a new format onto the stack to start adding to.
@@ -768,11 +769,15 @@ export default class FormatNode extends Node {
768
769
  ? node.getLastCaret()
769
770
  : // Line break? Place the caret just after the line break, whether a text node or something else
770
771
  node instanceof LineBreakNode
771
- ? segmentAfter !== undefined && segmentAfter instanceof TextNode
772
+ ? segmentAfter !== undefined &&
773
+ segmentAfter instanceof TextNode
772
774
  ? { node: segmentAfter, index: 0 }
773
775
  : undefined
774
776
  : node instanceof MetadataNode
775
- ? { node: node.getText(), index: node.getText().getLength() }
777
+ ? {
778
+ node: node.getText(),
779
+ index: node.getText().getLength(),
780
+ }
776
781
  : { node: node, index: node.getLength() };
777
782
  if (newCaret === undefined)
778
783
  return;
@@ -1,13 +1,13 @@
1
1
  import type { CaretRange } from './Caret';
2
2
  import Node from './Node';
3
3
  import type TextNode from './TextNode';
4
- export default abstract class MetadataNode<MetaType> extends Node {
4
+ export default abstract class MetadataNode<MetaType = any> extends Node {
5
5
  #private;
6
6
  constructor(text: TextNode, meta: MetaType);
7
7
  getMeta(): MetaType;
8
8
  getText(): TextNode;
9
- abstract withMeta(meta: MetaType): MetadataNode<MetaType>;
10
- abstract withText(text: TextNode): MetadataNode<MetaType>;
9
+ abstract withMeta(meta: MetaType): MetadataNode;
10
+ abstract withText(text: TextNode): MetadataNode;
11
11
  abstract toText(): string;
12
12
  abstract toBookdown(): string;
13
13
  getChildren(): TextNode[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bookish-press",
3
3
  "private": false,
4
- "version": "0.6.53",
4
+ "version": "0.7.0",
5
5
  "type": "module",
6
6
  "description": "A platform for reading and writing readable, accessible, beautiful online books.",
7
7
  "license": "MIT",
@@ -27,33 +27,38 @@
27
27
  "merge": "git checkout main && git merge dev && git push origin main && git checkout dev"
28
28
  },
29
29
  "devDependencies": {
30
- "@sveltejs/adapter-auto": "^3.0.0",
31
- "@sveltejs/adapter-static": "^3.0.0",
32
- "@sveltejs/kit": "^2.0.0",
33
- "@sveltejs/package": "^2.2",
34
- "@sveltejs/vite-plugin-svelte": "^3.0.0",
30
+ "@sveltejs/adapter-auto": "^3",
31
+ "@sveltejs/adapter-static": "^3",
32
+ "@sveltejs/kit": "^2",
33
+ "@sveltejs/package": "^2",
34
+ "@sveltejs/vite-plugin-svelte": "^3",
35
35
  "@types/prismjs": "^1.26",
36
36
  "@types/smoothscroll-polyfill": "^0",
37
- "@types/uuid": "^9.0",
37
+ "chalk": "^5.3.0",
38
+ "globals": "^16",
38
39
  "prettier": "^3",
39
40
  "prettier-plugin-svelte": "^3",
40
- "svelte-check": "^3.6",
41
- "svelte-preprocess": "^5.1",
41
+ "svelte-check": "^3",
42
+ "svelte-preprocess": "^5",
42
43
  "tslib": "^2",
43
44
  "typescript": "^5",
44
- "vite": "^5.0.0",
45
- "vitest": "^1.0.0"
45
+ "uuid": "^11.1.0",
46
+ "vite": "^5",
47
+ "vitest": "^3"
46
48
  },
47
49
  "dependencies": {
48
- "@sveltejs/kit": "^2.0.0",
50
+ "@sveltejs/kit": "^2",
49
51
  "ajv": "^8",
50
- "ajv-formats": "^2",
51
- "firebase": "^10.8.1",
52
- "firebase-functions": "latest",
52
+ "ajv-formats": "^3",
53
+ "firebase": "^11",
54
+ "firebase-admin": "^13.2.0",
55
+ "firebase-functions": "^6.3.2",
53
56
  "prismjs": "^1.29",
54
57
  "smoothscroll-polyfill": "^0.4",
55
- "svelte": "^4.2",
56
- "uuid": "^9.0"
58
+ "svelte": "^4"
59
+ },
60
+ "engines": {
61
+ "node": "20"
57
62
  },
58
63
  "types": "./dist/index.d.ts",
59
64
  "main": "./dist/index.js",