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
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type MediaProps = typeof __propDef.props;
10
12
  export type MediaEvents = typeof __propDef.events;
@@ -11,6 +11,8 @@ declare const __propDef: {
11
11
  slots: {
12
12
  default: {};
13
13
  };
14
+ exports?: {} | undefined;
15
+ bindings?: string | undefined;
14
16
  };
15
17
  export type MediaPreviewProps = typeof __propDef.props;
16
18
  export type MediaPreviewEvents = typeof __propDef.events;
@@ -23,5 +23,7 @@ declare const __propDef: {
23
23
  slots: {
24
24
  default: {};
25
25
  };
26
+ exports?: undefined;
27
+ bindings?: undefined;
26
28
  };
27
29
  export {};
@@ -3,13 +3,15 @@ declare const __propDef: {
3
3
  props: {
4
4
  previous: string | null;
5
5
  next: string | null;
6
- collapse?: boolean | undefined;
6
+ collapse?: boolean;
7
7
  listener?: ((expanded: boolean, layout: Function) => void) | undefined;
8
8
  };
9
9
  events: {
10
10
  [evt: string]: CustomEvent<any>;
11
11
  };
12
12
  slots: {};
13
+ exports?: {} | undefined;
14
+ bindings?: string | undefined;
13
15
  };
14
16
  export type OutlineProps = typeof __propDef.props;
15
17
  export type OutlineEvents = typeof __propDef.events;
@@ -10,6 +10,8 @@ declare const __propDef: {
10
10
  slots: {
11
11
  default: {};
12
12
  };
13
+ exports?: {} | undefined;
14
+ bindings?: string | undefined;
13
15
  };
14
16
  export type PageProps = typeof __propDef.props;
15
17
  export type PageEvents = typeof __propDef.events;
@@ -1,7 +1,7 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- id?: string | null | undefined;
4
+ id?: string | null;
5
5
  };
6
6
  events: {
7
7
  [evt: string]: CustomEvent<any>;
@@ -9,6 +9,8 @@ declare const __propDef: {
9
9
  slots: {
10
10
  default: {};
11
11
  };
12
+ exports?: {} | undefined;
13
+ bindings?: string | undefined;
12
14
  };
13
15
  export type PageHeaderProps = typeof __propDef.props;
14
16
  export type PageHeaderEvents = typeof __propDef.events;
@@ -23,5 +23,7 @@ declare const __propDef: {
23
23
  slots: {
24
24
  default: {};
25
25
  };
26
+ exports?: undefined;
27
+ bindings?: undefined;
26
28
  };
27
29
  export {};
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type PossibleChapterProps = typeof __propDef.props;
10
12
  export type PossibleChapterEvents = typeof __propDef.events;
@@ -10,6 +10,8 @@ declare const __propDef: {
10
10
  [evt: string]: CustomEvent<any>;
11
11
  };
12
12
  slots: {};
13
+ exports?: {} | undefined;
14
+ bindings?: string | undefined;
13
15
  };
14
16
  export type PossibleReferenceProps = typeof __propDef.props;
15
17
  export type PossibleReferenceEvents = typeof __propDef.events;
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type PrintProps = typeof __propDef.props;
10
12
  export type PrintEvents = typeof __propDef.events;
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type PublishProps = typeof __propDef.props;
10
12
  export type PublishEvents = typeof __propDef.events;
@@ -3,12 +3,14 @@ import Reference from '../../models/book/Reference';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  reference: Reference;
6
- edit?: boolean | undefined;
6
+ edit?: boolean;
7
7
  };
8
8
  events: {
9
9
  [evt: string]: CustomEvent<any>;
10
10
  };
11
11
  slots: {};
12
+ exports?: {} | undefined;
13
+ bindings?: string | undefined;
12
14
  };
13
15
  export type ReferenceProps = typeof __propDef.props;
14
16
  export type ReferenceEvents = typeof __propDef.events;
@@ -30,8 +30,14 @@ if (references !== null) {
30
30
  $edition.withImage(ChapterIDs.ReferencesID, embed),
31
31
  )
32
32
  : undefined}
33
- header="References"
33
+ header={$edition.getHeader(ChapterIDs.ReferencesID)}
34
34
  tags={$edition.getTags()}
