bookish-press 0.4.1 → 0.4.3

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 (403) hide show
  1. package/README.md +3 -1
  2. package/components/Auth.svelte +27 -24
  3. package/components/Auth.svelte.d.ts +4 -4
  4. package/components/Authentication.d.ts +2 -2
  5. package/components/BookPreview.svelte +75 -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 +47 -0
  16. package/components/app/Feedback.svelte.d.ts +18 -0
  17. package/components/app/Head.svelte +15 -0
  18. package/components/app/Head.svelte.d.ts +18 -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 +20 -0
  28. package/components/app/Paragraph.svelte.d.ts +18 -0
  29. package/components/app/Section.svelte +12 -0
  30. package/components/app/Section.svelte.d.ts +27 -0
  31. package/components/app/Table.svelte +32 -0
  32. package/components/app/Table.svelte.d.ts +27 -0
  33. package/components/app/TextInput.svelte +38 -0
  34. package/components/app/TextInput.svelte.d.ts +22 -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 +26 -21
  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 +67 -24
  42. package/components/chapter/CaptionedCode.svelte.d.ts +4 -4
  43. package/components/chapter/ChapterBody.svelte +62 -9
  44. package/components/chapter/ChapterBody.svelte.d.ts +5 -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 +39 -17
  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 +155 -67
  54. package/components/chapter/Embed.svelte.d.ts +6 -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 +63 -38
  64. package/components/chapter/Format.svelte.d.ts +5 -4
  65. package/components/chapter/InlineCode.svelte +16 -6
  66. package/components/chapter/InlineCode.svelte.d.ts +4 -4
  67. package/components/chapter/Label.svelte +38 -9
  68. package/components/chapter/Label.svelte.d.ts +4 -4
  69. package/components/chapter/Link.svelte +24 -19
  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 +79 -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 +373 -244
  92. package/components/editor/BookishEditor.svelte.d.ts +9 -6
  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 +82 -0
  101. package/components/editor/CaretView.svelte.d.ts +25 -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 +4 -3
  127. package/components/editor/Note.svelte.d.ts +6 -2
  128. package/components/editor/Permissions.svelte +95 -0
  129. package/components/editor/Permissions.svelte.d.ts +20 -0
  130. package/components/editor/PositionEditor.svelte +9 -6
  131. package/components/editor/PositionEditor.svelte.d.ts +4 -4
  132. package/components/editor/QuoteEditor.svelte +7 -2
  133. package/components/editor/QuoteEditor.svelte.d.ts +4 -4
  134. package/components/editor/Switch.svelte +55 -28
  135. package/components/editor/Switch.svelte.d.ts +4 -4
  136. package/components/editor/TableEditor.svelte +10 -0
  137. package/components/editor/TableEditor.svelte.d.ts +17 -0
  138. package/components/editor/TextEditor.svelte +83 -45
  139. package/components/editor/TextEditor.svelte.d.ts +5 -4
  140. package/components/editor/Toggle.svelte +11 -8
  141. package/components/editor/Toggle.svelte.d.ts +4 -4
  142. package/components/editor/Toolbar.svelte +191 -144
  143. package/components/editor/Toolbar.svelte.d.ts +5 -8
  144. package/components/editor/ToolbarGroup.svelte +17 -23
  145. package/components/editor/ToolbarGroup.svelte.d.ts +3 -4
  146. package/components/editor/ToolbarSpacer.svelte +8 -1
  147. package/components/editor/ToolbarSpacer.svelte.d.ts +6 -2
  148. package/components/editor/URLEditor.svelte +6 -8
  149. package/components/editor/URLEditor.svelte.d.ts +3 -3
  150. package/components/editor/UndoState.d.ts +3 -3
  151. package/components/editor/icons/annotate.svg +1 -0
  152. package/components/editor/icons/block.svg +1 -0
  153. package/components/editor/icons/bold.svg +1 -0
  154. package/components/editor/icons/bullets.svg +1 -0
  155. package/components/editor/icons/callout.svg +1 -0
  156. package/components/editor/icons/citation.svg +8 -0
  157. package/components/editor/icons/clear.svg +1 -0
  158. package/components/editor/icons/clipboard.svg +1 -0
  159. package/components/editor/icons/code.svg +1 -0
  160. package/components/editor/icons/columnafter.svg +1 -0
  161. package/components/editor/icons/columnbefore.svg +1 -0
  162. package/components/editor/icons/comment.svg +1 -0
  163. package/components/editor/icons/copy.svg +1 -0
  164. package/components/editor/icons/cut.svg +1 -0
  165. package/components/editor/icons/define.svg +7 -0
  166. package/components/editor/icons/deletecolumn.svg +1 -0
  167. package/components/editor/icons/deleterow.svg +1 -0
  168. package/components/editor/icons/footnote.svg +8 -0
  169. package/components/editor/icons/header1.svg +7 -0
  170. package/components/editor/icons/header2.svg +7 -0
  171. package/components/editor/icons/header3.svg +7 -0
  172. package/components/editor/icons/home.svg +1 -0
  173. package/components/editor/icons/indent.svg +1 -0
  174. package/components/editor/icons/italic.svg +1 -0
  175. package/components/editor/icons/label.svg +1 -0
  176. package/components/editor/icons/left.svg +1 -0
  177. package/components/editor/icons/level.svg +1 -0
  178. package/components/editor/icons/link.svg +1 -0
  179. package/components/editor/icons/list.svg +1 -0
  180. package/components/editor/icons/media.svg +1 -0
  181. package/components/editor/icons/middle.svg +1 -0
  182. package/components/editor/icons/numbers.svg +10 -0
  183. package/components/editor/icons/paragraph.svg +1 -0
  184. package/components/editor/icons/paste.svg +10 -0
  185. package/components/editor/icons/quote.svg +1 -0
  186. package/components/editor/icons/redo.svg +1 -0
  187. package/components/editor/icons/right.svg +1 -0
  188. package/components/editor/icons/rowabove.svg +1 -0
  189. package/components/editor/icons/rowbelow.svg +1 -0
  190. package/components/editor/icons/rule.svg +1 -0
  191. package/components/editor/icons/sub.svg +1 -0
  192. package/components/editor/icons/super.svg +1 -0
  193. package/components/editor/icons/table.svg +1 -0
  194. package/components/editor/icons/text.svg +1 -0
  195. package/components/editor/icons/time.svg +1 -0
  196. package/components/editor/icons/undo.svg +1 -0
  197. package/components/editor/icons/unindent.svg +1 -0
  198. package/components/editor/icons/unlink.svg +1 -0
  199. package/components/page/Acknowledgements.svelte +35 -24
  200. package/components/page/Acknowledgements.svelte.d.ts +4 -4
  201. package/components/page/Authors.svelte +34 -17
  202. package/components/page/Authors.svelte.d.ts +7 -6
  203. package/components/page/BookLoader.svelte +59 -0
  204. package/components/page/BookLoader.svelte.d.ts +16 -0
  205. package/components/page/BulkReferenceEditor.svelte +54 -23
  206. package/components/page/BulkReferenceEditor.svelte.d.ts +4 -4
  207. package/components/page/Chapter.svelte +234 -143
  208. package/components/page/Chapter.svelte.d.ts +3 -3
  209. package/components/page/ChapterContext.d.ts +4 -4
  210. package/components/page/ChapterNumber.svelte +9 -0
  211. package/components/page/ChapterNumber.svelte.d.ts +27 -0
  212. package/components/page/ChapterTitle.svelte +16 -0
  213. package/components/page/ChapterTitle.svelte.d.ts +18 -0
  214. package/components/page/Contexts.d.ts +42 -22
  215. package/components/page/Contexts.js +129 -17
  216. package/components/page/DefinitionView.svelte +129 -90
  217. package/components/page/DefinitionView.svelte.d.ts +3 -3
  218. package/components/page/Description.svelte +31 -19
  219. package/components/page/Description.svelte.d.ts +4 -4
  220. package/components/page/Edition.svelte +135 -81
  221. package/components/page/Edition.svelte.d.ts +5 -6
  222. package/components/page/EditionLoader.svelte +99 -0
  223. package/components/page/EditionLoader.svelte.d.ts +18 -0
  224. package/components/page/Editions.svelte +106 -0
  225. package/components/page/Editions.svelte.d.ts +14 -0
  226. package/components/page/Glossary.svelte +65 -49
  227. package/components/page/Glossary.svelte.d.ts +4 -4
  228. package/components/page/Header.svelte +143 -56
  229. package/components/page/Header.svelte.d.ts +8 -6
  230. package/components/page/Index.svelte +116 -80
  231. package/components/page/Index.svelte.d.ts +4 -4
  232. package/components/page/Instructions.svelte +18 -17
  233. package/components/page/Instructions.svelte.d.ts +6 -4
  234. package/components/page/License.svelte +39 -23
  235. package/components/page/License.svelte.d.ts +4 -4
  236. package/components/page/Loading.svelte +102 -12
  237. package/components/page/Loading.svelte.d.ts +6 -2
  238. package/components/page/Media.svelte +81 -53
  239. package/components/page/Media.svelte.d.ts +4 -4
  240. package/components/page/MediaPreview.svelte +26 -8
  241. package/components/page/MediaPreview.svelte.d.ts +3 -3
  242. package/components/page/Muted.svelte +10 -0
  243. package/components/page/Muted.svelte.d.ts +27 -0
  244. package/components/page/Outline.svelte +279 -59
  245. package/components/page/Outline.svelte.d.ts +3 -3
  246. package/components/page/Page.svelte +40 -9
  247. package/components/page/Page.svelte.d.ts +3 -3
  248. package/components/page/PageHeader.svelte +14 -0
  249. package/components/page/PageHeader.svelte.d.ts +18 -0
  250. package/components/page/PageParagraph.svelte +18 -0
  251. package/components/page/PageParagraph.svelte.d.ts +27 -0
  252. package/components/page/PossibleChapter.svelte +7 -7
  253. package/components/page/PossibleChapter.svelte.d.ts +4 -4
  254. package/components/page/PossibleReference.svelte +6 -11
  255. package/components/page/PossibleReference.svelte.d.ts +6 -7
  256. package/components/page/Print.svelte +27 -3
  257. package/components/page/Print.svelte.d.ts +4 -4
  258. package/components/page/Publish.svelte +134 -0
  259. package/components/page/Publish.svelte.d.ts +14 -0
  260. package/components/page/Reference.svelte +259 -117
  261. package/components/page/Reference.svelte.d.ts +5 -5
  262. package/components/page/References.svelte +45 -48
  263. package/components/page/References.svelte.d.ts +4 -4
  264. package/components/page/Rows.svelte +54 -0
  265. package/components/page/Rows.svelte.d.ts +27 -0
  266. package/components/page/Search.svelte +88 -63
  267. package/components/page/Search.svelte.d.ts +4 -4
  268. package/components/page/Status.svelte +46 -39
  269. package/components/page/Status.svelte.d.ts +4 -9
  270. package/components/page/SubdomainEditor.svelte +41 -27
  271. package/components/page/SubdomainEditor.svelte.d.ts +4 -4
  272. package/components/page/TableOfContents.svelte +264 -191
  273. package/components/page/TableOfContents.svelte.d.ts +4 -4
  274. package/components/page/TableOfContentsImage.svelte +8 -8
  275. package/components/page/TableOfContentsImage.svelte.d.ts +3 -3
  276. package/components/page/TableOfContentsRow.svelte +97 -34
  277. package/components/page/TableOfContentsRow.svelte.d.ts +4 -4
  278. package/components/page/ThemeEditor.svelte +177 -39
  279. package/components/page/ThemeEditor.svelte.d.ts +4 -4
  280. package/components/page/ThemeEditorPreview.svelte +35 -23
  281. package/components/page/ThemeEditorPreview.svelte.d.ts +5 -5
  282. package/components/page/ThemeSetEditor.svelte +15 -13
  283. package/components/page/ThemeSetEditor.svelte.d.ts +4 -4
  284. package/components/page/ThemeVariableEditor.svelte +24 -15
  285. package/components/page/ThemeVariableEditor.svelte.d.ts +3 -3
  286. package/components/page/Title.svelte +12 -0
  287. package/components/page/Title.svelte.d.ts +27 -0
  288. package/components/page/Unknown.svelte +28 -21
  289. package/components/page/Unknown.svelte.d.ts +4 -4
  290. package/components/page/margins.js +50 -33
  291. package/index.d.ts +13 -0
  292. package/index.js +14 -0
  293. package/models/CRUD.d.ts +27 -0
  294. package/models/CRUD.js +262 -0
  295. package/models/Firebase.d.ts +1 -0
  296. package/models/Firebase.js +26 -16
  297. package/models/book/Book.d.ts +40 -39
  298. package/models/book/Book.js +121 -121
  299. package/models/book/BookMedia.d.ts +3 -3
  300. package/models/book/BookMedia.js +22 -16
  301. package/models/book/BookSaveStatus.d.ts +7 -0
  302. package/models/book/BookSaveStatus.js +8 -0
  303. package/models/book/Chapter.d.ts +50 -39
  304. package/models/book/Chapter.js +189 -198
  305. package/models/book/ChapterID.js +7 -7
  306. package/models/book/Definition.d.ts +1 -1
  307. package/models/book/Edition.d.ts +87 -61
  308. package/models/book/Edition.js +460 -309
  309. package/models/book/Reference.d.ts +24 -0
  310. package/models/book/Reference.js +78 -0
  311. package/models/book/Schema.d.ts +168 -0
  312. package/models/book/Schema.js +115 -0
  313. package/models/book/Theme.d.ts +44 -37
  314. package/models/book/Theme.js +452 -52
  315. package/models/book/ThemeColors.d.ts +1 -1
  316. package/models/book/Words.d.ts +2 -0
  317. package/models/book/Words.js +110 -0
  318. package/models/chapter/AtomNode.d.ts +4 -4
  319. package/models/chapter/AtomNode.js +20 -13
  320. package/models/chapter/BlockNode.d.ts +9 -10
  321. package/models/chapter/BlockNode.js +32 -13
  322. package/models/chapter/BlocksNode.d.ts +10 -10
  323. package/models/chapter/BlocksNode.js +315 -120
  324. package/models/chapter/BlocksNode.test.js +494 -228
  325. package/models/chapter/Bookkeeping.d.ts +1 -1
  326. package/models/chapter/CalloutNode.d.ts +3 -3
  327. package/models/chapter/CalloutNode.js +34 -12
  328. package/models/chapter/Caret.d.ts +9 -7
  329. package/models/chapter/Caret.js +11 -6
  330. package/models/chapter/ChapterNode.d.ts +11 -11
  331. package/models/chapter/ChapterNode.js +70 -33
  332. package/models/chapter/CitationsNode.d.ts +3 -3
  333. package/models/chapter/CitationsNode.js +31 -12
  334. package/models/chapter/CodeNode.d.ts +11 -6
  335. package/models/chapter/CodeNode.js +143 -34
  336. package/models/chapter/CommentNode.d.ts +5 -5
  337. package/models/chapter/CommentNode.js +29 -13
  338. package/models/chapter/DefinitionNode.d.ts +2 -2
  339. package/models/chapter/DefinitionNode.js +15 -7
  340. package/models/chapter/Edit.d.ts +3 -3
  341. package/models/chapter/EmbedNode.d.ts +9 -5
  342. package/models/chapter/EmbedNode.js +108 -35
  343. package/models/chapter/ErrorNode.d.ts +2 -2
  344. package/models/chapter/ErrorNode.js +34 -12
  345. package/models/chapter/FootnoteNode.d.ts +5 -5
  346. package/models/chapter/FootnoteNode.js +34 -16
  347. package/models/chapter/FormatNode.d.ts +10 -10
  348. package/models/chapter/FormatNode.js +237 -106
  349. package/models/chapter/FormatNode.test.js +87 -45
  350. package/models/chapter/InlineCodeNode.d.ts +2 -2
  351. package/models/chapter/InlineCodeNode.js +22 -9
  352. package/models/chapter/LabelNode.d.ts +4 -4
  353. package/models/chapter/LabelNode.js +31 -13
  354. package/models/chapter/LinkNode.d.ts +2 -2
  355. package/models/chapter/LinkNode.js +21 -9
  356. package/models/chapter/ListNode.d.ts +8 -8
  357. package/models/chapter/ListNode.js +99 -38
  358. package/models/chapter/ListNode.test.js +29 -24
  359. package/models/chapter/MetadataNode.d.ts +3 -3
  360. package/models/chapter/MetadataNode.js +13 -5
  361. package/models/chapter/Node.d.ts +5 -3
  362. package/models/chapter/Node.js +76 -29
  363. package/models/chapter/Node.test.js +20 -18
  364. package/models/chapter/ParagraphNode.d.ts +6 -6
  365. package/models/chapter/ParagraphNode.js +84 -29
  366. package/models/chapter/ParagraphNode.test.js +22 -13
  367. package/models/chapter/Parser.d.ts +27 -27
  368. package/models/chapter/Parser.js +220 -206
  369. package/models/chapter/Parser.test.js +16 -16
  370. package/models/chapter/Position.d.ts +1 -1
  371. package/models/chapter/QuoteNode.d.ts +6 -6
  372. package/models/chapter/QuoteNode.js +61 -23
  373. package/models/chapter/RootNode.d.ts +4 -4
  374. package/models/chapter/RuleNode.d.ts +2 -2
  375. package/models/chapter/RuleNode.js +31 -11
  376. package/models/chapter/TableNode.d.ts +8 -6
  377. package/models/chapter/TableNode.js +89 -34
  378. package/models/chapter/TableNode.test.js +22 -24
  379. package/models/chapter/TextNode.d.ts +6 -6
  380. package/models/chapter/TextNode.js +72 -32
  381. package/models/chapter/TextNode.test.js +4 -4
  382. package/package.json +108 -26
  383. package/util/getSubdomain.js +8 -6
  384. package/util/isMobile.js +1 -1
  385. package/util/mineReference.d.ts +3 -2
  386. package/util/mineReference.js +67 -29
  387. package/util/scrollToEyeLevel.js +6 -1
  388. package/components/chapter/renderPosition.d.ts +0 -3
  389. package/components/chapter/renderPosition.js +0 -4
  390. package/components/editor/ToolbarIcon.svelte +0 -22
  391. package/components/editor/ToolbarIcon.svelte.d.ts +0 -16
  392. package/components/page/Alert.svelte +0 -11
  393. package/components/page/Alert.svelte.d.ts +0 -23
  394. package/components/page/Revisions.svelte +0 -124
  395. package/components/page/Revisions.svelte.d.ts +0 -14
  396. package/models/BookLoader.d.ts +0 -2
  397. package/models/BookLoader.js +0 -67
  398. package/models/Firestore.d.ts +0 -22
  399. package/models/Firestore.js +0 -194
  400. package/models/chapter/ReferenceNode.d.ts +0 -29
  401. package/models/chapter/ReferenceNode.js +0 -48
  402. package/models/loadEdition.d.ts +0 -5
  403. package/models/loadEdition.js +0 -16
