bookish-press 0.4.0 → 0.4.16

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 (394) hide show
  1. package/README.md +3 -1
  2. package/components/Auth.svelte +19 -14
  3. package/components/Auth.svelte.d.ts +4 -4
  4. package/components/Authentication.d.ts +2 -2
  5. package/components/BookPreview.svelte +77 -59
  6. package/components/BookPreview.svelte.d.ts +5 -5
  7. package/components/External.svelte +1 -1
  8. package/components/External.svelte.d.ts +3 -3
  9. package/components/Link.svelte +49 -3
  10. package/components/Link.svelte.d.ts +3 -4
  11. package/components/app/BookList.svelte +19 -0
  12. package/components/app/BookList.svelte.d.ts +18 -0
  13. package/components/app/Button.svelte +49 -0
  14. package/components/app/Button.svelte.d.ts +22 -0
  15. package/components/app/Feedback.svelte +45 -0
  16. package/components/app/Feedback.svelte.d.ts +18 -0
  17. package/components/app/Head.svelte +12 -0
  18. package/components/app/Head.svelte.d.ts +27 -0
  19. package/components/app/Large.svelte +8 -0
  20. package/components/app/Large.svelte.d.ts +27 -0
  21. package/components/app/Lead.svelte +12 -0
  22. package/components/app/Lead.svelte.d.ts +27 -0
  23. package/components/app/Link.svelte +24 -0
  24. package/components/app/Link.svelte.d.ts +20 -0
  25. package/components/app/Options.svelte +24 -0
  26. package/components/app/Options.svelte.d.ts +19 -0
  27. package/components/app/Paragraph.svelte +19 -0
  28. package/components/app/Paragraph.svelte.d.ts +18 -0
  29. package/components/app/Table.svelte +32 -0
  30. package/components/app/Table.svelte.d.ts +27 -0
  31. package/components/app/TextInput.svelte +37 -0
  32. package/components/app/TextInput.svelte.d.ts +22 -0
  33. package/components/app/Writing.svelte +13 -0
  34. package/components/app/Writing.svelte.d.ts +27 -0
  35. package/components/chapter/Atom.svelte +20 -6
  36. package/components/chapter/Atom.svelte.d.ts +3 -3
  37. package/components/chapter/Block.svelte +23 -20
  38. package/components/chapter/Block.svelte.d.ts +4 -4
  39. package/components/chapter/Callout.svelte +38 -7
  40. package/components/chapter/Callout.svelte.d.ts +4 -4
  41. package/components/chapter/CaptionedCode.svelte +66 -23
  42. package/components/chapter/CaptionedCode.svelte.d.ts +4 -4
  43. package/components/chapter/ChapterBody.svelte +61 -9
  44. package/components/chapter/ChapterBody.svelte.d.ts +4 -4
  45. package/components/chapter/Citations.svelte +86 -20
  46. package/components/chapter/Citations.svelte.d.ts +4 -4
  47. package/components/chapter/Code.svelte +152 -21
  48. package/components/chapter/Code.svelte.d.ts +3 -3
  49. package/components/chapter/Comment.svelte +38 -16
  50. package/components/chapter/Comment.svelte.d.ts +3 -3
  51. package/components/chapter/Definition.svelte +52 -18
  52. package/components/chapter/Definition.svelte.d.ts +5 -8
  53. package/components/chapter/Embed.svelte +154 -66
  54. package/components/chapter/Embed.svelte.d.ts +5 -4
  55. package/components/chapter/ErrorMessage.svelte +7 -2
  56. package/components/chapter/ErrorMessage.svelte.d.ts +4 -4
  57. package/components/chapter/ExtendedPrism.d.ts +2 -0
  58. package/components/chapter/ExtendedPrism.js +69 -0
  59. package/components/chapter/Figure.svelte +90 -0
  60. package/components/chapter/Figure.svelte.d.ts +24 -0
  61. package/components/chapter/Footnote.svelte +75 -12
  62. package/components/chapter/Footnote.svelte.d.ts +4 -4
  63. package/components/chapter/Format.svelte +60 -37
  64. package/components/chapter/Format.svelte.d.ts +4 -4
  65. package/components/chapter/InlineCode.svelte +15 -5
  66. package/components/chapter/InlineCode.svelte.d.ts +4 -4
  67. package/components/chapter/Label.svelte +37 -8
  68. package/components/chapter/Label.svelte.d.ts +4 -4
  69. package/components/chapter/Link.svelte +23 -18
  70. package/components/chapter/Link.svelte.d.ts +4 -4
  71. package/components/chapter/List.svelte +75 -8
  72. package/components/chapter/List.svelte.d.ts +4 -4
  73. package/components/chapter/Marginal.svelte +169 -27
  74. package/components/chapter/Marginal.svelte.d.ts +6 -3
  75. package/components/chapter/Paragraph.svelte +74 -6
  76. package/components/chapter/Paragraph.svelte.d.ts +4 -4
  77. package/components/chapter/Positioned.svelte +33 -0
  78. package/components/chapter/Positioned.svelte.d.ts +19 -0
  79. package/components/chapter/Problem.svelte +15 -0
  80. package/components/chapter/Problem.svelte.d.ts +27 -0
  81. package/components/chapter/Python.svelte +68 -21
  82. package/components/chapter/Python.svelte.d.ts +4 -4
  83. package/components/chapter/Quote.svelte +64 -11
  84. package/components/chapter/Quote.svelte.d.ts +4 -4
  85. package/components/chapter/Rule.svelte +12 -1
  86. package/components/chapter/Rule.svelte.d.ts +4 -4
  87. package/components/chapter/Table.svelte +36 -25
  88. package/components/chapter/Table.svelte.d.ts +4 -4
  89. package/components/chapter/Text.svelte +61 -36
  90. package/components/chapter/Text.svelte.d.ts +5 -4
  91. package/components/editor/BookishEditor.svelte +343 -237
  92. package/components/editor/BookishEditor.svelte.d.ts +5 -5
  93. package/components/editor/CalloutEditor.svelte +5 -5
  94. package/components/editor/CalloutEditor.svelte.d.ts +4 -4
  95. package/components/editor/CaptionedCodeEditor.svelte +16 -12
  96. package/components/editor/CaptionedCodeEditor.svelte.d.ts +4 -4
  97. package/components/editor/CaretContext.d.ts +48 -16
  98. package/components/editor/CaretState.d.ts +16 -44
  99. package/components/editor/CaretUtilities.d.ts +2 -2
  100. package/components/editor/CaretView.svelte +80 -0
  101. package/components/editor/CaretView.svelte.d.ts +24 -0
  102. package/components/editor/CitationsEditor.svelte +36 -25
  103. package/components/editor/CitationsEditor.svelte.d.ts +4 -4
  104. package/components/editor/Clipboard.d.ts +2 -2
  105. package/components/editor/Command.d.ts +13 -12
  106. package/components/editor/Commands.d.ts +1 -1
  107. package/components/editor/Commands.js +1114 -571
  108. package/components/editor/ConfirmButton.svelte +18 -12
  109. package/components/editor/ConfirmButton.svelte.d.ts +5 -4
  110. package/components/editor/DefinitionEditor.svelte +29 -21
  111. package/components/editor/DefinitionEditor.svelte.d.ts +4 -4
  112. package/components/editor/EmbedEditor.svelte +93 -43
  113. package/components/editor/EmbedEditor.svelte.d.ts +3 -3
  114. package/components/editor/Icon.svelte +17 -0
  115. package/components/editor/Icon.svelte.d.ts +16 -0
  116. package/components/editor/ImageChooser.svelte +53 -34
  117. package/components/editor/ImageChooser.svelte.d.ts +3 -3
  118. package/components/editor/InlineCodeEditor.svelte +7 -4
  119. package/components/editor/InlineCodeEditor.svelte.d.ts +4 -4
  120. package/components/editor/LabelEditor.svelte +20 -11
  121. package/components/editor/LabelEditor.svelte.d.ts +4 -4
  122. package/components/editor/LanguageEditor.svelte +10 -7
  123. package/components/editor/LanguageEditor.svelte.d.ts +3 -3
  124. package/components/editor/LinkEditor.svelte +64 -39
  125. package/components/editor/LinkEditor.svelte.d.ts +4 -4
  126. package/components/editor/Note.svelte +3 -3
  127. package/components/editor/Note.svelte.d.ts +6 -2
  128. package/components/editor/PositionEditor.svelte +9 -6
  129. package/components/editor/PositionEditor.svelte.d.ts +4 -4
  130. package/components/editor/QuoteEditor.svelte +7 -2
  131. package/components/editor/QuoteEditor.svelte.d.ts +4 -4
  132. package/components/editor/Switch.svelte +55 -28
  133. package/components/editor/Switch.svelte.d.ts +4 -4
  134. package/components/editor/TableEditor.svelte +10 -0
  135. package/components/editor/TableEditor.svelte.d.ts +17 -0
  136. package/components/editor/TextEditor.svelte +83 -45
  137. package/components/editor/TextEditor.svelte.d.ts +5 -4
  138. package/components/editor/Toggle.svelte +11 -8
  139. package/components/editor/Toggle.svelte.d.ts +4 -4
  140. package/components/editor/Toolbar.svelte +192 -144
  141. package/components/editor/Toolbar.svelte.d.ts +5 -8
  142. package/components/editor/ToolbarGroup.svelte +18 -23
  143. package/components/editor/ToolbarGroup.svelte.d.ts +3 -4
  144. package/components/editor/ToolbarSpacer.svelte +8 -1
  145. package/components/editor/ToolbarSpacer.svelte.d.ts +6 -2
  146. package/components/editor/URLEditor.svelte +6 -8
  147. package/components/editor/URLEditor.svelte.d.ts +3 -3
  148. package/components/editor/UndoState.d.ts +3 -3
  149. package/components/editor/icons/annotate.svg +1 -0
  150. package/components/editor/icons/block.svg +1 -0
  151. package/components/editor/icons/bold.svg +1 -0
  152. package/components/editor/icons/bullets.svg +1 -0
  153. package/components/editor/icons/callout.svg +1 -0
  154. package/components/editor/icons/citation.svg +8 -0
  155. package/components/editor/icons/clear.svg +1 -0
  156. package/components/editor/icons/clipboard.svg +1 -0
  157. package/components/editor/icons/code.svg +1 -0
  158. package/components/editor/icons/columnafter.svg +1 -0
  159. package/components/editor/icons/columnbefore.svg +1 -0
  160. package/components/editor/icons/comment.svg +1 -0
  161. package/components/editor/icons/copy.svg +1 -0
  162. package/components/editor/icons/cut.svg +1 -0
  163. package/components/editor/icons/define.svg +7 -0
  164. package/components/editor/icons/deletecolumn.svg +1 -0
  165. package/components/editor/icons/deleterow.svg +1 -0
  166. package/components/editor/icons/footnote.svg +8 -0
  167. package/components/editor/icons/header1.svg +7 -0
  168. package/components/editor/icons/header2.svg +7 -0
  169. package/components/editor/icons/header3.svg +7 -0
  170. package/components/editor/icons/home.svg +1 -0
  171. package/components/editor/icons/indent.svg +1 -0
  172. package/components/editor/icons/italic.svg +1 -0
  173. package/components/editor/icons/label.svg +1 -0
  174. package/components/editor/icons/left.svg +1 -0
  175. package/components/editor/icons/level.svg +1 -0
  176. package/components/editor/icons/link.svg +1 -0
  177. package/components/editor/icons/list.svg +1 -0
  178. package/components/editor/icons/media.svg +1 -0
  179. package/components/editor/icons/middle.svg +1 -0
  180. package/components/editor/icons/numbers.svg +10 -0
  181. package/components/editor/icons/paragraph.svg +1 -0
  182. package/components/editor/icons/paste.svg +10 -0
  183. package/components/editor/icons/quote.svg +1 -0
  184. package/components/editor/icons/redo.svg +1 -0
  185. package/components/editor/icons/right.svg +1 -0
  186. package/components/editor/icons/rowabove.svg +1 -0
  187. package/components/editor/icons/rowbelow.svg +1 -0
  188. package/components/editor/icons/rule.svg +1 -0
  189. package/components/editor/icons/sub.svg +1 -0
  190. package/components/editor/icons/super.svg +1 -0
  191. package/components/editor/icons/table.svg +1 -0
  192. package/components/editor/icons/text.svg +1 -0
  193. package/components/editor/icons/time.svg +1 -0
  194. package/components/editor/icons/undo.svg +1 -0
  195. package/components/editor/icons/unindent.svg +1 -0
  196. package/components/editor/icons/unlink.svg +1 -0
  197. package/components/page/Acknowledgements.svelte +31 -22
  198. package/components/page/Acknowledgements.svelte.d.ts +4 -4
  199. package/components/page/Authors.svelte +34 -14
  200. package/components/page/Authors.svelte.d.ts +6 -6
  201. package/components/page/BulkReferenceEditor.svelte +53 -22
  202. package/components/page/BulkReferenceEditor.svelte.d.ts +4 -4
  203. package/components/page/Chapter.svelte +196 -141
  204. package/components/page/Chapter.svelte.d.ts +3 -3
  205. package/components/page/ChapterContext.d.ts +4 -4
  206. package/components/page/ChapterNumber.svelte +9 -0
  207. package/components/page/ChapterNumber.svelte.d.ts +27 -0
  208. package/components/page/ChapterTitle.svelte +16 -0
  209. package/components/page/ChapterTitle.svelte.d.ts +18 -0
  210. package/components/page/Contexts.d.ts +31 -20
  211. package/components/page/Contexts.js +47 -17
  212. package/components/page/DefinitionView.svelte +115 -86
  213. package/components/page/DefinitionView.svelte.d.ts +3 -3
  214. package/components/page/Description.svelte +27 -18
  215. package/components/page/Description.svelte.d.ts +4 -4
  216. package/components/page/Edition.svelte +127 -74
  217. package/components/page/Edition.svelte.d.ts +4 -4
  218. package/components/page/Editions.svelte +144 -0
  219. package/components/page/Editions.svelte.d.ts +14 -0
  220. package/components/page/Glossary.svelte +57 -48
  221. package/components/page/Glossary.svelte.d.ts +4 -4
  222. package/components/page/Header.svelte +129 -44
  223. package/components/page/Header.svelte.d.ts +6 -6
  224. package/components/page/Index.svelte +114 -80
  225. package/components/page/Index.svelte.d.ts +4 -4
  226. package/components/page/Instructions.svelte +18 -16
  227. package/components/page/Instructions.svelte.d.ts +4 -4
  228. package/components/page/License.svelte +29 -21
  229. package/components/page/License.svelte.d.ts +4 -4
  230. package/components/page/Loading.svelte +102 -12
  231. package/components/page/Loading.svelte.d.ts +6 -2
  232. package/components/page/Media.svelte +77 -51
  233. package/components/page/Media.svelte.d.ts +4 -4
  234. package/components/page/MediaPreview.svelte +26 -8
  235. package/components/page/MediaPreview.svelte.d.ts +3 -3
  236. package/components/page/Muted.svelte +10 -0
  237. package/components/page/Muted.svelte.d.ts +27 -0
  238. package/components/page/Outline.svelte +279 -59
  239. package/components/page/Outline.svelte.d.ts +3 -3
  240. package/components/page/Page.svelte +40 -9
  241. package/components/page/Page.svelte.d.ts +3 -3
  242. package/components/page/PageHeader.svelte +14 -0
  243. package/components/page/PageHeader.svelte.d.ts +18 -0
  244. package/components/page/PageParagraph.svelte +18 -0
  245. package/components/page/PageParagraph.svelte.d.ts +27 -0
  246. package/components/page/PossibleChapter.svelte +7 -7
  247. package/components/page/PossibleChapter.svelte.d.ts +4 -4
  248. package/components/page/PossibleReference.svelte +6 -11
  249. package/components/page/PossibleReference.svelte.d.ts +6 -7
  250. package/components/page/Print.svelte +27 -3
  251. package/components/page/Print.svelte.d.ts +4 -4
  252. package/components/page/Reference.svelte +256 -113
  253. package/components/page/Reference.svelte.d.ts +5 -5
  254. package/components/page/References.svelte +39 -47
  255. package/components/page/References.svelte.d.ts +4 -4
  256. package/components/page/Rows.svelte +54 -0
  257. package/components/page/Rows.svelte.d.ts +27 -0
  258. package/components/page/Search.svelte +86 -63
  259. package/components/page/Search.svelte.d.ts +4 -4
  260. package/components/page/Status.svelte +43 -35
  261. package/components/page/Status.svelte.d.ts +4 -9
  262. package/components/page/SubdomainEditor.svelte +40 -27
  263. package/components/page/SubdomainEditor.svelte.d.ts +4 -4
  264. package/components/page/TableOfContents.svelte +225 -190
  265. package/components/page/TableOfContents.svelte.d.ts +4 -4
  266. package/components/page/TableOfContentsImage.svelte +8 -8
  267. package/components/page/TableOfContentsImage.svelte.d.ts +3 -3
  268. package/components/page/TableOfContentsRow.svelte +96 -33
  269. package/components/page/TableOfContentsRow.svelte.d.ts +4 -4
  270. package/components/page/ThemeEditor.svelte +174 -39
  271. package/components/page/ThemeEditor.svelte.d.ts +4 -4
  272. package/components/page/ThemeEditorPreview.svelte +35 -23
  273. package/components/page/ThemeEditorPreview.svelte.d.ts +5 -5
  274. package/components/page/ThemeSetEditor.svelte +15 -13
  275. package/components/page/ThemeSetEditor.svelte.d.ts +4 -4
  276. package/components/page/ThemeVariableEditor.svelte +24 -15
  277. package/components/page/ThemeVariableEditor.svelte.d.ts +3 -3
  278. package/components/page/Title.svelte +12 -0
  279. package/components/page/Title.svelte.d.ts +27 -0
  280. package/components/page/Unknown.svelte +25 -21
  281. package/components/page/Unknown.svelte.d.ts +4 -4
  282. package/components/page/margins.js +50 -33
  283. package/index.d.ts +14 -0
  284. package/index.js +14 -0
  285. package/models/CRUD.d.ts +17 -0
  286. package/models/CRUD.js +194 -0
  287. package/models/Firebase.js +17 -15
  288. package/models/book/Book.d.ts +24 -28
  289. package/models/book/Book.js +120 -113
  290. package/models/book/BookMedia.d.ts +3 -3
  291. package/models/book/BookMedia.js +22 -16
  292. package/models/book/BookSaveStatus.d.ts +7 -0
  293. package/models/book/BookSaveStatus.js +8 -0
  294. package/models/book/Chapter.d.ts +46 -39
  295. package/models/book/Chapter.js +180 -198
  296. package/models/book/ChapterID.js +7 -7
  297. package/models/book/Definition.d.ts +1 -1
  298. package/models/book/Edition.d.ts +62 -60
  299. package/models/book/Edition.js +385 -303
  300. package/models/book/Reference.d.ts +24 -0
  301. package/models/book/Reference.js +78 -0
  302. package/models/book/Schema.d.ts +169 -0
  303. package/models/book/Schema.js +114 -0
  304. package/models/book/Theme.d.ts +44 -37
  305. package/models/book/Theme.js +452 -52
  306. package/models/book/ThemeColors.d.ts +1 -1
  307. package/models/book/Words.d.ts +2 -0
  308. package/models/book/Words.js +110 -0
  309. package/models/chapter/AtomNode.d.ts +4 -4
  310. package/models/chapter/AtomNode.js +20 -13
  311. package/models/chapter/BlockNode.d.ts +9 -10
  312. package/models/chapter/BlockNode.js +32 -13
  313. package/models/chapter/BlocksNode.d.ts +10 -10
  314. package/models/chapter/BlocksNode.js +315 -120
  315. package/models/chapter/BlocksNode.test.js +494 -228
  316. package/models/chapter/Bookkeeping.d.ts +1 -1
  317. package/models/chapter/CalloutNode.d.ts +3 -3
  318. package/models/chapter/CalloutNode.js +34 -12
  319. package/models/chapter/Caret.d.ts +9 -7
  320. package/models/chapter/Caret.js +11 -6
  321. package/models/chapter/ChapterNode.d.ts +11 -11
  322. package/models/chapter/ChapterNode.js +70 -33
  323. package/models/chapter/CitationsNode.d.ts +3 -3
  324. package/models/chapter/CitationsNode.js +31 -12
  325. package/models/chapter/CodeNode.d.ts +11 -6
  326. package/models/chapter/CodeNode.js +143 -34
  327. package/models/chapter/CommentNode.d.ts +5 -5
  328. package/models/chapter/CommentNode.js +29 -13
  329. package/models/chapter/DefinitionNode.d.ts +2 -2
  330. package/models/chapter/DefinitionNode.js +15 -7
  331. package/models/chapter/Edit.d.ts +3 -3
  332. package/models/chapter/EmbedNode.d.ts +9 -5
  333. package/models/chapter/EmbedNode.js +108 -35
  334. package/models/chapter/ErrorNode.d.ts +2 -2
  335. package/models/chapter/ErrorNode.js +34 -12
  336. package/models/chapter/FootnoteNode.d.ts +5 -5
  337. package/models/chapter/FootnoteNode.js +34 -16
  338. package/models/chapter/FormatNode.d.ts +10 -10
  339. package/models/chapter/FormatNode.js +237 -106
  340. package/models/chapter/FormatNode.test.js +87 -45
  341. package/models/chapter/InlineCodeNode.d.ts +2 -2
  342. package/models/chapter/InlineCodeNode.js +22 -9
  343. package/models/chapter/LabelNode.d.ts +4 -4
  344. package/models/chapter/LabelNode.js +31 -13
  345. package/models/chapter/LinkNode.d.ts +2 -2
  346. package/models/chapter/LinkNode.js +21 -9
  347. package/models/chapter/ListNode.d.ts +8 -8
  348. package/models/chapter/ListNode.js +99 -38
  349. package/models/chapter/ListNode.test.js +29 -24
  350. package/models/chapter/MetadataNode.d.ts +3 -3
  351. package/models/chapter/MetadataNode.js +13 -5
  352. package/models/chapter/Node.d.ts +5 -3
  353. package/models/chapter/Node.js +76 -29
  354. package/models/chapter/Node.test.js +20 -18
  355. package/models/chapter/ParagraphNode.d.ts +6 -6
  356. package/models/chapter/ParagraphNode.js +84 -29
  357. package/models/chapter/ParagraphNode.test.js +22 -13
  358. package/models/chapter/Parser.d.ts +25 -25
  359. package/models/chapter/Parser.js +201 -189
  360. package/models/chapter/Parser.test.js +16 -16
  361. package/models/chapter/Position.d.ts +1 -1
  362. package/models/chapter/QuoteNode.d.ts +6 -6
  363. package/models/chapter/QuoteNode.js +61 -23
  364. package/models/chapter/RootNode.d.ts +4 -4
  365. package/models/chapter/RuleNode.d.ts +2 -2
  366. package/models/chapter/RuleNode.js +31 -11
  367. package/models/chapter/TableNode.d.ts +8 -6
  368. package/models/chapter/TableNode.js +89 -34
  369. package/models/chapter/TableNode.test.js +22 -24
  370. package/models/chapter/TextNode.d.ts +6 -6
  371. package/models/chapter/TextNode.js +72 -32
  372. package/models/chapter/TextNode.test.js +4 -4
  373. package/models/loadEdition.d.ts +1 -1
  374. package/models/loadEdition.js +10 -6
  375. package/package.json +104 -25
  376. package/util/getSubdomain.js +8 -6
  377. package/util/isMobile.js +1 -1
  378. package/util/mineReference.d.ts +3 -2
  379. package/util/mineReference.js +67 -29
  380. package/util/scrollToEyeLevel.js +6 -1
  381. package/components/chapter/renderPosition.d.ts +0 -3
  382. package/components/chapter/renderPosition.js +0 -4
  383. package/components/editor/ToolbarIcon.svelte +0 -22
  384. package/components/editor/ToolbarIcon.svelte.d.ts +0 -16
  385. package/components/page/Alert.svelte +0 -11
  386. package/components/page/Alert.svelte.d.ts +0 -23
  387. package/components/page/Revisions.svelte +0 -124
  388. package/components/page/Revisions.svelte.d.ts +0 -14
  389. package/models/BookLoader.d.ts +0 -2
  390. package/models/BookLoader.js +0 -67
  391. package/models/Firestore.d.ts +0 -22
  392. package/models/Firestore.js +0 -194
  393. package/models/chapter/ReferenceNode.d.ts +0 -29
  394. package/models/chapter/ReferenceNode.js +0 -48
