bookish-press 0.5.26 → 0.5.62

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 (164) hide show
  1. package/dist/components/Auth.svelte.d.ts +2 -2
  2. package/dist/components/BookPreview.svelte +1 -0
  3. package/dist/components/BookPreview.svelte.d.ts +2 -2
  4. package/dist/components/Link.svelte.d.ts +2 -2
  5. package/dist/components/app/BookList.svelte.d.ts +2 -2
  6. package/dist/components/app/Button.svelte.d.ts +2 -2
  7. package/dist/components/app/Feedback.svelte.d.ts +2 -2
  8. package/dist/components/app/Head.svelte.d.ts +2 -2
  9. package/dist/components/app/Large.svelte.d.ts +2 -2
  10. package/dist/components/app/Lead.svelte.d.ts +2 -2
  11. package/dist/components/app/Link.svelte.d.ts +2 -2
  12. package/dist/components/app/Options.svelte.d.ts +2 -2
  13. package/dist/components/app/Paragraph.svelte.d.ts +2 -2
  14. package/dist/components/app/Section.svelte.d.ts +2 -2
  15. package/dist/components/app/Table.svelte.d.ts +2 -2
  16. package/dist/components/app/TextInput.svelte.d.ts +2 -2
  17. package/dist/components/chapter/Atom.svelte.d.ts +2 -2
  18. package/dist/components/chapter/Block.svelte.d.ts +2 -2
  19. package/dist/components/chapter/Callout.svelte.d.ts +2 -2
  20. package/dist/components/chapter/CaptionedCode.svelte.d.ts +2 -2
  21. package/dist/components/chapter/ChapterBody.svelte +2 -0
  22. package/dist/components/chapter/ChapterBody.svelte.d.ts +2 -2
  23. package/dist/components/chapter/Citations.svelte.d.ts +2 -2
  24. package/dist/components/chapter/Code.svelte.d.ts +2 -2
  25. package/dist/components/chapter/Comment.svelte.d.ts +2 -2
  26. package/dist/components/chapter/Definition.svelte +6 -7
  27. package/dist/components/chapter/Definition.svelte.d.ts +2 -2
  28. package/dist/components/chapter/Embed.svelte +4 -3
  29. package/dist/components/chapter/Embed.svelte.d.ts +2 -2
  30. package/dist/components/chapter/ErrorMessage.svelte.d.ts +2 -2
  31. package/dist/components/chapter/ExtendedPrism.d.ts +1 -1
  32. package/dist/components/chapter/Figure.svelte +6 -0
  33. package/dist/components/chapter/Figure.svelte.d.ts +2 -2
  34. package/dist/components/chapter/Footnote.svelte.d.ts +2 -2
  35. package/dist/components/chapter/Format.svelte +21 -16
  36. package/dist/components/chapter/Format.svelte.d.ts +2 -2
  37. package/dist/components/chapter/InlineCode.svelte.d.ts +2 -2
  38. package/dist/components/chapter/Label.svelte.d.ts +2 -2
  39. package/dist/components/chapter/LineBreak.svelte +6 -0
  40. package/dist/components/chapter/LineBreak.svelte.d.ts +17 -0
  41. package/dist/components/chapter/Link.svelte.d.ts +2 -2
  42. package/dist/components/chapter/List.svelte +16 -33
  43. package/dist/components/chapter/List.svelte.d.ts +2 -2
  44. package/dist/components/chapter/Marginal.svelte +5 -4
  45. package/dist/components/chapter/Marginal.svelte.d.ts +2 -2
  46. package/dist/components/chapter/Paragraph.svelte.d.ts +2 -2
  47. package/dist/components/chapter/Positioned.svelte.d.ts +2 -2
  48. package/dist/components/chapter/Problem.svelte.d.ts +2 -2
  49. package/dist/components/chapter/Python.svelte.d.ts +2 -2
  50. package/dist/components/chapter/Quote.svelte.d.ts +2 -2
  51. package/dist/components/chapter/Rule.svelte +2 -2
  52. package/dist/components/chapter/Rule.svelte.d.ts +2 -2
  53. package/dist/components/chapter/Table.svelte.d.ts +2 -2
  54. package/dist/components/chapter/Text.svelte.d.ts +2 -2
  55. package/dist/components/controls/DarkToggle.svelte +1 -1
  56. package/dist/components/controls/DarkToggle.svelte.d.ts +2 -2
  57. package/dist/components/editor/BookishEditor.svelte +13 -16
  58. package/dist/components/editor/BookishEditor.svelte.d.ts +2 -2
  59. package/dist/components/editor/CalloutEditor.svelte.d.ts +2 -2
  60. package/dist/components/editor/CaptionedCodeEditor.svelte.d.ts +2 -2
  61. package/dist/components/editor/CaretContext.d.ts +1 -1
  62. package/dist/components/editor/CaretView.svelte.d.ts +2 -2
  63. package/dist/components/editor/CitationsEditor.svelte.d.ts +2 -2
  64. package/dist/components/editor/Commands.js +121 -55
  65. package/dist/components/editor/ConfirmButton.svelte +7 -1
  66. package/dist/components/editor/ConfirmButton.svelte.d.ts +2 -2
  67. package/dist/components/editor/DefinitionEditor.svelte.d.ts +2 -2
  68. package/dist/components/editor/EmbedEditor.svelte.d.ts +2 -2
  69. package/dist/components/editor/Icon.svelte.d.ts +2 -2
  70. package/dist/components/editor/ImageChooser.svelte +2 -1
  71. package/dist/components/editor/ImageChooser.svelte.d.ts +2 -2
  72. package/dist/components/editor/ImageThumbnail.svelte +11 -7
  73. package/dist/components/editor/ImageThumbnail.svelte.d.ts +2 -2
  74. package/dist/components/editor/InlineCodeEditor.svelte.d.ts +2 -2
  75. package/dist/components/editor/LabelEditor.svelte.d.ts +2 -2
  76. package/dist/components/editor/LanguageEditor.svelte.d.ts +2 -2
  77. package/dist/components/editor/LinkEditor.svelte +4 -3
  78. package/dist/components/editor/LinkEditor.svelte.d.ts +2 -2
  79. package/dist/components/editor/Note.svelte.d.ts +2 -2
  80. package/dist/components/editor/Permissions.svelte +2 -0
  81. package/dist/components/editor/Permissions.svelte.d.ts +2 -2
  82. package/dist/components/editor/PositionEditor.svelte.d.ts +2 -2
  83. package/dist/components/editor/QuoteEditor.svelte.d.ts +2 -2
  84. package/dist/components/editor/Switch.svelte.d.ts +2 -2
  85. package/dist/components/editor/TableEditor.svelte.d.ts +2 -2
  86. package/dist/components/editor/TextEditor.svelte.d.ts +2 -2
  87. package/dist/components/editor/Toggle.svelte +1 -1
  88. package/dist/components/editor/Toggle.svelte.d.ts +2 -2
  89. package/dist/components/editor/Toolbar.svelte +2 -1
  90. package/dist/components/editor/Toolbar.svelte.d.ts +2 -2
  91. package/dist/components/editor/ToolbarGroup.svelte.d.ts +2 -2
  92. package/dist/components/editor/ToolbarSpacer.svelte.d.ts +2 -2
  93. package/dist/components/editor/URLEditor.svelte.d.ts +2 -2
  94. package/dist/components/page/Acknowledgements.svelte.d.ts +2 -2
  95. package/dist/components/page/Authors.svelte.d.ts +2 -2
  96. package/dist/components/page/BookLoader.svelte.d.ts +2 -2
  97. package/dist/components/page/BulkReferenceEditor.svelte.d.ts +2 -2
  98. package/dist/components/page/Chapter.svelte +1 -1
  99. package/dist/components/page/Chapter.svelte.d.ts +2 -2
  100. package/dist/components/page/ChapterNumber.svelte.d.ts +2 -2
  101. package/dist/components/page/ChapterTitle.svelte.d.ts +2 -2
  102. package/dist/components/page/DefinitionView.svelte.d.ts +2 -2
  103. package/dist/components/page/Description.svelte.d.ts +2 -2
  104. package/dist/components/page/Edition.svelte.d.ts +2 -2
  105. package/dist/components/page/EditionLoader.svelte +12 -3
  106. package/dist/components/page/EditionLoader.svelte.d.ts +2 -2
  107. package/dist/components/page/Editions.svelte +1 -1
  108. package/dist/components/page/Editions.svelte.d.ts +2 -2
  109. package/dist/components/page/Glossary.svelte.d.ts +2 -2
  110. package/dist/components/page/Header.svelte.d.ts +2 -2
  111. package/dist/components/page/Index.svelte.d.ts +2 -2
  112. package/dist/components/page/Instructions.svelte.d.ts +2 -2
  113. package/dist/components/page/License.svelte.d.ts +2 -2
  114. package/dist/components/page/Loading.svelte.d.ts +2 -2
  115. package/dist/components/page/Media.svelte.d.ts +2 -2
  116. package/dist/components/page/MediaPreview.svelte.d.ts +2 -2
  117. package/dist/components/page/Muted.svelte.d.ts +2 -2
  118. package/dist/components/page/Outline.svelte +1 -1
  119. package/dist/components/page/Outline.svelte.d.ts +2 -2
  120. package/dist/components/page/Page.svelte.d.ts +2 -2
  121. package/dist/components/page/PageHeader.svelte.d.ts +2 -2
  122. package/dist/components/page/PageParagraph.svelte.d.ts +2 -2
  123. package/dist/components/page/PossibleChapter.svelte.d.ts +2 -2
  124. package/dist/components/page/PossibleReference.svelte.d.ts +2 -2
  125. package/dist/components/page/Print.svelte.d.ts +2 -2
  126. package/dist/components/page/Publish.svelte.d.ts +2 -2
  127. package/dist/components/page/Reference.svelte.d.ts +2 -2
  128. package/dist/components/page/References.svelte.d.ts +2 -2
  129. package/dist/components/page/Rows.svelte.d.ts +2 -2
  130. package/dist/components/page/Search.svelte.d.ts +2 -2
  131. package/dist/components/page/Status.svelte.d.ts +2 -2
  132. package/dist/components/page/SubdomainEditor.svelte.d.ts +2 -2
  133. package/dist/components/page/TableOfContents.svelte +2 -2
  134. package/dist/components/page/TableOfContents.svelte.d.ts +2 -2
  135. package/dist/components/page/TableOfContentsImage.svelte.d.ts +2 -2
  136. package/dist/components/page/TableOfContentsRow.svelte +1 -1
  137. package/dist/components/page/TableOfContentsRow.svelte.d.ts +2 -2
  138. package/dist/components/page/ThemeEditor.svelte.d.ts +2 -2
  139. package/dist/components/page/ThemeEditorPreview.svelte.d.ts +2 -2
  140. package/dist/components/page/ThemeSetEditor.svelte.d.ts +2 -2
  141. package/dist/components/page/ThemeVariableEditor.svelte.d.ts +2 -2
  142. package/dist/components/page/Title.svelte.d.ts +2 -2
  143. package/dist/components/page/Unknown.svelte.d.ts +2 -2
  144. package/dist/models/CRUD.d.ts +1 -0
  145. package/dist/models/CRUD.js +17 -4
  146. package/dist/models/book/Chapter.d.ts +10 -8
  147. package/dist/models/book/Chapter.js +16 -6
  148. package/dist/models/book/Edition.d.ts +3 -2
  149. package/dist/models/book/Edition.js +12 -5
  150. package/dist/models/chapter/Caret.d.ts +2 -1
  151. package/dist/models/chapter/Caret.js +20 -6
  152. package/dist/models/chapter/DefinitionNode.js +1 -1
  153. package/dist/models/chapter/FormatNode.d.ts +4 -1
  154. package/dist/models/chapter/FormatNode.js +57 -10
  155. package/dist/models/chapter/InlineCodeNode.js +1 -1
  156. package/dist/models/chapter/LineBreakNode.d.ts +15 -0
  157. package/dist/models/chapter/LineBreakNode.js +37 -0
  158. package/dist/models/chapter/LinkNode.js +1 -1
  159. package/dist/models/chapter/ListNode.js +1 -1
  160. package/dist/models/chapter/Parser.d.ts +2 -0
  161. package/dist/models/chapter/Parser.js +15 -8
  162. package/dist/models/chapter/Symbols.d.ts +1 -0
  163. package/dist/models/chapter/Symbols.js +1 -0
  164. package/package.json +23 -23
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  import Reference from '../../models/book/Reference';
3
3
  declare const __propDef: {
4
4
  props: {
@@ -13,6 +13,6 @@ declare const __propDef: {
13
13
  export type ReferenceProps = typeof __propDef.props;
14
14
  export type ReferenceEvents = typeof __propDef.events;
15
15
  export type ReferenceSlots = typeof __propDef.slots;
16
- export default class Reference extends SvelteComponentTyped<ReferenceProps, ReferenceEvents, ReferenceSlots> {
16
+ export default class Reference extends SvelteComponent<ReferenceProps, ReferenceEvents, ReferenceSlots> {
17
17
  }
18
18
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: Record<string, never>;
4
4
  events: {
@@ -9,6 +9,6 @@ declare const __propDef: {
9
9
  export type ReferencesProps = typeof __propDef.props;
10
10
  export type ReferencesEvents = typeof __propDef.events;
11
11
  export type ReferencesSlots = typeof __propDef.slots;
12
- export default class References extends SvelteComponentTyped<ReferencesProps, ReferencesEvents, ReferencesSlots> {
12
+ export default class References extends SvelteComponent<ReferencesProps, ReferencesEvents, ReferencesSlots> {
13
13
  }
14
14
  export {};
@@ -1,7 +1,7 @@
1
1
  /** @typedef {typeof __propDef.props} RowsProps */
2
2
  /** @typedef {typeof __propDef.events} RowsEvents */
3
3
  /** @typedef {typeof __propDef.slots} RowsSlots */
4
- export default class Rows extends SvelteComponentTyped<{
4
+ export default class Rows extends SvelteComponent<{
5
5
  [x: string]: never;
6
6
  }, {
7
7
  [evt: string]: CustomEvent<any>;
@@ -12,7 +12,7 @@ export default class Rows extends SvelteComponentTyped<{
12
12
  export type RowsProps = typeof __propDef.props;
13
13
  export type RowsEvents = typeof __propDef.events;
14
14
  export type RowsSlots = typeof __propDef.slots;
15
- import { SvelteComponentTyped } from "svelte";
15
+ import { SvelteComponent } from "svelte";
16
16
  declare const __propDef: {
17
17
  props: {
18
18
  [x: string]: never;
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: Record<string, never>;
4
4
  events: {
@@ -9,6 +9,6 @@ declare const __propDef: {
9
9
  export type SearchProps = typeof __propDef.props;
10
10
  export type SearchEvents = typeof __propDef.events;
11
11
  export type SearchSlots = typeof __propDef.slots;
12
- export default class Search extends SvelteComponentTyped<SearchProps, SearchEvents, SearchSlots> {
12
+ export default class Search extends SvelteComponent<SearchProps, SearchEvents, SearchSlots> {
13
13
  }
14
14
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: Record<string, never>;
4
4
  events: {
@@ -9,6 +9,6 @@ declare const __propDef: {
9
9
  export type StatusProps = typeof __propDef.props;
10
10
  export type StatusEvents = typeof __propDef.events;
11
11
  export type StatusSlots = typeof __propDef.slots;
12
- export default class Status extends SvelteComponentTyped<StatusProps, StatusEvents, StatusSlots> {
12
+ export default class Status extends SvelteComponent<StatusProps, StatusEvents, StatusSlots> {
13
13
  }
14
14
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: Record<string, never>;
4
4
  events: {
@@ -9,6 +9,6 @@ declare const __propDef: {
9
9
  export type SubdomainEditorProps = typeof __propDef.props;
10
10
  export type SubdomainEditorEvents = typeof __propDef.events;
11
11
  export type SubdomainEditorSlots = typeof __propDef.slots;
12
- export default class SubdomainEditor extends SvelteComponentTyped<SubdomainEditorProps, SubdomainEditorEvents, SubdomainEditorSlots> {
12
+ export default class SubdomainEditor extends SvelteComponent<SubdomainEditorProps, SubdomainEditorEvents, SubdomainEditorSlots> {
13
13
  }
14
14
  export {};
@@ -138,7 +138,7 @@ onMount(() => {
138
138
  </Instructions>
139
139
 
140
140
  <PageHeader id="chapters"
141
- >Chapters {#if editable}<Button
141
+ >Chapters{#if editable}&nbsp;<Button
142
142
  tooltip="add empty chapter"
143
143
  disabled={waitingForChapter}
144
144
  command={addChapter}>+ chapter</Button
@@ -289,7 +289,7 @@ onMount(() => {
289
289
  {/if}
290
290
 
291
291
  {#if $book && (editable || isEditionPartiallyEditable())}
292
- <PageHeader>Editors</PageHeader>
292
+ <PageHeader id="editors">Editors</PageHeader>
293
293
  <Instructions {editable}>
294
294
  These authors can edit this edition and its chapters. To give
295
295
  book-level permissions, edit the book editors on the <Link
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: Record<string, never>;
4
4
  events: {
@@ -9,6 +9,6 @@ declare const __propDef: {
9
9
  export type TableOfContentsProps = typeof __propDef.props;
10
10
  export type TableOfContentsEvents = typeof __propDef.events;
11
11
  export type TableOfContentsSlots = typeof __propDef.slots;
12
- export default class TableOfContents extends SvelteComponentTyped<TableOfContentsProps, TableOfContentsEvents, TableOfContentsSlots> {
12
+ export default class TableOfContents extends SvelteComponent<TableOfContentsProps, TableOfContentsEvents, TableOfContentsSlots> {
13
13
  }
14
14
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  embed: string | null;
@@ -12,6 +12,6 @@ declare const __propDef: {
12
12
  export type TableOfContentsImageProps = typeof __propDef.props;
13
13
  export type TableOfContentsImageEvents = typeof __propDef.events;
14
14
  export type TableOfContentsImageSlots = typeof __propDef.slots;
15
- export default class TableOfContentsImage extends SvelteComponentTyped<TableOfContentsImageProps, TableOfContentsImageEvents, TableOfContentsImageSlots> {
15
+ export default class TableOfContentsImage extends SvelteComponent<TableOfContentsImageProps, TableOfContentsImageEvents, TableOfContentsImageSlots> {
16
16
  }
17
17
  export {};
@@ -76,7 +76,7 @@ $: chapterURL =
76
76
  >
77
77
  <ConfirmButton
78
78
  tooltip="delete chapter {title}"
79
- confirm="delete chapter"
79
+ confirm="delete"
80
80
  command={() =>
81
81
  chapter && $edition
82
82
  ? edition.set(
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  import type Chapter from '../../models/book/Chapter';
3
3
  declare const __propDef: {
4
4
  props: {
@@ -19,6 +19,6 @@ declare const __propDef: {
19
19
  export type TableOfContentsRowProps = typeof __propDef.props;
20
20
  export type TableOfContentsRowEvents = typeof __propDef.events;
21
21
  export type TableOfContentsRowSlots = typeof __propDef.slots;
22
- export default class TableOfContentsRow extends SvelteComponentTyped<TableOfContentsRowProps, TableOfContentsRowEvents, TableOfContentsRowSlots> {
22
+ export default class TableOfContentsRow extends SvelteComponent<TableOfContentsRowProps, TableOfContentsRowEvents, TableOfContentsRowSlots> {
23
23
  }
24
24
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: Record<string, never>;
4
4
  events: {
@@ -9,6 +9,6 @@ declare const __propDef: {
9
9
  export type ThemeEditorProps = typeof __propDef.props;
10
10
  export type ThemeEditorEvents = typeof __propDef.events;
11
11
  export type ThemeEditorSlots = typeof __propDef.slots;
12
- export default class ThemeEditor extends SvelteComponentTyped<ThemeEditorProps, ThemeEditorEvents, ThemeEditorSlots> {
12
+ export default class ThemeEditor extends SvelteComponent<ThemeEditorProps, ThemeEditorEvents, ThemeEditorSlots> {
13
13
  }
14
14
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  import type Theme from '../../models/book/Theme';
3
3
  declare const __propDef: {
4
4
  props: {
@@ -12,6 +12,6 @@ declare const __propDef: {
12
12
  export type ThemeEditorPreviewProps = typeof __propDef.props;
13
13
  export type ThemeEditorPreviewEvents = typeof __propDef.events;
14
14
  export type ThemeEditorPreviewSlots = typeof __propDef.slots;
15
- export default class ThemeEditorPreview extends SvelteComponentTyped<ThemeEditorPreviewProps, ThemeEditorPreviewEvents, ThemeEditorPreviewSlots> {
15
+ export default class ThemeEditorPreview extends SvelteComponent<ThemeEditorPreviewProps, ThemeEditorPreviewEvents, ThemeEditorPreviewSlots> {
16
16
  }
17
17
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  header: string;
@@ -13,6 +13,6 @@ declare const __propDef: {
13
13
  export type ThemeSetEditorProps = typeof __propDef.props;
14
14
  export type ThemeSetEditorEvents = typeof __propDef.events;
15
15
  export type ThemeSetEditorSlots = typeof __propDef.slots;
16
- export default class ThemeSetEditor extends SvelteComponentTyped<ThemeSetEditorProps, ThemeSetEditorEvents, ThemeSetEditorSlots> {
16
+ export default class ThemeSetEditor extends SvelteComponent<ThemeSetEditorProps, ThemeSetEditorEvents, ThemeSetEditorSlots> {
17
17
  }
18
18
  export {};
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  group: string;
@@ -13,6 +13,6 @@ declare const __propDef: {
13
13
  export type ThemeVariableEditorProps = typeof __propDef.props;
14
14
  export type ThemeVariableEditorEvents = typeof __propDef.events;
15
15
  export type ThemeVariableEditorSlots = typeof __propDef.slots;
16
- export default class ThemeVariableEditor extends SvelteComponentTyped<ThemeVariableEditorProps, ThemeVariableEditorEvents, ThemeVariableEditorSlots> {
16
+ export default class ThemeVariableEditor extends SvelteComponent<ThemeVariableEditorProps, ThemeVariableEditorEvents, ThemeVariableEditorSlots> {
17
17
  }
18
18
  export {};
@@ -1,7 +1,7 @@
1
1
  /** @typedef {typeof __propDef.props} TitleProps */
2
2
  /** @typedef {typeof __propDef.events} TitleEvents */
3
3
  /** @typedef {typeof __propDef.slots} TitleSlots */
4
- export default class Title extends SvelteComponentTyped<{
4
+ export default class Title extends SvelteComponent<{
5
5
  [x: string]: never;
6
6
  }, {
7
7
  [evt: string]: CustomEvent<any>;
@@ -12,7 +12,7 @@ export default class Title extends SvelteComponentTyped<{
12
12
  export type TitleProps = typeof __propDef.props;
13
13
  export type TitleEvents = typeof __propDef.events;
14
14
  export type TitleSlots = typeof __propDef.slots;
15
- import { SvelteComponentTyped } from "svelte";
15
+ import { SvelteComponent } from "svelte";
16
16
  declare const __propDef: {
17
17
  props: {
18
18
  [x: string]: never;
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: Record<string, never>;
4
4
  events: {
@@ -11,6 +11,6 @@ declare const __propDef: {
11
11
  export type UnknownProps = typeof __propDef.props;
12
12
  export type UnknownEvents = typeof __propDef.events;
13
13
  export type UnknownSlots = typeof __propDef.slots;
14
- export default class Unknown extends SvelteComponentTyped<UnknownProps, UnknownEvents, UnknownSlots> {
14
+ export default class Unknown extends SvelteComponent<UnknownProps, UnknownEvents, UnknownSlots> {
15
15
  }
16
16
  export {};
@@ -20,6 +20,7 @@ export declare function updateLock(edition: Edition, uid: string, content: strin
20
20
  * returns a map of DocumentReferences for new chapters so they can be persisted client side.
21
21
  */
22
22
  export declare function updateEdition(book: Book, previousEdition: Edition | undefined, newEdition: Edition): Promise<Map<string, DocumentReference>>;
23
+ export declare function deleteChapterText(ref: DocumentReference): Promise<void>;
23
24
  export declare function updateBook(book: Book): Promise<void>;
24
25
  export declare function isSubdomainAvailable(subdomain: string, book: Book): Promise<boolean>;
25
26
  export declare function getBookIDWithSubdomain(subdomain: string): Promise<string | null>;
@@ -60,8 +60,12 @@ export function listenToChapters(bookID, editionID, react) {
60
60
  throw NO_DATABASE_CONNECTION;
61
61
  return onSnapshot(collection(db, 'books', bookID, 'editions', editionID, 'chapters'), (docs) => {
62
62
  const chapters = [];
63
+ // For each chapter in the book, if the doc exists and it's not a pending local write, send updated chapters to the front end.
63
64
  docs.forEach((doc) => {
64
- chapters.push([doc.ref, doc.data().text]);
65
+ if (doc.exists() && !doc.metadata.hasPendingWrites)
66
+ // If the chapter text is somehow null, set it to an empty string.
67
+ // This accounts for previous defects that could lead to null.
68
+ chapters.push([doc.ref, doc.data().text ?? '']);
65
69
  });
66
70
  react(chapters);
67
71
  });
@@ -182,7 +186,9 @@ export async function updateEdition(book, previousEdition, newEdition) {
182
186
  for (const newChapter of newEdition.chapters) {
183
187
  if (newChapter.ref === undefined) {
184
188
  // Make the new chapter's text.
185
- const newChapterRef = await addDoc(collection(db, editionPath(newEdition.bookRef.id, editionRef.id), 'chapters'), { text: newChapter.text });
189
+ const newChapterRef = await addDoc(collection(db, editionPath(newEdition.bookRef.id, editionRef.id), 'chapters'),
190
+ // If the new chapter has null text, set it to empty string
191
+ { text: newChapter.text ?? '' });
186
192
  // Add the ref of the new chapter to the revised chapter.
187
193
  newEdition = newEdition.withRevisedChapter(newChapter, newChapter.withRef(newChapterRef));
188
194
  // Map the chapter ref to it's id.
@@ -193,8 +199,12 @@ export async function updateEdition(book, previousEdition, newEdition) {
193
199
  const previousChapter = previousEdition === undefined
194
200
  ? undefined
195
201
  : previousEdition.getChapterByRef(newChapter.ref);
196
- if (previousChapter === undefined ||
197
- newChapter.text !== previousChapter.text) {
202
+ if (
203
+ // A null chapter text means that we haven't loaded it yet from the database, so we
204
+ // only set it if it's not null.
205
+ newChapter.text !== null &&
206
+ (previousChapter === undefined ||
207
+ newChapter.text !== previousChapter.text)) {
198
208
  await setDoc(doc(db, editionPath(newEdition.bookRef.id, editionRef.id), 'chapters', newChapter.ref.id), { text: newChapter.text });
199
209
  }
200
210
  }
@@ -225,6 +235,9 @@ export async function updateEdition(book, previousEdition, newEdition) {
225
235
  await setDoc(doc(db, editionPath(newEdition.bookRef.id, editionRef.id)), newEdition.toObject());
226
236
  return newChapterRefs;
227
237
  }
238
+ export async function deleteChapterText(ref) {
239
+ deleteDoc(ref);
240
+ }
228
241
  export async function updateBook(book) {
229
242
  if (!db)
230
243
  throw Error("Can't update book, not connected to Firebase.");
@@ -10,7 +10,8 @@ export type ChapterSpecification = {
10
10
  numbered: boolean;
11
11
  forthcoming: boolean;
12
12
  section?: string;
13
- text?: string;
13
+ /** A string means that we know the chapter's text; null means we haven't loaded it yet from the database and should not be editing or saving it. */
14
+ text?: string | null;
14
15
  uids: string[];
15
16
  };
16
17
  export type ChapterContent = {
@@ -30,7 +31,7 @@ export default class Chapter {
30
31
  readonly numbered: boolean;
31
32
  readonly forthcoming: boolean;
32
33
  readonly section: string | undefined;
33
- readonly text: string;
34
+ readonly text: string | null;
34
35
  readonly uids: string[];
35
36
  _ast: ChapterNode | undefined;
36
37
  _index: Record<string, Array<Match>> | undefined;
@@ -41,15 +42,16 @@ export default class Chapter {
41
42
  }[];
42
43
  lastEdit: number;
43
44
  listeners: Set<(text: string) => void>;
44
- constructor(ref: DocumentReference | undefined, id: string, title: string, authors: string[], image: string | null, numbered: boolean, forthcoming: boolean, section: string | undefined, text: string, uids: string[]);
45
+ constructor(ref: DocumentReference | undefined, id: string, title: string, authors: string[], image: string | null, numbered: boolean, forthcoming: boolean, section: string | undefined, text: string | null, uids: string[]);
45
46
  /**
46
47
  * Convert a chapter spec and it's text into a chapter object.
47
48
  * The spec may contain the text itself, but it may not, so we require it to be
48
49
  * repeated here to guarantee its provided.
49
50
  */
50
- static fromJSON(spec: ChapterSpecification, text: string): Chapter;
51
+ static fromJSON(spec: ChapterSpecification): Chapter;
51
52
  toJSON(): ChapterSpecification;
52
- getRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
53
+ getRef(): DocumentReference<import("@firebase/firestore").DocumentData, import("@firebase/firestore").DocumentData> | undefined;
54
+ hasRefID(id: string): boolean;
53
55
  withEditors(uids: string[]): Chapter;
54
56
  withRef(ref: DocumentReference): Chapter;
55
57
  withoutRef(): Chapter;
@@ -62,7 +64,7 @@ export default class Chapter {
62
64
  isNumbered(): boolean;
63
65
  asNumbered(numbered: boolean): Chapter;
64
66
  isEditor(uid: string): boolean;
65
- getText(): string;
67
+ getText(): string | null;
66
68
  withText(text: string): Chapter;
67
69
  withAST(ast: ChapterNode): Chapter;
68
70
  getAuthors(): string[];
@@ -73,8 +75,8 @@ export default class Chapter {
73
75
  withTitle(title: string): Chapter;
74
76
  getImage(): string | null;
75
77
  withImage(image: string | null): Chapter;
76
- getAST(edition: Edition): ChapterNode;
77
- getWordCount(edition: Edition): number;
78
+ getAST(edition: Edition): ChapterNode | undefined;
79
+ getWordCount(edition: Edition): number | undefined;
78
80
  getReadingTime(edition: Edition): number | undefined;
79
81
  getIndex(edition: Edition): Record<string, Match[]>;
80
82
  toString(): string;
@@ -39,9 +39,9 @@ export default class Chapter {
39
39
  * The spec may contain the text itself, but it may not, so we require it to be
40
40
  * repeated here to guarantee its provided.
41
41
  */
42
- static fromJSON(spec, text) {
42
+ static fromJSON(spec) {
43
43
  // Copy the spec, filling in defaults as necessary.
44
- return new Chapter(spec.ref, spec.id, spec.title, spec.authors ?? [], spec.image ?? null, spec.numbered === true || spec.numbered === undefined, spec.forthcoming === true, spec.section, spec.text ?? text, spec.uids);
44
+ return new Chapter(spec.ref, spec.id, spec.title, spec.authors ?? [], spec.image ?? null, spec.numbered === true || spec.numbered === undefined, spec.forthcoming === true, spec.section, spec.text ?? null, spec.uids);
45
45
  }
46
46
  toJSON() {
47
47
  // Note that we don't include the chapter text in the payload; that's stored in the chapters subcollection.
@@ -64,6 +64,9 @@ export default class Chapter {
64
64
  getRef() {
65
65
  return this.ref;
66
66
  }
67
+ hasRefID(id) {
68
+ return this.ref !== undefined && this.ref.id === id;
69
+ }
67
70
  withEditors(uids) {
68
71
  return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, uids);
69
72
  }
@@ -144,6 +147,8 @@ export default class Chapter {
144
147
  return new Chapter(this.ref, this.id, this.title, this.authors, image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
145
148
  }
146
149
  getAST(edition) {
150
+ if (this.text === null)
151
+ return undefined;
147
152
  // Compute the cache if necessary
148
153
  if (this._ast === undefined)
149
154
  this._ast = Parser.parseChapter(edition, this.text);
@@ -151,18 +156,23 @@ export default class Chapter {
151
156
  }
152
157
  getWordCount(edition) {
153
158
  if (this._wordCount === undefined)
154
- this._wordCount = this.getAST(edition).toText().split(/\s+/).length;
159
+ this._wordCount = this.getAST(edition)
160
+ ?.toText()
161
+ .split(/\s+/).length;
155
162
  return this._wordCount;
156
163
  }
157
164
  // Utility function
158
165
  getReadingTime(edition) {
159
- return this.isForthcoming()
166
+ const wordCount = this.getWordCount(edition);
167
+ return wordCount === undefined || this.isForthcoming()
160
168
  ? undefined
161
- : Math.max(1, Math.round(this.getWordCount(edition) / 150));
169
+ : Math.max(1, Math.round(wordCount / 150));
162
170
  }
163
171
  getIndex(edition) {
164
172
  if (this._index === undefined) {
165
173
  const ast = this.getAST(edition);
174
+ if (ast === undefined)
175
+ return {};
166
176
  // Build a list of common words
167
177
  let commonWords = new Set();
168
178
  CommonWords.forEach((word) => commonWords.add(word));
@@ -207,6 +217,6 @@ export default class Chapter {
207
217
  return this._index;
208
218
  }
209
219
  toString() {
210
- return `${this.title} by ${this.authors.join(', ')}: ${this.text.substring(0, 32)}}`;
220
+ return `${this.title} by ${this.authors.join(', ')}: ${this.text?.substring(0, 32)}}`;
211
221
  }
212
222
  }
@@ -57,8 +57,8 @@ export default class Edition {
57
57
  static fromJSON(editionRef: DocumentReference | undefined, spec: EditionSpecification): Edition;
58
58
  static parseReference(citationID: string, ref: string | string[], edition: Edition, short?: boolean): FormatNode | Reference;
59
59
  toObject(): EditionSpecification;
60
- getBookRef(): DocumentReference<import("@firebase/firestore").DocumentData>;
61
- getEditionRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
60
+ getBookRef(): DocumentReference<import("@firebase/firestore").DocumentData, import("@firebase/firestore").DocumentData>;
61
+ getEditionRef(): DocumentReference<import("@firebase/firestore").DocumentData, import("@firebase/firestore").DocumentData> | undefined;
62
62
  getChapterUIDS(): string[];
63
63
  withRef(editionRef: DocumentReference | undefined): Edition;
64
64
  getTitle(): string;
@@ -83,6 +83,7 @@ export default class Edition {
83
83
  withoutRefs(): Edition;
84
84
  withIncrementedEditionNumber(): Edition;
85
85
  withNewChapter(): Edition;
86
+ hasChapterRefID(id: string): boolean;
86
87
  withoutChapter(chapterID: string): Edition;
87
88
  withMovedChapter(chapterID: string, increment: number): Edition;
88
89
  getSymbols(): Record<string, string>;
@@ -59,7 +59,7 @@ export default class Edition {
59
59
  static fromJSON(editionRef, spec) {
60
60
  // Copy all of the specification metadata to fields.
61
61
  // Choose suitable defaults if the spec is lacking a field.
62
- 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);
62
+ 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);
63
63
  }
64
64
  static parseReference(citationID, ref, edition, short = false) {
65
65
  if (typeof ref === 'string')
@@ -175,15 +175,19 @@ export default class Edition {
175
175
  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);
176
176
  }
177
177
  withChapterText(text) {
178
- return this.withChapters(this.chapters.map((chapter) => {
178
+ // No need to make a new edition if no chapter was changed.
179
+ let modified = false;
180
+ const newChapters = this.chapters.map((chapter) => {
179
181
  if (chapter.ref === undefined)
180
182
  return chapter;
181
183
  const match = text.find(([ref, text]) => chapter.ref !== undefined &&
182
184
  chapter.ref.id === ref.id &&
183
- chapter.text !== text &&
184
- text !== undefined);
185
+ chapter.text !== text);
186
+ if (match)
187
+ modified = true;
185
188
  return match ? chapter.withText(match[1]) : chapter;
186
- }));
189
+ });
190
+ return modified ? this.withChapters(newChapters) : this;
187
191
  }
188
192
  withRevisedChapter(previous, edited) {
189
193
  const index = this.chapters.indexOf(previous);
@@ -210,6 +214,9 @@ export default class Edition {
210
214
  const newChapter = new Chapter(undefined, `chapter${number}`, 'Untitled Chapter', [], null, true, false, undefined, '', []);
211
215
  return this.withChapters([...this.chapters, newChapter]);
212
216
  }
217
+ hasChapterRefID(id) {
218
+ return this.chapters.some((chapter) => chapter.hasRefID(id));
219
+ }
213
220
  withoutChapter(chapterID) {
214
221
  let index = this.chapters.findIndex((chapter) => chapter.getID() === chapterID);
215
222
  if (index < 0)
@@ -2,6 +2,7 @@ import type Node from './Node';
2
2
  import AtomNode from './AtomNode';
3
3
  import TextNode from './TextNode';
4
4
  import type EmbedNode from './EmbedNode';
5
+ import LineBreakNode from './LineBreakNode';
5
6
  export type SelectableNode = TextNode | AtomNode<any> | EmbedNode;
6
7
  type Caret = {
7
8
  node: SelectableNode;
@@ -16,7 +17,7 @@ export type IndexRange = {
16
17
  start: number;
17
18
  end: number;
18
19
  };
19
- export declare function getTextAndAtomNodes(node: Node): (AtomNode<any> | TextNode)[];
20
+ export declare function getNavigableNodes(node: Node): (AtomNode<any> | TextNode | LineBreakNode)[];
20
21
  export declare function caretToIndex(node: Node, caret: Caret): number | undefined;
21
22
  export declare function indexToCaret(node: Node, index: number): Caret | undefined;
22
23
  export declare function caretRangeToIndexRange(node: Node, range: CaretRange): IndexRange | undefined;
@@ -1,10 +1,13 @@
1
1
  import AtomNode from './AtomNode';
2
2
  import TextNode from './TextNode';
3
3
  import FormatNode from './FormatNode';
4
- export function getTextAndAtomNodes(node) {
4
+ import LineBreakNode from './LineBreakNode';
5
+ export function getNavigableNodes(node) {
5
6
  return node
6
7
  .getNodes()
7
- .filter((n) => n instanceof TextNode || n instanceof AtomNode);
8
+ .filter((n) => n instanceof TextNode ||
9
+ n instanceof AtomNode ||
10
+ n instanceof LineBreakNode);
8
11
  }
9
12
  function getFormatRoots(node) {
10
13
  const roots = [];
@@ -22,7 +25,7 @@ export function caretToIndex(node, caret) {
22
25
  roots = [node];
23
26
  let currentIndex = 0;
24
27
  for (let n = 0; n < roots.length; n++) {
25
- const nodes = getTextAndAtomNodes(roots[n]);
28
+ const nodes = getNavigableNodes(roots[n]);
26
29
  for (let i = 0; i < nodes.length; i++) {
27
30
  const t = nodes[i];
28
31
  if (t !== caret.node)
@@ -40,9 +43,9 @@ export function indexToCaret(node, index) {
40
43
  roots = [node];
41
44
  let currentIndex = 0;
42
45
  for (let n = 0; n < roots.length; n++) {
43
- const nodes = getTextAndAtomNodes(roots[n]);
46
+ const nodes = getNavigableNodes(roots[n]);
44
47
  for (let i = 0; i < nodes.length; i++) {
45
- const t = nodes[i];
48
+ let t = nodes[i];
46
49
  if (index >= currentIndex &&
47
50
  index <= currentIndex + t.getCaretPositionCount()) {
48
51
  // Prefer empty nodes to enable zero width formats.
@@ -51,7 +54,18 @@ export function indexToCaret(node, index) {
51
54
  if (next instanceof TextNode && next.getLength() === 0)
52
55
  return { node: next, index: 0 };
53
56
  }
54
- return { node: t, index: index - currentIndex };
57
+ // If it's a line break node, find the next non-line break node.
58
+ if (t instanceof LineBreakNode) {
59
+ while (i < nodes.length &&
60
+ nodes[i] instanceof LineBreakNode)
61
+ i++;
62
+ t = nodes[i];
63
+ if (i === nodes.length || t instanceof LineBreakNode)
64
+ return undefined;
65
+ return { node: t, index: 0 };
66
+ }
67
+ else
68
+ return { node: t, index: index - currentIndex };
55
69
  }
56
70
  currentIndex += t.getCaretPositionCount();
57
71
  }
@@ -14,7 +14,7 @@ export default class DefinitionNode extends MetadataNode {
14
14
  return `${this.getText().toHTML()}`;
15
15
  }
16
16
  toBookdown() {
17
- return `~${this.getText().toBookdown()}~${this.getMeta()}`;
17
+ return `~${this.getText().getText()}~${this.getMeta()}`;
18
18
  }
19
19
  copy() {
20
20
  return new DefinitionNode(this.getText(), this.getMeta());
@@ -6,8 +6,9 @@ import { type CaretRange } from './Caret';
6
6
  import MetadataNode from './MetadataNode';
7
7
  import AtomNode from './AtomNode';
8
8
  import type Edit from './Edit';
9
+ import LineBreakNode from './LineBreakNode';
9
10
  export type Format = '' | '*' | '_' | '^' | 'v';
10
- export type FormatNodeSegmentType = FormatNode | TextNode | ErrorNode | MetadataNode<any> | AtomNode<any>;
11
+ export type FormatNodeSegmentType = FormatNode | TextNode | LineBreakNode | ErrorNode | MetadataNode<any> | AtomNode<any>;
11
12
  export default class FormatNode extends Node {
12
13
  #private;
13
14
  constructor(format: Format, segments: FormatNodeSegmentType[]);
@@ -57,4 +58,6 @@ export default class FormatNode extends Node {
57
58
  withoutAdjacentContent(caret: Caret, next: boolean): Edit | undefined;
58
59
  withoutCharacter(caret: Caret, next: boolean): Edit | undefined;
59
60
  withNodeInserted(caret: Caret, node: Node): Edit;
61
+ getSegmentAfter(segment: FormatNodeSegmentType): FormatNodeSegmentType | undefined;
62
+ getSegmentBefore(segment: FormatNodeSegmentType): FormatNodeSegmentType | undefined;
60
63
  }