@@ -1,221 +1,212 @@
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
+ uids;
15
+ // Derived values
16
+ _ast = undefined;
17
+ _index = undefined;
18
+ _wordCount = undefined;
12
19
  // A list of requested edits, stored as promises, resolved
13
20
  // when the book is ready to save.
14
21
  edits = [];
15
22
  lastEdit = 0;
16
23
  // A set of listeners that are notified when the chapter text changes.
17
24
  listeners = new Set();
18
- constructor(edition, spec) {
19
- this.edition = edition;
25
+ constructor(ref, id, title, authors, image, numbered, forthcoming, section, text, uids) {
26
+ this.ref = ref;
27
+ this.id = id;
28
+ this.title = title;
29
+ this.authors = authors.slice();
30
+ this.image = image;
31
+ this.numbered = numbered;
32
+ this.forthcoming = forthcoming;
33
+ this.section = section;
34
+ this.text = text;
35
+ this.uids = uids;
36
+ }
37
+ /**
38
+ * Convert a chapter spec and it's text into a chapter object.
39
+ * The spec may contain the text itself, but it may not, so we require it to be
40
+ * repeated here to guarantee its provided.
41
+ */
42
+ static fromJSON(spec, text) {
20
43
  // 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
- }
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);
70
45
  }
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;
46
+ toJSON() {
93
47
  // Note that we don't include the chapter text in the payload; that's stored in the chapters subcollection.
94
48
  // 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
- }
49
+ const json = {
50
+ id: this.id,
51
+ title: this.title,
52
+ authors: this.authors.slice(),
53
+ image: this.image,
54
+ numbered: this.numbered,
55
+ forthcoming: this.forthcoming,
56
+ uids: this.uids,
57
+ };
58
+ if (this.ref)
59
+ json.ref = this.ref;
60
+ if (this.section)
61
+ json.section = this.section;
62
+ return json;
106
63
  }
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
- }
64
+ getRef() {
65
+ return this.ref;
113
66
  }
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
- }
67
+ withEditors(uids) {
68
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, uids);
120
69
  }
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
- }
70
+ withRef(ref) {
71
+ return new Chapter(ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
127
72
  }
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
- }
73
+ withoutRef() {
74
+ return new Chapter(undefined, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
145
75
  }
146
- addAuthor(name) {
147
- this.spec.authors.push(name);
148
- return this.edition.requestSave();
76
+ getID() {
77
+ return this.id;
149
78
  }
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
- }
79
+ withChapterID(id) {
80
+ return new Chapter(this.ref, id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
156
81
  }
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
- }
82
+ getSection() {
83
+ return this.section;
162
84
  }
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
- }
85
+ withSection(section) {
86
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, section, this.text, this.uids);
87
+ }
88
+ isForthcoming() {
89
+ return this.forthcoming;
90
+ }
91
+ asForthcoming(forthcoming) {
92
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, forthcoming, this.section, this.text, this.uids);
93
+ }
94
+ isNumbered() {
95
+ return this.numbered;
96
+ }
97
+ asNumbered(numbered) {
98
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, numbered, this.forthcoming, this.section, this.text, this.uids);
99
+ }
100
+ isEditor(uid) {
101
+ return this.uids.includes(uid);
102
+ }
103
+ getText() {
104
+ return this.text;
105
+ }
106
+ withText(text) {
107
+ return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, text, this.uids);
108
+ }
109
+ withAST(ast) {
110
+ const newChapter = new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, ast.toBookdown(), this.uids);
111
+ newChapter._ast = ast;
112
+ return newChapter;
113
+ }
114
+ getAuthors() {
115
+ return this.authors;
116
+ }
117
+ withAuthor(name) {
118
+ return new Chapter(this.ref, this.id, this.title, [...this.authors, name], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
119
+ }
120
+ withRenamedAuthor(index, name) {
121
+ if (index < 0 || index >= this.authors.length)
122
+ return this;
123
+ return new Chapter(this.ref, this.id, this.title, [
124
+ ...this.authors.slice(0, index),
125
+ name,
126
+ ...this.authors.slice(index + 1),
127
+ ], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
128
+ }
129
+ withoutAuthor(index) {
130
+ if (index < 0 || index >= this.authors.length)
131
+ return this;
132
+ 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, this.uids);
133
+ }
134
+ getTitle() {
135
+ return this.title;
136
+ }
137
+ withTitle(title) {
138
+ return new Chapter(this.ref, this.id, title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
139
+ }
140
+ getImage() {
141
+ return this.image;
142
+ }
143
+ withImage(image) {
144
+ return new Chapter(this.ref, this.id, this.title, this.authors, image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
145
+ }
146
+ getAST(edition) {
147
+ // Compute the cache if necessary
148
+ if (this._ast === undefined)
149
+ this._ast = Parser.parseChapter(edition, this.text);
150
+ return this._ast;
151
+ }
152
+ getWordCount(edition) {
153
+ if (this._wordCount === undefined)
154
+ this._wordCount = this.getAST(edition).toText().split(/\s+/).length;
155
+ return this._wordCount;
169
156
  }
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
157
  // 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;
158
+ getReadingTime(edition) {
159
+ return this.isForthcoming()
160
+ ? undefined
161
+ : Math.max(1, Math.round(this.getWordCount(edition) / 150));
162
+ }
163
+ getIndex(edition) {
164
+ if (this._index === undefined) {
165
+ const ast = this.getAST(edition);
166
+ // Build a list of common words
167
+ let commonWords = new Set();
168
+ CommonWords.forEach((word) => commonWords.add(word));
169
+ // Get all the text in the chapter.
170
+ let text = ast.toText();
171
+ // Split by word boundaries.
172
+ const words = text.split(/\b/);
173
+ // Index the words
174
+ const index = {};
175
+ words.forEach((word, wordNumber) => {
176
+ // Skip non words. We keep them for search results.
177
+ if (!/[a-zA-Z\u2019]+/.test(word))
178
+ return;
179
+ word = word.toLowerCase();
180
+ // Should we include?
181
+ // • It shouldn't be a common word
182
+ // • It shouldn't have an apostrophe
183
+ // • It should be longer than two letters
184
+ // • It shouldn't end in 'ly'
185
+ if (!commonWords.has(word) &&
186
+ word.indexOf('\u2019') < 0 &&
187
+ word.length > 2 &&
188
+ word.substring(word.length - 2, word.length) !== 'ly') {
189
+ // If we haven't started a list of occurrences, start one.
190
+ if (!(word in index))
191
+ index[word] = [];
192
+ let match = {
193
+ left: words
194
+ .slice(Math.max(0, wordNumber - 10), Math.max(0, wordNumber - 1) + 1)
195
+ .join(''),
196
+ match: words[wordNumber],
197
+ right: words
198
+ .slice(Math.min(words.length - 1, wordNumber + 1), Math.min(words.length - 1, wordNumber + 10) + 1)
199
+ .join(''),
200
+ };
201
+ // Add the occurrence, but a lower case canonical version.
202
+ index[word.toLowerCase()].push(match);
203
+ }
204
+ });
205
+ this._index = index;
206
+ }
207
+ return this._index;
208
+ }
209
+ toString() {
210
+ return `${this.title} by ${this.authors.join(', ')}: ${this.text.substring(0, 32)}}`;
220
211
  }
221
212
  }
@@ -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,13 +1,19 @@
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
+ import type { EditionInfo } from './Book';
11
+ export type EditionSpecification = {
12
+ bookRef: DocumentReference;
10
13
  title: string;
14
+ number: number;
15
+ summary: string;
16
+ published: number | null;
11
17
  authors: string[];
12
18
  images: Record<string, string | null>;
13
19
  description: string;
@@ -15,87 +21,104 @@ export declare type EditionSpecification = {
15
21
  license: string;
16
22
  acknowledgements: string;
17
23
  tags: string[];
18
- revisions: [string, string][];
19
24
  sources: Record<string, string>;
20
25
  references: Record<string, string | string[]>;
21
26
  symbols: Record<string, string>;
22
27
  glossary: Record<string, Definition>;
23
28
  theme: Theme | null;
24
- uids: Array<string>;
25
- bookRef?: DocumentReference;
29
+ uids: string[];
30
+ chapteruids: string[];
31
+ active: Record<string, string>;
26
32
  };
27
- export declare enum BookSaveStatus {
28
- Changed = 0,
29
- Saving = 1,
30
- Saved = 2,
31
- Error = 3
32
- }
33
33
  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;
54
- getRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
55
- addUserID(uid: string): void;
34
+ readonly bookRef: DocumentReference;
35
+ readonly editionRef: DocumentReference | undefined;
36
+ readonly uids: string[];
37
+ readonly title: string;
38
+ readonly authors: string[];
39
+ readonly number: number;
40
+ readonly summary: string;
41
+ readonly published: number | null;
42
+ readonly images: Record<string, string | null>;
43
+ readonly description: string;
44
+ readonly chapters: Chapter[];
45
+ readonly license: string;
46
+ readonly acknowledgements: string;
47
+ readonly tags: string[];
48
+ readonly sources: Record<string, string>;
49
+ readonly references: Record<string, Reference | FormatNode>;
50
+ readonly symbols: Record<string, string>;
51
+ readonly glossary: Record<string, Definition>;
52
+ readonly theme: Theme | null;
53
+ readonly active: Record<string, string>;
54
+ 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, active: Record<string, string>);
55
+ static fromJSON(editionRef: DocumentReference | undefined, spec: EditionSpecification): Edition;
56
+ static parseReference(citationID: string, ref: string | string[], edition: Edition, short?: boolean): FormatNode | Reference;
57
+ toObject(): EditionSpecification;
58
+ getBookRef(): DocumentReference<import("@firebase/firestore").DocumentData>;
59
+ getEditionRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
60
+ getChapterUIDS(): string[];
61
+ withRef(editionRef: DocumentReference | undefined): Edition;
56
62
  getTitle(): string;
57
- setTitle(title: string): Promise<void>;
63
+ withTitle(title: string): Edition;
58
64
  getDescription(): string;
59
- setDescription(text: string): Promise<void>;
65
+ setDescription(description: string): Edition;
60
66
  getAcknowledgements(): string;
61
- setAcknowledgements(text: string): Promise<void>;
67
+ withAcknowledgements(acks: string): Edition;
68
+ withSummary(summary: string): Edition;
69
+ asPublished(published: boolean): Edition;
62
70
  getLicense(): string;
63
- setLicense(text: string): Promise<void>;
71
+ setLicense(license: string): Edition;
64
72
  getChapters(): Chapter[];
65
73
  hasChapter(chapterID: string): boolean;
66
74
  getChapter(chapterID: string): Chapter | undefined;
75
+ getChapterByRef(ref: DocumentReference): Chapter | undefined;
67
76
  getChapterPosition(chapterID: string): number | undefined;
68
77
  getChapterCount(): number;
69
- addChapter(): Promise<void>;
70
- moveChapter(chapterID: string, increment: number): Promise<void>;
71
- deleteChapter(chapterID: string): Promise<void>;
78
+ withChapters(chapters: Chapter[]): Edition;
79
+ withChapterText(text: [DocumentReference, string][]): Edition;
80
+ withRevisedChapter(previous: Chapter, edited: Chapter): Edition;
81
+ withoutRefs(): Edition;
82
+ withIncrementedEditionNumber(): Edition;
83
+ withNewChapter(): Edition;
84
+ withoutChapter(chapterID: string): Edition;
85
+ withMovedChapter(chapterID: string, increment: number): Edition;
72
86
  getSymbols(): Record<string, string>;
73
87
  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;
88
+ getReferences(): Record<string, FormatNode | Reference>;
89
+ getReference(citationID: string): FormatNode | Reference | undefined;
90
+ withReferences(newReferences: Record<string, FormatNode | Reference>): Edition;
91
+ withNewReferences(references: Reference[]): Edition;
92
+ withEditedReference(ref: Reference): Edition;
93
+ withEditedReferenceID(newCitationID: string, ref: Reference): Edition | undefined;
94
+ withoutReference(citationID: string): Edition;
80
95
  hasGlossary(): boolean;
81
96
  getGlossary(): Record<string, Definition>;
82
97
  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;
98
+ withGlossary(glossary: Record<string, Definition>): Edition;
99
+ withDefinition(id: string, phrase: string, definition: string, synonyms: string[]): Edition;
100
+ withoutDefinition(id: string): Edition;
101
+ withEditedDefinition(id: string, definition: Definition): Edition;
102
+ withEditedDefinitionID(id: string, newID: string): Edition | undefined;
87
103
  getTags(): string[];
88
104
  getTheme(): Theme | null;
89
- setTheme(theme: Theme | null): Promise<void>;
90
- setThemeValue(group: string, name: string, value: string): Promise<void> | undefined;
105
+ withTheme(theme: Theme | null): Edition;
106
+ withThemeValue(group: string, name: string, value: string): Edition;
91
107
  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][];
108
+ withAuthors(authors: string[]): Edition;
109
+ withAuthor(name: string): Edition;
110
+ withAuthorName(index: number, name: string): Edition;
111
+ withoutAuthor(index: number): Edition;
112
+ withEditors(uids: string[]): Edition;
96
113
  hasImage(id: string): boolean;
97
114
  getImage(id: string): string | null;
98
- setImage(id: string, embed: string | null): Promise<void> | undefined;
115
+ withImage(id: string, embed: string | null): Edition;
116
+ isEditor(uid: string): boolean;
117
+ isChapterEditor(uid: string): boolean;
118
+ getLeasee(content: string): string | undefined;
119
+ hasLease(uid: string, content: string): boolean;
120
+ isLeased(contentID: string): boolean;
121
+ withLock(uid: string, content: string, lock: boolean): Edition;
99
122
  getBookReadingTime(): number | undefined;
100
123
  getChapterNumber(chapterID: string): undefined;
101
124
  getSource(sourceID: string): string | null;
@@ -106,6 +129,9 @@ export default class Edition {
106
129
  getNextChapterID(chapterID: string): string | null;
107
130
  getPreviousChapterID(chapterID: string): string | null;
108
131
  getEmbeds(): EmbedNode[];
109
- isLatestPublishedEdition(): boolean;
110
- getEditionNumber(): number | undefined;
132
+ isLatestEdition(book: Book): boolean;
133
+ isLatestPublishedEdition(book: Book): boolean;
134
+ getEditionNumber(): number;
135
+ getEditionLabel(): string;
136
+ getInfo(): EditionInfo | undefined;
111
137
  }