@@ -1,221 +1,203 @@
1
- import Parser from "../chapter/Parser";
2
- import { BookSaveStatus } from "./Edition";
3
- import { loadChapterTextFromFirestore, updateChapterTextInFirestore } from "../Firestore";
1
+ import Parser from '../chapter/Parser';
2
+ import CommonWords from './Words';
4
3
  export default class Chapter {
5
- // The metadata from the database.
6
- spec;
7
- edition;
8
- // Caches
9
- ast;
10
- index;
11
- wordCount;
4
+ // Inputs
5
+ ref;
6
+ id;
7
+ title;
8
+ authors;
9
+ image;
10
+ numbered;
11
+ forthcoming;
12
+ section;
13
+ text;
14
+ // Derived values
15
+ _ast = undefined;
16
+ _index = undefined;
17
+ _wordCount = undefined;
12
18
  // A list of requested edits, stored as promises, resolved
13
19
  // when the book is ready to save.
14
20
  edits = [];
15
21
  lastEdit = 0;
16
22
  // A set of listeners that are notified when the chapter text changes.
17
23
  listeners = new Set();
18
- constructor(edition, spec) {
19
- this.edition = edition;
24
+ constructor(ref, id, title, authors, image, numbered, forthcoming, section, text) {
25
+ this.ref = ref;
26
+ this.id = id;
27
+ this.title = title;
28
+ this.authors = authors.slice();
29
+ this.image = image;
30
+ this.numbered = numbered;
31
+ this.forthcoming = forthcoming;
32
+ this.section = section;
33
+ this.text = text;
34
+ }
35
+ /**
36
+ * Convert a chapter spec and it's text into a chapter object.
37
+ * The spec may contain the text itself, but it may not, so we require it to be
38
+ * repeated here to guarantee its provided.
39
+ */
40
+ static fromJSON(spec, text) {
20
41
  // Copy the spec, filling in defaults as necessary.
21
- this.spec = {
22
- ref: spec.ref,
23
- id: spec.id,
24
- title: spec.title,
25
- authors: spec.authors ?? [],
26
- image: spec.image ?? null,
27
- numbered: spec.numbered === true || spec.numbered === undefined,
28
- forthcoming: spec.forthcoming === true,
29
- text: spec.text
30
- };
31
- // If the chapter has text, then parse it, count searchable words, and compute an index.
32
- if (this.spec.text !== undefined)
33
- this.setText(this.spec.text);
34
- else if (this.spec.ref) {
35
- loadChapterTextFromFirestore(this.spec.ref).then(text => this.setText(text.text));
36
- }
37
- // Otherwise, set them all to undefined.
38
- else {
39
- this.ast = undefined;
40
- this.wordCount = 0;
41
- this.index = undefined;
42
- }
43
- }
44
- saveEdits() {
45
- if (this.edition.editionRef && this.spec.ref && this.spec.text !== undefined) {
46
- // If it's been more than a second since our last edit and there
47
- // are edits that haven't been saved, try updating the book,
48
- // and if we succeed, resolve all of the edits, and if we fail,
49
- // then reject them.
50
- if (Date.now() - this.lastEdit > 1000 && this.edits.length > 0) {
51
- // Tell listeners that this book model changed.
52
- this.edition.notifyListeners(BookSaveStatus.Saving);
53
- updateChapterTextInFirestore(this.edition.editionRef, this.spec.ref, this.spec.text)
54
- .then(() => {
55
- // Approve the edits.
56
- this.edits.forEach(edit => edit.resolve());
57
- this.edition.notifyListeners(BookSaveStatus.Saved);
58
- })
59
- .catch(() => {
60
- // Reject the edits.
61
- this.edits.forEach(edit => edit.reject());
62
- this.edition.notifyListeners(BookSaveStatus.Error);
63
- })
64
- .finally(() => {
65
- // Reset the edit queue.
66
- this.edits = [];
67
- });
68
- }
69
- }
42
+ return new Chapter(spec.ref, spec.id, spec.title, spec.authors ?? [], spec.image ?? null, spec.numbered === true || spec.numbered === undefined, spec.forthcoming === true, spec.section, spec.text ?? text);
70
43
  }
71
- addListener(listener) { this.listeners.add(listener); }
72
- removeListener(listener) { this.listeners.delete(listener); }
73
- notifyListeners() {
74
- this.listeners.forEach(listener => this.spec.text !== undefined ? listener.call(undefined, this.spec.text) : undefined);
75
- }
76
- // Adds a save request to the queue, to be resolved later after a period of
77
- // inactivity. Returns a promise that will eventually be resolved.
78
- requestSave() {
79
- // Tell listeners that this chapter model changed.
80
- this.edition.notifyListeners(BookSaveStatus.Changed);
81
- // Return a promise that will resolve or reject later after this model saves the edits to the database.
82
- this.lastEdit = Date.now();
83
- const promise = new Promise((resolve, reject) => {
84
- this.edits.push({ resolve: resolve, reject: reject });
85
- });
86
- return promise;
87
- }
88
- toObject() {
89
- // Deep copy to prevent external mutations.
90
- const payload = JSON.parse(JSON.stringify(this.spec));
91
- // Reassign a copy of the Firebase ref, since the deep copy doesn't work for it.
92
- payload.ref = this.spec.ref;
44
+ toJSON() {
93
45
  // Note that we don't include the chapter text in the payload; that's stored in the chapters subcollection.
94
46
  // We just return the chapter metadata here, which is stored in the book collection.
95
- delete payload.text;
96
- return payload;
97
- }
98
- getBook() { return this.edition; }
99
- getRef() { return this.spec.ref; }
100
- getChapterID() { return this.spec.id; }
101
- setChapterID(id) {
102
- if (this.spec.id !== id) {
103
- this.spec.id = id;
104
- return this.edition.requestSave();
105
- }
47
+ const json = {
48
+ id: this.id,
49
+ title: this.title,
50
+ authors: this.authors.slice(),
51
+ image: this.image,
52
+ numbered: this.numbered,
53
+ forthcoming: this.forthcoming,
54
+ };
55
+ if (this.ref)
56
+ json.ref = this.ref;
57
+ if (this.section)
58
+ json.section = this.section;
59
+ return json;
106
60
  }
107
- getSection() { return this.spec.section; }
108
- setSection(section) {
109
- if (this.spec.section !== section) {
110
- this.spec.section = section;
111
- return this.edition.requestSave();
112
- }
61
+ getRef() {
62
+ return this.ref;
113
63
  }
114
- isForthcoming() { return this.spec.forthcoming; }
115
- setForthcoming(forthcoming) {
116
- if (this.spec.forthcoming !== forthcoming) {
117
- this.spec.forthcoming = forthcoming;
118
- return this.edition.requestSave();
119
- }
64
+ withRef(ref) {
65
+ return new Chapter(ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text);
120
66
  }
121
- isNumbered() { return this.spec.numbered; }
122
- setNumbered(numbered) {
123
- if (numbered !== this.spec.numbered) {
124
- this.spec.numbered = numbered;
125
- return this.edition.requestSave();
126
- }
67
+ withoutRef() {
68
+ return new Chapter(undefined, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text);
127
69
  }
128
- getText() { return this.spec.text; }
129
- setText(text) {
130
- this.setAST(Parser.parseChapter(this.edition, text));
131
- }
132
- setAST(node) {
133
- this.ast = node;
134
- const newText = this.ast.toBookdown();
135
- const changed = this.spec.text !== newText;
136
- this.spec.text = newText;
137
- this.wordCount = this.ast.toText().split(/\s+/).length;
138
- this.index = this.computeIndex();
139
- // Don't save if its the same. This is just an optimization.
140
- if (changed) {
141
- this.notifyListeners();
142
- if (this.edition.editionRef && this.spec.ref)
143
- return this.requestSave();
144
- }
70
+ getID() {
71
+ return this.id;
145
72
  }
146
- addAuthor(name) {
147
- this.spec.authors.push(name);
148
- return this.edition.requestSave();
73
+ withChapterID(id) {
74
+ return new Chapter(this.ref, id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text);
149
75
  }
150
- getAuthors() { return this.spec.authors; }
151
- setAuthor(index, name) {
152
- if (index >= 0 && index < this.spec.authors.length) {
153
- this.spec.authors[index] = name;
154
- return this.edition.requestSave();
155
- }
76
+ getSection() {
77
+ return this.section;
156
78
  }
157
- removeAuthor(index) {
158
- if (index >= 0 && index < this.spec.authors.length) {
159
- this.spec.authors.splice(index, 1);
160
- return this.edition.requestSave();
161
- }
79
+ withSection(section) {
80
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, section, this.text);
162
81
  }
163
- getTitle() { return this.spec.title; }
164
- setTitle(title) {
165
- if (title !== this.spec.title) {
166
- this.spec.title = title;
167
- return this.edition.requestSave();
168
- }
82
+ isForthcoming() {
83
+ return this.forthcoming;
84
+ }
85
+ asForthcoming(forthcoming) {
86
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, forthcoming, this.section, this.text);
87
+ }
88
+ isNumbered() {
89
+ return this.numbered;
90
+ }
91
+ asNumbered(numbered) {
92
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, numbered, this.forthcoming, this.section, this.text);
93
+ }
94
+ getText() {
95
+ return this.text;
96
+ }
97
+ withText(text) {
98
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, text);
99
+ }
100
+ withAST(ast) {
101
+ const newChapter = new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, ast.toBookdown());
102
+ newChapter._ast = ast;
103
+ return newChapter;
104
+ }
105
+ getAuthors() {
106
+ return this.authors;
107
+ }
108
+ withAuthor(name) {
109
+ return new Chapter(this.ref, this.id, this.title, [...this.authors, name], this.image, this.numbered, this.forthcoming, this.section, this.text);
110
+ }
111
+ withRenamedAuthor(index, name) {
112
+ if (index < 0 || index >= this.authors.length)
113
+ return this;
114
+ return new Chapter(this.ref, this.id, this.title, [
115
+ ...this.authors.slice(0, index),
116
+ name,
117
+ ...this.authors.slice(index + 1),
118
+ ], this.image, this.numbered, this.forthcoming, this.section, this.text);
119
+ }
120
+ withoutAuthor(index) {
121
+ if (index < 0 || index >= this.authors.length)
122
+ return this;
123
+ return new Chapter(this.ref, this.id, this.title, [...this.authors.slice(0, index), ...this.authors.slice(index + 1)], this.image, this.numbered, this.forthcoming, this.section, this.text);
124
+ }
125
+ getTitle() {
126
+ return this.title;
127
+ }
128
+ withTitle(title) {
129
+ return new Chapter(this.ref, this.id, title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text);
130
+ }
131
+ getImage() {
132
+ return this.image;
133
+ }
134
+ withImage(image) {
135
+ return new Chapter(this.ref, this.id, this.title, this.authors, image, this.numbered, this.forthcoming, this.section, this.text);
136
+ }
137
+ getAST(edition) {
138
+ // Compute the cache if necessary
139
+ if (this._ast === undefined)
140
+ this._ast = Parser.parseChapter(edition, this.text);
141
+ return this._ast;
142
+ }
143
+ getWordCount(edition) {
144
+ if (this._wordCount === undefined)
145
+ this._wordCount = this.getAST(edition).toText().split(/\s+/).length;
146
+ return this._wordCount;
169
147
  }
170
- getPosition() { return this.edition.getChapterPosition(this.getChapterID()); }
171
- move(increment) { return this.edition.moveChapter(this.getChapterID(), increment); }
172
- delete() { return this.edition.deleteChapter(this.getChapterID()); }
173
- getImage() { return this.spec.image; }
174
- setImage(embed) {
175
- if (this.spec.image === embed)
176
- return;
177
- this.spec.image = embed;
178
- return this.edition.requestSave();
179
- }
180
- getIndex() { return this.index; }
181
- getAST() { return this.ast; }
182
148
  // Utility function
183
- getReadingTime() { return this.isForthcoming() || !this.wordCount ? undefined : Math.max(1, Math.round(this.wordCount / 150)); }
184
- computeIndex() {
185
- if (!this.ast)
186
- return;
187
- // Build a list of common words
188
- let commonWords = new Set();
189
- ["a", "about", "all", "also", "and", "are", "as", "at", "be", "because", "but", "by", "can", "come", "could", "day", "do", "does", "even", "find", "first", "for", "from", "get", "give", "go", "has", "have", "he", "her", "here", "him", "his", "how", "I", "if", "in", "into", "is", "it", "its", "just", "know", "like", "look", "make", "man", "many", "me", "more", "my", "new", "no", "not", "now", "of", "on", "one", "only", "or", "other", "our", "out", "people", "say", "see", "she", "so", "some", "take", "tell", "than", "that", "the", "their", "them", "then", "there", "these", "they", "thing", "think", "this", "those", "time", "to", "two", "up", "use", "very", "want", "was", "way", "we", "well", "went", "what", "when", "which", "who", "will", "with", "would", "year", "yes", "you", "your"].forEach(word => commonWords.add(word));
190
- // Get all the text in the chapter.
191
- let text = this.ast.toText();
192
- // Split by word boundaries.
193
- const words = text.split(/\b/);
194
- // Index the words
195
- const index = {};
196
- words.forEach((word, wordNumber) => {
197
- // Skip non words. We keep them for search results.
198
- if (!/[a-zA-Z\u2019]+/.test(word))
199
- return;
200
- word = word.toLowerCase();
201
- // Should we include?
202
- // • It shouldn't be a common word
203
- // • It shouldn't have an apostrophe
204
- // • It should be longer than two letters
205
- // • It shouldn't end in 'ly'
206
- if (!(commonWords.has(word)) && word.indexOf('\u2019') < 0 && (word.length > 2 && word.substring(word.length - 2, word.length) !== "ly")) {
207
- // If we haven't started a list of occurrences, start one.
208
- if (!(word in index))
209
- index[word] = [];
210
- let match = {
211
- left: words.slice(Math.max(0, wordNumber - 10), Math.max(0, wordNumber - 1) + 1).join(""),
212
- match: words[wordNumber],
213
- right: words.slice(Math.min(words.length - 1, wordNumber + 1), Math.min(words.length - 1, wordNumber + 10) + 1).join("")
214
- };
215
- // Add the occurrence, but a lower case canonical version.
216
- index[word.toLowerCase()].push(match);
217
- }
218
- });
219
- return index;
149
+ getReadingTime(edition) {
150
+ return this.isForthcoming()
151
+ ? undefined
152
+ : Math.max(1, Math.round(this.getWordCount(edition) / 150));
153
+ }
154
+ getIndex(edition) {
155
+ if (this._index === undefined) {
156
+ const ast = this.getAST(edition);
157
+ // Build a list of common words
158
+ let commonWords = new Set();
159
+ CommonWords.forEach((word) => commonWords.add(word));
160
+ // Get all the text in the chapter.
161
+ let text = ast.toText();
162
+ // Split by word boundaries.
163
+ const words = text.split(/\b/);
164
+ // Index the words
165
+ const index = {};
166
+ words.forEach((word, wordNumber) => {
167
+ // Skip non words. We keep them for search results.
168
+ if (!/[a-zA-Z\u2019]+/.test(word))
169
+ return;
170
+ word = word.toLowerCase();
171
+ // Should we include?
172
+ // • It shouldn't be a common word
173
+ // • It shouldn't have an apostrophe
174
+ // • It should be longer than two letters
175
+ // • It shouldn't end in 'ly'
176
+ if (!commonWords.has(word) &&
177
+ word.indexOf('\u2019') < 0 &&
178
+ word.length > 2 &&
179
+ word.substring(word.length - 2, word.length) !== 'ly') {
180
+ // If we haven't started a list of occurrences, start one.
181
+ if (!(word in index))
182
+ index[word] = [];
183
+ let match = {
184
+ left: words
185
+ .slice(Math.max(0, wordNumber - 10), Math.max(0, wordNumber - 1) + 1)
186
+ .join(''),
187
+ match: words[wordNumber],
188
+ right: words
189
+ .slice(Math.min(words.length - 1, wordNumber + 1), Math.min(words.length - 1, wordNumber + 10) + 1)
190
+ .join(''),
191
+ };
192
+ // Add the occurrence, but a lower case canonical version.
193
+ index[word.toLowerCase()].push(match);
194
+ }
195
+ });
196
+ this._index = index;
197
+ }
198
+ return this._index;
199
+ }
200
+ toString() {
201
+ return `${this.title} by ${this.authors.join(', ')}: ${this.text.substring(0, 32)}}`;
220
202
  }
221
203
  }
@@ -1,10 +1,10 @@
1
1
  const ChapterIDs = {
2
- TableOfContentsID: "",
3
- ReferencesID: "references",
4
- SearchID: "search",
5
- MediaID: "media",
6
- IndexID: "index",
7
- GlossaryID: "glossary",
8
- UnknownID: "unknown"
2
+ TableOfContentsID: '',
3
+ ReferencesID: 'references',
4
+ SearchID: 'search',
5
+ MediaID: 'media',
6
+ IndexID: 'index',
7
+ GlossaryID: 'glossary',
8
+ UnknownID: 'unknown',
9
9
  };
10
10
  export default ChapterIDs;
@@ -1,4 +1,4 @@
1
- declare type Definition = {
1
+ type Definition = {
2
2
  phrase: string;
3
3
  definition: string;
4
4
  synonyms?: string[];
@@ -1,12 +1,14 @@
1
1
  import Chapter from './Chapter';
2
2
  import type { ChapterSpecification } from './Chapter';
3
- import EmbedNode from "../chapter/EmbedNode";
4
- import type ReferenceNode from "../chapter/ReferenceNode";
3
+ import EmbedNode from '../chapter/EmbedNode';
4
+ import Reference from './Reference';
5
5
  import type Theme from './Theme';
6
6
  import type Definition from './Definition.js';
7
- import type Book from './Book.js';
8
7
  import type { DocumentReference } from 'firebase/firestore';
9
- export declare type EditionSpecification = {
8
+ import type Book from './Book';
9
+ import type FormatNode from '../chapter/FormatNode';
10
+ export type EditionSpecification = {
11
+ bookRef?: DocumentReference;
10
12
  title: string;
11
13
  authors: string[];
12
14
  images: Record<string, string | null>;
@@ -15,87 +17,85 @@ export declare type EditionSpecification = {
15
17
  license: string;
16
18
  acknowledgements: string;
17
19
  tags: string[];
18
- revisions: [string, string][];
19
20
  sources: Record<string, string>;
20
21
  references: Record<string, string | string[]>;
21
22
  symbols: Record<string, string>;
22
23
  glossary: Record<string, Definition>;
23
24
  theme: Theme | null;
24
- uids: Array<string>;
25
- bookRef?: DocumentReference;
25
+ uids: string[];
26
26
  };
27
- export declare enum BookSaveStatus {
28
- Changed = 0,
29
- Saving = 1,
30
- Saved = 2,
31
- Error = 3
32
- }
33
27
  export default class Edition {
34
- readonly specification: EditionSpecification;
35
- readonly book: Book | undefined;
36
- editionRef: DocumentReference | undefined;
37
- chapters: Chapter[];
38
- chaptersByID: Record<string, Chapter | undefined>;
39
- listeners: Set<Function>;
40
- edits: {
41
- resolve: Function;
42
- reject: Function;
43
- }[];
44
- lastEdit: number;
45
- constructor(book?: Book, editionRef?: DocumentReference, specification?: EditionSpecification);
46
- setRef(ref: DocumentReference): void;
47
- saveEdits(): Promise<void>;
48
- getBook(): Book | undefined;
49
- addListener(listener: (status: BookSaveStatus) => void): void;
50
- removeListener(listener: Function): void;
51
- notifyListeners(status: BookSaveStatus): void;
52
- requestSave(): Promise<void>;
53
- toObject(): any;
28
+ readonly bookRef: DocumentReference | undefined;
29
+ readonly editionRef: DocumentReference | undefined;
30
+ readonly uids: string[];
31
+ readonly title: string;
32
+ readonly authors: string[];
33
+ readonly images: Record<string, string | null>;
34
+ readonly description: string;
35
+ readonly chapters: Chapter[];
36
+ readonly license: string;
37
+ readonly acknowledgements: string;
38
+ readonly tags: string[];
39
+ readonly sources: Record<string, string>;
40
+ readonly references: Record<string, Reference | FormatNode>;
41
+ readonly symbols: Record<string, string>;
42
+ readonly glossary: Record<string, Definition>;
43
+ readonly theme: Theme | null;
44
+ constructor(bookRef: DocumentReference | undefined, editionRef: DocumentReference | undefined, uids: string[], title: string, authors: string[], 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);
45
+ static fromJSON(editionRef: DocumentReference | undefined, spec: EditionSpecification): Promise<Edition>;
46
+ static parseReference(citationID: string, ref: string | string[], edition: Edition, short?: boolean): FormatNode | Reference;
47
+ toObject(): EditionSpecification;
54
48
  getRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
55
- addUserID(uid: string): void;
49
+ withRef(editionRef: DocumentReference | undefined): Edition;
56
50
  getTitle(): string;
57
- setTitle(title: string): Promise<void>;
51
+ withTitle(title: string): Edition;
58
52
  getDescription(): string;
59
- setDescription(text: string): Promise<void>;
53
+ setDescription(description: string): Edition;
60
54
  getAcknowledgements(): string;
61
- setAcknowledgements(text: string): Promise<void>;
55
+ setAcknowledgements(acks: string): Edition;
62
56
  getLicense(): string;
63
- setLicense(text: string): Promise<void>;
57
+ setLicense(license: string): Edition;
64
58
  getChapters(): Chapter[];
65
59
  hasChapter(chapterID: string): boolean;
66
60
  getChapter(chapterID: string): Chapter | undefined;
61
+ getChapterByRef(ref: DocumentReference): Chapter | undefined;
67
62
  getChapterPosition(chapterID: string): number | undefined;
68
63
  getChapterCount(): number;
69
- addChapter(): Promise<void>;
70
- moveChapter(chapterID: string, increment: number): Promise<void>;
71
- deleteChapter(chapterID: string): Promise<void>;
64
+ withChapters(chapters: Chapter[]): Edition;
65
+ withRevisedChapter(previous: Chapter, edited: Chapter): Edition;
66
+ withoutRefs(): Edition;
67
+ withNewChapter(): Edition;
68
+ withoutChapter(chapterID: string): Edition;
69
+ withMovedChapter(chapterID: string, increment: number): Edition;
72
70
  getSymbols(): Record<string, string>;
73
71
  hasReferences(): boolean;
74
- getReferences(): Record<string, string | string[]>;
75
- getReference(citationID: string): string | string[] | undefined;
76
- addReferences(references: ReferenceNode[]): Promise<void>;
77
- editReference(ref: ReferenceNode): Promise<void> | undefined;
78
- editReferenceID(newCitationID: string, ref: ReferenceNode): Promise<void> | undefined;
79
- removeReference(citationID: string): Promise<void> | undefined;
72
+ getReferences(): Record<string, FormatNode | Reference>;
73
+ getReference(citationID: string): FormatNode | Reference | undefined;
74
+ withReferences(newReferences: Record<string, FormatNode | Reference>): Edition;
75
+ withNewReferences(references: Reference[]): Edition;
76
+ withEditedReference(ref: Reference): Edition;
77
+ withEditedReferenceID(newCitationID: string, ref: Reference): Edition | undefined;
78
+ withoutReference(citationID: string): Edition;
80
79
  hasGlossary(): boolean;
81
80
  getGlossary(): Record<string, Definition>;
82
81
  hasDefinition(id: string): boolean;
83
- addDefinition(id: string, phrase: string, definition: string, synonyms: string[]): Promise<void>;
84
- removeDefinition(id: string): Promise<void>;
85
- editDefinition(id: string, definition: Definition): Promise<void>;
86
- editDefinitionID(id: string, newID: string): Promise<void> | undefined;
82
+ withGlossary(glossary: Record<string, Definition>): Edition;
83
+ withDefinition(id: string, phrase: string, definition: string, synonyms: string[]): Edition;
84
+ withoutDefinition(id: string): Edition;
85
+ withEditedDefinition(id: string, definition: Definition): Edition;
86
+ withEditedDefinitionID(id: string, newID: string): Edition | undefined;
87
87
  getTags(): string[];
88
88
  getTheme(): Theme | null;
89
- setTheme(theme: Theme | null): Promise<void>;
90
- setThemeValue(group: string, name: string, value: string): Promise<void> | undefined;
89
+ withTheme(theme: Theme | null): Edition;
90
+ withThemeValue(group: string, name: string, value: string): Edition;
91
91
  getAuthors(): string[];
92
- addAuthor(name: string): Promise<void>;
93
- setAuthor(index: number, name: string): Promise<void>;
94
- removeAuthor(index: number): Promise<void>;
95
- getRevisions(): [string, string][];
92
+ withAuthors(authors: string[]): Edition;
93
+ withAuthor(name: string): Edition;
94
+ withAuthorName(index: number, name: string): Edition;
95
+ withoutAuthor(index: number): Edition;
96
96
  hasImage(id: string): boolean;
97
97
  getImage(id: string): string | null;
98
- setImage(id: string, embed: string | null): Promise<void> | undefined;
98
+ withImage(id: string, embed: string | null): Edition;
99
99
  getBookReadingTime(): number | undefined;
100
100
  getChapterNumber(chapterID: string): undefined;
101
101
  getSource(sourceID: string): string | null;
@@ -106,6 +106,8 @@ export default class Edition {
106
106
  getNextChapterID(chapterID: string): string | null;
107
107
  getPreviousChapterID(chapterID: string): string | null;
108
108
  getEmbeds(): EmbedNode[];
109
- isLatestPublishedEdition(): boolean;
110
- getEditionNumber(): number | undefined;
109
+ isLatestEdition(book: Book): boolean;
110
+ isLatestPublishedEdition(book: Book): boolean;
111
+ getEditionNumber(book: Book): number | undefined;
112
+ getEditionLabel(book: Book): string;
111
113
  }