35
+ save={(text) =>
36
+ $edition
37
+ ? edition.set(
38
+ $edition.withHeader(ChapterIDs.ReferencesID, text),
39
+ )
40
+ : undefined}
35
41
  >
36
42
  <Outline
37
43
  slot="outline"
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type ReferencesProps = typeof __propDef.props;
10
12
  export type ReferencesEvents = typeof __propDef.events;
@@ -23,5 +23,7 @@ declare const __propDef: {
23
23
  slots: {
24
24
  default: {};
25
25
  };
26
+ exports?: undefined;
27
+ bindings?: undefined;
26
28
  };
27
29
  export {};
@@ -66,18 +66,24 @@ $: {
66
66
  setImage={(embed) =>
67
67
  $edition
68
68
  ? edition.set(
69
- $edition.withImage(ChapterIDs.SearchID, embed)
69
+ $edition.withImage(ChapterIDs.SearchID, embed),
70
70
  )
71
71
  : undefined}
72
- header="Search"
72
+ header={$edition.getHeader(ChapterIDs.SearchID)}
73
73
  id="search"
74
74
  tags={$edition.getTags()}
75
+ save={(text) =>
76
+ $edition
77
+ ? edition.set(
78
+ $edition.withHeader(ChapterIDs.SearchID, text),
79
+ )
80
+ : undefined}
75
81
  >
76
82
  <Outline
77
83
  slot="outline"
78
84
  previous={$edition.getPreviousChapterID(
79
85
  ChapterIDs.SearchID,
80
- false
86
+ false,
81
87
  )}
82
88
  next={$edition.getNextChapterID(ChapterIDs.SearchID, false)}
83
89
  />
@@ -103,7 +109,7 @@ $: {
103
109
  {:else}
104
110
  <p
105
111
  >Found {results.filter(
106
- (result) => !(result instanceof Chapter)
112
+ (result) => !(result instanceof Chapter),
107
113
  ).length} occurrences of <em>{query}</em>...</p
108
114
  >
109
115
  {#each results as result}
@@ -111,7 +117,7 @@ $: {
111
117
  <PageHeader id={'header-' + result.getID()}
112
118
  ><ChapterNumber
113
119
  >Chapter{#if $edition.getChapterNumber(result.getID()) !== undefined}&nbsp;{$edition.getChapterNumber(
114
- result.getID()
120
+ result.getID(),
115
121
  )}{/if}</ChapterNumber
116
122
  > - <ChapterTitle>{result.getTitle()}</ChapterTitle
117
123
  ></PageHeader
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type SearchProps = typeof __propDef.props;
10
12
  export type SearchEvents = typeof __propDef.events;
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type StatusProps = typeof __propDef.props;
10
12
  export type StatusEvents = typeof __propDef.events;
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type SubdomainEditorProps = typeof __propDef.props;
10
12
  export type SubdomainEditorEvents = typeof __propDef.events;
@@ -23,6 +23,7 @@ import Permissions from '../editor/Permissions.svelte';
23
23
  import Publish from './Publish.svelte';
24
24
  import { onMount } from 'svelte';
25
25
  import Editions from './Editions.svelte';
26
+ import EditableHeader from './EditableHeader.svelte';
26
27
  let auth = getUser();
27
28
  let book = getBook();
28
29
  let edition = getEdition();
@@ -176,9 +177,7 @@ onMount(() => {
176
177
 
177
178
  <TableOfContentsRow
178
179
  {chapter}
179
- {chapterID}
180
180
  number={$edition.getChapterNumber(chapterID)}
181
- title={chapter.getTitle()}
182
181
  forthcoming={chapter.isForthcoming()}
183
182
  >
184
183
  <span slot="annotation">
@@ -222,33 +221,27 @@ onMount(() => {
222
221
  </TableOfContentsRow>
223
222
  {/each}
224
223
  {#if $edition.hasReferences() || editable}
225
- <TableOfContentsRow
226
- chapterID={ChapterIDs.ReferencesID}
227
- title="References"
228
- >
224
+ <TableOfContentsRow chapter={ChapterIDs.ReferencesID}>
229
225
  <span slot="annotation">Everything cited</span>
230
226
  </TableOfContentsRow>
231
227
  {/if}
232
228
  {#if ($edition.getGlossary() && Object.keys($edition.getGlossary()).length > 0) || editable}
233
- <TableOfContentsRow
234
- chapterID={ChapterIDs.GlossaryID}
235
- title="Glossary"
236
- >
229
+ <TableOfContentsRow chapter={ChapterIDs.GlossaryID}>
237
230
  <span slot="annotation">Definitions</span>
238
231
  </TableOfContentsRow>
239
232
  {/if}
240
- <TableOfContentsRow chapterID={ChapterIDs.IndexID} title="Index">
233
+ <TableOfContentsRow chapter={ChapterIDs.IndexID}>
241
234
  <span slot="annotation">Common words and where they are</span>
242
235
  </TableOfContentsRow>
243
- <TableOfContentsRow chapterID={ChapterIDs.SearchID} title="Search">
236
+ <TableOfContentsRow chapter={ChapterIDs.SearchID}>
244
237
  <span slot="annotation">Find where words occur</span>
245
238
  </TableOfContentsRow>
246
239
 
247
- <TableOfContentsRow chapterID={ChapterIDs.MediaID} title="Media">
240
+ <TableOfContentsRow chapter={ChapterIDs.MediaID}>
248
241
  <span slot="annotation">Images and video in the book</span>
249
242
  </TableOfContentsRow>
250
243
  {#if editable}
251
- <TableOfContentsRow chapterID="unknown" title="Unknown">
244
+ <TableOfContentsRow chapter={ChapterIDs.UnknownID}>
252
245
  <span slot="annotation">Customize bad links</span>
253
246
  </TableOfContentsRow>
254
247
  {/if}
@@ -257,7 +250,7 @@ onMount(() => {
257
250
  <Acknowledgements />
258
251
  <License />
259
252
 
260
- <PageHeader id="print">Print</PageHeader>
253
+ <EditableHeader id="print" label="Edit print header" />
261
254
 
262
255
  <Instructions {editable}>
263
256
  This link will generate the entire book on a single page, suitable
@@ -270,7 +263,7 @@ onMount(() => {
270
263
  > and then print or export. Long books can take some time to render.
271
264
  </PageParagraph>
272
265
 
273
- <PageHeader id="citation">Citation</PageHeader>
266
+ <EditableHeader id="citation" label="Edit citation header" />
274
267
 
275
268
  <Instructions {editable}>
276
269
  This citation is created from the current authors, title, and date.
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type TableOfContentsProps = typeof __propDef.props;
10
12
  export type TableOfContentsEvents = typeof __propDef.events;
@@ -8,6 +8,8 @@ declare const __propDef: {
8
8
  [evt: string]: CustomEvent<any>;
9
9
  };
10
10
  slots: {};
11
+ exports?: {} | undefined;
12
+ bindings?: string | undefined;
11
13
  };
12
14
  export type TableOfContentsImageProps = typeof __propDef.props;
13
15
  export type TableOfContentsImageEvents = typeof __propDef.events;
@@ -1,4 +1,5 @@
1
1
  <script>import TableOfContentsImage from './TableOfContentsImage.svelte';
2
+ import Chapter from '../../models/book/Chapter';
2
3
  import Toggle from '../editor/Toggle.svelte';
3
4
  import ConfirmButton from '../editor/ConfirmButton.svelte';
4
5
  import { getBase, getEdition, isEditionEditable, setChapter, } from './Contexts';
@@ -7,32 +8,43 @@ import ChapterNumber from './ChapterNumber.svelte';
7
8
  import Button from '../app/Button.svelte';
8
9
  import ChapterTitle from './ChapterTitle.svelte';
9
10
  import Authors from './Authors.svelte';
10
- export let chapterID;
11
- export let chapter = undefined;
12
- export let title;
11
+ /** Either the chapter or a built in chapter ID */
12
+ export let chapter;
13
13
  export let number = undefined;
14
14
  export let forthcoming = false;
15
15
  let edition = getEdition();
16
16
  let base = getBase();
17
17
  let editable = isEditionEditable();
18
+ $: title =
19
+ chapter instanceof Chapter
20
+ ? chapter.getTitle()
21
+ : $edition
22
+ ? $edition.getHeader(chapter)
23
+ : '—';
18
24
  function moveUp() {
19
- if ($edition && chapter)
20
- edition.set($edition.withMovedChapter(chapter.getID(), -1));
25
+ if ($edition && chapter instanceof Chapter)
26
+ edition.set($edition.withMovedChapter(getChapterID(), -1));
21
27
  }
22
28
  function moveDown() {
23
- if ($edition && chapter)
24
- edition.set($edition.withMovedChapter(chapter.getID(), 1));
29
+ if ($edition && chapter instanceof Chapter)
30
+ edition.set($edition.withMovedChapter(getChapterID(), 1));
31
+ }
32
+ function getChapterID() {
33
+ if (chapter instanceof Chapter)
34
+ return chapter.getID();
35
+ else
36
+ return chapter;
25
37
  }
26
38
  $: chapterURL =
27
- forthcoming && !editable ? undefined : `${$base}/${chapterID}`;
39
+ forthcoming && !editable ? undefined : `${$base}/${getChapterID()}`;
28
40
  </script>
29
41
 
30
42
  <tr class="toc-row" class:forthcoming>
31
43
  <td
32
44
  ><TableOfContentsImage
33
- embed={chapter
45
+ embed={chapter instanceof Chapter
34
46
  ? chapter.getImage()
35
- : $edition?.getImage(chapterID) ?? null}
47
+ : ($edition?.getImage(chapter) ?? null)}
36
48
  url={chapterURL}
37
49
  /></td
38
50
  >
@@ -41,7 +53,7 @@ $: chapterURL =
41
53
  <Toggle
42
54
  on={number !== undefined}
43
55
  save={(on) =>
44
- chapter
56
+ chapter instanceof Chapter
45
57
  ? setChapter(edition, chapter, chapter.asNumbered(on))
46
58
  : undefined}
47
59
  >
@@ -57,7 +69,7 @@ $: chapterURL =
57
69
  <ChapterNumber>{'Chapter ' + number}</ChapterNumber>
58
70
  {/if}
59
71
  <ChapterTitle link={chapterURL}>{title}</ChapterTitle>
60
- {#if chapter && chapter.getAuthors().length > 0}
72
+ {#if chapter instanceof Chapter && chapter.getAuthors().length > 0}
61
73
  <Authors
62
74
  editable={false}
63
75
  authors={chapter.getAuthors()}
@@ -70,7 +82,7 @@ $: chapterURL =
70
82
  <td><slot name="etc" /></td>
71
83
  {#if editable && $edition}
72
84
  <td class="controls">
73
- {#if chapter}
85
+ {#if chapter instanceof Chapter}
74
86
  <Button
75
87
  tooltip="move chapter {title} up"
76
88
  disabled={$edition.getChapterPosition(chapter.getID()) ===
@@ -1,12 +1,11 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import type Chapter from '../../models/book/Chapter';
2
+ import Chapter from '../../models/book/Chapter';
3
+ import type { ChapterIDKey } from '../../models/book/ChapterID';
3
4
  declare const __propDef: {
4
5
  props: {
5
- chapterID: string;
6
- chapter?: Chapter | undefined;
7
- title: string;
6
+ /** Either the chapter or a built in chapter ID */ chapter: Chapter | ChapterIDKey;
8
7
  number?: number | undefined;
9
- forthcoming?: boolean | undefined;
8
+ forthcoming?: boolean;
10
9
  };
11
10
  events: {
12
11
  [evt: string]: CustomEvent<any>;
@@ -15,6 +14,8 @@ declare const __propDef: {
15
14
  annotation: {};
16
15
  etc: {};
17
16
  };
17
+ exports?: {} | undefined;
18
+ bindings?: string | undefined;
18
19
  };
19
20
  export type TableOfContentsRowProps = typeof __propDef.props;
20
21
  export type TableOfContentsRowEvents = typeof __propDef.events;
@@ -5,6 +5,8 @@ declare const __propDef: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
+ exports?: {} | undefined;
9
+ bindings?: string | undefined;
8
10
  };
9
11
  export type ThemeEditorProps = typeof __propDef.props;
10
12
  export type ThemeEditorEvents = typeof __propDef.events;
@@ -8,6 +8,8 @@ declare const __propDef: {
8
8
  [evt: string]: CustomEvent<any>;
9
9
  };
10
10
  slots: {};
11
+ exports?: {} | undefined;
12
+ bindings?: string | undefined;
11
13
  };
12
14
  export type ThemeEditorPreviewProps = typeof __propDef.props;
13
15
  export type ThemeEditorPreviewEvents = typeof __propDef.events;
@@ -9,6 +9,8 @@ declare const __propDef: {
9
9
  [evt: string]: CustomEvent<any>;
10
10
  };
11
11
  slots: {};
12
+ exports?: {} | undefined;
13
+ bindings?: string | undefined;
12
14
  };
13
15
  export type ThemeSetEditorProps = typeof __propDef.props;
14
16
  export type ThemeSetEditorEvents = typeof __propDef.events;
@@ -9,6 +9,8 @@ declare const __propDef: {
9
9
  [evt: string]: CustomEvent<any>;
10
10
  };
11
11
  slots: {};
12
+ exports?: {} | undefined;
13
+ bindings?: string | undefined;
12
14
  };
13
15
  export type ThemeVariableEditorProps = typeof __propDef.props;
14
16
  export type ThemeVariableEditorEvents = typeof __propDef.events;
@@ -23,5 +23,7 @@ declare const __propDef: {
23
23
  slots: {
24
24
  default: {};
25
25
  };
26
+ exports?: undefined;
27
+ bindings?: undefined;
26
28
  };
27
29
  export {};
@@ -18,10 +18,10 @@ let edition = getEdition();
18
18
  setImage={(embed) =>
19
19
  $edition
20
20
  ? edition.set(
21
- $edition.withImage(ChapterIDs.UnknownID, embed)
21
+ $edition.withImage(ChapterIDs.UnknownID, embed),
22
22
  )
23
23
  : undefined}
24
- header="Oops."
24
+ header={$edition.getHeader(ChapterIDs.UnknownID)}
25
25
  >
26
26
  <Outline slot="outline" previous={null} next={null} />
27
27
  </Header>
@@ -7,6 +7,8 @@ declare const __propDef: {
7
7
  slots: {
8
8
  default: {};
9
9
  };
10
+ exports?: {} | undefined;
11
+ bindings?: string | undefined;
10
12
  };
11
13
  export type UnknownProps = typeof __propDef.props;
12
14
  export type UnknownEvents = typeof __propDef.events;
@@ -78,7 +78,7 @@ export function listenToChapters(bookID, editionID, react) {
78
78
  export async function getUserEmails(uids) {
79
79
  if (!functions)
80
80
  throw Error("Can't publish, no connection to Firebase functions.");
81
- const getUserEmails = httpsCallable(functions, 'getUserEmails');
81
+ const getUserEmails = httpsCallable(functions, 'getUserEmailsGen2');
82
82
  const result = await getUserEmails({
83
83
  uids,
84
84
  });
@@ -87,7 +87,7 @@ export async function getUserEmails(uids) {
87
87
  export async function createUser(email) {
88
88
  if (!functions)
89
89
  throw Error("Can't publish, no connection to Firebase functions.");
90
- const createUserWithEmail = httpsCallable(functions, 'createUserWithEmail');
90
+ const createUserWithEmail = httpsCallable(functions, 'createUserWithEmailGen2');
91
91
  const result = await createUserWithEmail({
92
92
  email,
93
93
  });
@@ -113,7 +113,7 @@ export async function createBook(userID) {
113
113
  // Create a model to store it.
114
114
  let book = Book.fromJSON(bookRef.id, newBookData);
115
115
  // Make a new default edition with a single chapter with this user id.
116
- let newEdition = new Edition(bookRef, undefined, [], 'Untitled', [], 1, '', null, {}, '', [], 'All rights reserved.', '', [], {}, {}, {}, {}, null, null, {}, null).withNewChapter();
116
+ let newEdition = new Edition(bookRef, undefined, [], 'Untitled', [], 1, '', null, {}, undefined, '', [], 'All rights reserved.', '', [], {}, {}, {}, {}, null, null, {}, null).withNewChapter();
117
117
  // Add the edition to the editions collection in the database so we can get an edition ref.
118
118
  const editionRef = await addDoc(collection(db, 'books', bookRef.id, 'editions'), newEdition.toObject());
119
119
  // Remember the ref.
@@ -1,10 +1,4 @@
1
- declare const ChapterIDs: {
2
- TableOfContentsID: string;
3
- ReferencesID: string;
4
- SearchID: string;
5
- MediaID: string;
6
- IndexID: string;
7
- GlossaryID: string;
8
- UnknownID: string;
9
- };
1
+ export type ChapterIDKey = 'references' | 'search' | 'media' | 'index' | 'glossary' | 'unknown' | 'cover';
2
+ export type TOCHeaderKey = 'chapters' | 'acknowledgements' | 'license' | 'print' | 'citation';
3
+ declare const ChapterIDs: Record<string, ChapterIDKey>;
10
4
  export default ChapterIDs;
@@ -1,5 +1,5 @@
1
1
  const ChapterIDs = {
2
- TableOfContentsID: '',
2
+ TableOfContentsID: 'cover',
3
3
  ReferencesID: 'references',
4
4
  SearchID: 'search',
5
5
  MediaID: 'media',
@@ -4,6 +4,7 @@ import EmbedNode from '../chapter/EmbedNode';
4
4
  import Reference from './Reference';
5
5
  import type Theme from './Theme';
6
6
  import type Definition from './Definition.js';
7
+ import { type ChapterIDKey, type TOCHeaderKey } from './ChapterID.js';
7
8
  import type { DocumentReference } from 'firebase/firestore';
8
9
  import type Book from './Book';
9
10
  import type FormatNode from '../chapter/FormatNode';
@@ -15,7 +16,10 @@ export type EditionSpecification = {
15
16
  summary: string;
16
17
  published: number | null;
17
18
  authors: string[];
18
- images: Record<string, string | null>;
19
+ /** Custom images for built-in chapters */
20
+ images: Record<ChapterIDKey, string | null>;
21
+ /** Optional custom names for built-in chapters */
22
+ headers?: Record<ChapterIDKey | TOCHeaderKey, string> | undefined;
19
23
  description: string;
20
24
  chapters: ChapterSpecification[];
21
25
  license: string;
@@ -45,6 +49,7 @@ export default class Edition {
45
49
  readonly summary: string;
46
50
  readonly published: number | null;
47
51
  readonly images: Record<string, string | null>;
52
+ readonly headers: Record<ChapterIDKey | TOCHeaderKey, string> | undefined;
48
53
  readonly description: string;
49
54
  readonly chapters: Chapter[];
50
55
  readonly license: string;
@@ -58,7 +63,7 @@ export default class Edition {
58
63
  readonly base: string | null;
59
64
  readonly active: Record<string, string>;
60
65
  readonly gtagid: string | null;
61
- 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, base: string | null, active: Record<string, string>, gtagid: string | null);
66
+ constructor(bookRef: DocumentReference, editionRef: DocumentReference | undefined, uids: string[], title: string, authors: string[], number: number, summary: string, published: number | null, images: Record<string, string | null>, headers: Record<ChapterIDKey | TOCHeaderKey, string> | undefined, 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, base: string | null, active: Record<string, string>, gtagid: string | null);
62
67
  static fromJSON(editionRef: DocumentReference | undefined, spec: EditionSpecification): Edition;
63
68
  static parseReference(citationID: string, ref: string | string[], edition: Edition, short?: boolean): FormatNode | Reference;
64
69
  toObject(): EditionSpecification;
@@ -120,8 +125,8 @@ export default class Edition {
120
125
  withAuthorName(index: number, name: string): Edition;
121
126
  withoutAuthor(index: number): Edition;
122
127
  withEditors(uids: string[]): Edition;
123
- hasImage(id: string): boolean;
124
- getImage(id: string): string | null;
128
+ hasImage(id: ChapterIDKey): boolean;
129
+ getImage(id: ChapterIDKey | string): string | null;
125
130
  withImage(id: string, embed: string | null): Edition;
126
131
  isEditor(uid: string): boolean;
127
132
  isChapterEditor(uid: string): boolean;
@@ -145,6 +150,9 @@ export default class Edition {
145
150
  }[];
146
151
  isLatestEdition(book: Book): boolean;
147
152
  isLatestPublishedEdition(book: Book): boolean;
153
+ /** Get the custom header, if there is one */
154
+ getHeader(id: ChapterIDKey | TOCHeaderKey): string;
155
+ withHeader(id: ChapterIDKey | TOCHeaderKey, header: string): Edition;
148
156
  getEditionNumber(): number;
149
157
  getEditionLabel(): string;
150
158
  getInfo(): EditionInfo | undefined;