bookish-press 0.4.0 → 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 -80
  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,32 +1,63 @@
1
- <script>import Instructions from "./Instructions.svelte";
2
- import { getUniqueReferenceID, mineReference } from "../../util/mineReference";
3
- import ReferenceNode from "../../models/chapter/ReferenceNode";
4
- import { getEdition } from "./Contexts";
1
+ <script>import Instructions from './Instructions.svelte';
2
+ import { getUniqueReferenceID, mineReference, } from '../../util/mineReference';
3
+ import Reference from '../../models/book/Reference';
4
+ import { getEdition, isEditionEditable, isEditionPartiallyEditable, } from './Contexts';
5
+ import Button from '../app/Button.svelte';
5
6
  let edition = getEdition();
6
- let text = "";
7
+ let text = '';
8
+ let editable = isEditionEditable() || isEditionPartiallyEditable();
7
9
  function handleBulkAdd() {
8
10
  // Split by lines, skipping empty lines.
9
- const references = text.split(/\n+/).map(line => mineReference(Object.keys($edition.getReferences()), line));
10
- $edition.addReferences(references)
11
- .catch(() => {
12
- alert("Failed to save references.");
13
- });
11
+ const references = text
12
+ .split(/\n+/)
13
+ .map((line) => mineReference(Object.keys($edition?.getReferences() ?? []), line));
14
+ if ($edition) {
15
+ edition.set($edition.withNewReferences(references));
16
+ text = '';
17
+ }
14
18
  }
15
19
  function handleEmptyAdd() {
16
- $edition.addReferences([new ReferenceNode(getUniqueReferenceID(Object.keys($edition.getReferences())))])
17
- .catch(() => {
18
- alert("Failed to save empty reference.");
19
- });
20
+ if ($edition) {
21
+ edition.set($edition.withNewReferences([
22
+ new Reference(getUniqueReferenceID(Object.keys($edition.getReferences()))),
23
+ ]));
24
+ }
20
25
  }
21
26
  </script>
22
27
 
23
- <Instructions>
24
- To cite references in a chapter, add them here.
25
- You can add one at a time, or try pasting them in bulk, and we'll do our best to pull out the relevant parts, looking for things that look like author lists, years, sources, and URLs.
26
- Be sure to verify it though &mdash; it's likely to get some things wrong!
28
+ <Instructions {editable}>
29
+ To add references to a chapter, add them here first. You can add one at a
30
+ time, or try pasting them in bulk, and this page will try to pull out author
31
+ lists, years, sources, and URLs. Be sure to verify it though &mdash; it's
32
+ likely to get some things wrong.
27
33
  </Instructions>
28
- <div>
29
- <textarea rows={5} bind:value={text} style="width: 100%"></textarea>
30
- <button disabled={text.length === 0} on:click={handleBulkAdd}>Add bulk references</button>
31
- <button on:click={handleEmptyAdd}>Add empty reference</button>
32
- </div>
34
+
35
+ <textarea rows={5} bind:value={text} style="width: 100%" />
36
+ <Button
37
+ tooltip="convert to references"
38
+ disabled={text.length === 0}
39
+ command={handleBulkAdd}>+ bulk references</Button
40
+ >
41
+ <Button tooltip="add empty reference" command={handleEmptyAdd}
42
+ >+ reference</Button
43
+ >
44
+
45
+ <style>
46
+ textarea {
47
+ width: 100%;
48
+ padding: var(--app-chrome-padding);
49
+ font-family: var(--app-font);
50
+ font-size: var(--app-font-size);
51
+ border: none;
52
+ border-top: var(--app-chrome-border-size) solid var(--app-border-color);
53
+ border-bottom: var(--app-chrome-border-size) solid
54
+ var(--app-border-color);
55
+ margin-bottom: var(--app-chrome-padding);
56
+ }
57
+
58
+ textarea:focus {
59
+ border-bottom-color: var(--app-interactive-color);
60
+ border-top-color: var(--app-interactive-color);
61
+ outline: none;
62
+ }
63
+ </style>
@@ -1,14 +1,14 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
- props: {};
3
+ props: Record<string, never>;
4
4
  events: {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  };
7
7
  slots: {};
8
8
  };
9
- export declare type BulkReferenceEditorProps = typeof __propDef.props;
10
- export declare type BulkReferenceEditorEvents = typeof __propDef.events;
11
- export declare type BulkReferenceEditorSlots = typeof __propDef.slots;
9
+ export type BulkReferenceEditorProps = typeof __propDef.props;
10
+ export type BulkReferenceEditorEvents = typeof __propDef.events;
11
+ export type BulkReferenceEditorSlots = typeof __propDef.slots;
12
12
  export default class BulkReferenceEditor extends SvelteComponentTyped<BulkReferenceEditorProps, BulkReferenceEditorEvents, BulkReferenceEditorSlots> {
13
13
  }
14
14
  export {};
@@ -1,6 +1,6 @@
1
- <script>import Parser from "../../models/chapter/Parser";
1
+ <script>import Parser from '../../models/chapter/Parser';
2
2
  import Header from './Header.svelte';
3
- import Authors from "./Authors.svelte";
3
+ import Authors from './Authors.svelte';
4
4
  import Outline from './Outline.svelte';
5
5
  import Page from './Page.svelte';
6
6
  import TextEditor from '../editor/TextEditor.svelte';
@@ -8,25 +8,36 @@ import BookishEditor from '../editor/BookishEditor.svelte';
8
8
  import Toggle from '../editor/Toggle.svelte';
9
9
  import Instructions from './Instructions.svelte';
10
10
  import ChapterBody from '../chapter/ChapterBody.svelte';
11
- import PossibleReference from "./PossibleReference.svelte";
12
- import { CHAPTER, getEdition, isEditable } from "./Contexts";
13
- import { writable } from "svelte/store";
14
- import { onMount, setContext } from "svelte";
15
- import { hideOutlineIfObscured, layoutMarginals } from "./margins";
16
- import scrollToEyeLevel from "../../util/scrollToEyeLevel";
17
- import { goto } from "$app/navigation";
18
- import ChapterNode from "../../models/chapter/ChapterNode";
11
+ import PossibleReference from './PossibleReference.svelte';
12
+ import ChapterNumber from './ChapterNumber.svelte';
13
+ import Problem from '../chapter/Problem.svelte';
14
+ import { CHAPTER, getUser, getBook, getEdition, isBookEditable, isChapterEditable, isEditionPartiallyEditable, getLeasee, lease, setChapter, isEditionEditable, } from './Contexts';
15
+ import { writable } from 'svelte/store';
16
+ import { onMount, setContext } from 'svelte';
17
+ import { hideOutlineIfObscured, layoutMarginals } from './margins';
18
+ import scrollToEyeLevel from '../../util/scrollToEyeLevel';
19
+ import { goto } from '$app/navigation';
20
+ import ChapterNode from '../../models/chapter/ChapterNode';
21
+ import Muted from './Muted.svelte';
22
+ import Title from './Title.svelte';
23
+ import PageHeader from './PageHeader.svelte';
24
+ import Permissions from '../editor/Permissions.svelte';
19
25
  export let chapter;
20
26
  export let print = false;
27
+ let book = getBook();
21
28
  let edition = getEdition();
22
- let editable = isEditable();
29
+ let auth = getUser();
23
30
  // Keep track of the scroll position to facilitate reading during reloads.
24
- function rememberPosition() { localStorage.setItem('scrollposition', "" + window.scrollY); }
31
+ function rememberPosition() {
32
+ localStorage.setItem('scrollposition', '' + window.scrollY);
33
+ }
25
34
  // When the window resizes, the responsive layout might cause the marginals to move to the footer.
26
35
  // when this happens, we want to immediately remove all of the explicit positioning.
27
- function handleResize() { layoutMarginals(); }
36
+ function handleResize() {
37
+ layoutMarginals();
38
+ }
28
39
  // The currently selected marginal; we only do one at a time.
29
- let marginal = undefined;
40
+ let marginal = writable(undefined);
30
41
  // Keep track of which hash mark is scrolled to
31
42
  let highlightedID = undefined;
32
43
  // When this component is mounted...
@@ -40,7 +51,9 @@ onMount(() => {
40
51
  const observeHash = () => {
41
52
  // Get the ID without the hash and the corresponding element
42
53
  const elementID = window.location.hash.substring(1);
43
- const element = elementID ? document.getElementById(elementID) : null;
54
+ const element = elementID
55
+ ? document.getElementById(elementID)
56
+ : null;
44
57
  // If it's not empty, observe it, and remember what we're observing for highlighting
45
58
  if (element) {
46
59
  highlightedID = elementID;
@@ -61,75 +74,62 @@ onMount(() => {
61
74
  window.addEventListener('resize', handleResize);
62
75
  // Remember the scroll position before a refresh.
63
76
  // We have to do all of these because browser support varies.
64
- window.addEventListener("beforeunload", rememberPosition);
65
- window.addEventListener("visibilitychange", rememberPosition);
66
- window.addEventListener("pagehide", rememberPosition);
77
+ window.addEventListener('beforeunload', rememberPosition);
78
+ window.addEventListener('visibilitychange', rememberPosition);
79
+ window.addEventListener('pagehide', rememberPosition);
67
80
  // Start listening for hash changes, since we want to remove them upon scrolling away from them.
68
- window.addEventListener("pushstate", observeHash);
69
- window.addEventListener("popstate", observeHash);
70
- window.addEventListener("hashchange", observeHash);
81
+ window.addEventListener('pushstate', observeHash);
82
+ window.addEventListener('popstate', observeHash);
83
+ window.addEventListener('hashchange', observeHash);
71
84
  // Make an intersection observer to monitor the location of elements selected by the URL hash ID.
72
- const observer = new IntersectionObserver((entries => {
85
+ const observer = new IntersectionObserver((entries) => {
73
86
  // Go through all of the monitored elements
74
- entries.forEach(entry => {
75
- // If the observed element is out of view and in the hash, remove the hash
76
- if (entry.intersectionRatio === 0 && entry.target.id === window.location.hash.substring(1)) {
77
- history.pushState("", document.title, window.location.pathname + window.location.search);
87
+ entries.forEach((entry) => {
88
+ // If the observed element is out of view and in the hash, remove the hash
89
+ if (entry.intersectionRatio === 0 &&
90
+ entry.target.id === window.location.hash.substring(1)) {
91
+ history.pushState('', document.title, window.location.pathname + window.location.search);
78
92
  observer.unobserve(entry.target);
79
93
  highlightedID = undefined;
80
94
  }
81
95
  });
82
- }));
96
+ });
83
97
  // Do an initial check the hash to see if there's an ID to scroll to
84
98
  observeHash();
85
99
  // Position the marginals, since there's new content.
86
100
  layoutMarginals();
87
- // Periodically save the chapter's edits.
88
- const chapterSaverID = setInterval(() => {
89
- $currentChapter.saveEdits();
90
- }, 500);
91
101
  // On cleanup, unsubscribe from everything above.
92
102
  return () => {
93
103
  window.removeEventListener('scroll', handleScroll);
94
104
  window.removeEventListener('resize', handleResize);
95
105
  // Stop listening to page visibility changes.
96
- window.removeEventListener("beforeunload", rememberPosition);
97
- window.removeEventListener("visibilitychange", rememberPosition);
98
- window.removeEventListener("pagehide", rememberPosition);
106
+ window.removeEventListener('beforeunload', rememberPosition);
107
+ window.removeEventListener('visibilitychange', rememberPosition);
108
+ window.removeEventListener('pagehide', rememberPosition);
99
109
  // Delete the remembered position so that the next page scrolls to top.
100
- localStorage.removeItem("scrollposition");
110
+ localStorage.removeItem('scrollposition');
101
111
  // Stop listening for hash changes
102
- window.removeEventListener("pushstate", observeHash);
103
- window.removeEventListener("popstate", observeHash);
104
- window.removeEventListener("hashchange", observeHash);
112
+ window.removeEventListener('pushstate', observeHash);
113
+ window.removeEventListener('popstate', observeHash);
114
+ window.removeEventListener('hashchange', observeHash);
105
115
  // Stop observing everything on unmount
106
116
  observer.disconnect();
107
- // Stop saving.
108
- clearInterval(chapterSaverID);
109
117
  };
110
118
  });
111
119
  // Position the marginals on mount.
112
120
  onMount(() => layoutMarginals());
113
- // Keep track of the current chapter in a store to manage listeners on the chapter.
114
- let currentChapter = writable(chapter);
115
- let chapterChanged = () => currentChapter.set(chapter);
116
- $: {
117
- // Listen to the new edition
118
- $currentChapter.removeListener(chapterChanged);
119
- // Update the current edition.
120
- currentChapter.set(chapter);
121
- // Listen to changes on the book and chapter.
122
- $currentChapter.addListener(chapterChanged);
123
- }
124
121
  // This gets called after the page is done loading. There are various things we scroll to.
125
122
  function scrollToLastLocation() {
126
123
  // In case loading changed marginal positions
127
124
  layoutMarginals();
128
125
  // If there's a word we're trying to highlight in the URL path, scroll to the corresponding match.
129
126
  if (location.search) {
130
- const highlights = document.getElementsByClassName("bookish-text bookish-content-highlight");
127
+ const highlights = document.getElementsByClassName('bookish-text bookish-content-highlight');
131
128
  const num = getHighlightedNumber();
132
- if (num && highlights.length > 0 && num < highlights.length && num >= 0) {
129
+ if (num &&
130
+ highlights.length > 0 &&
131
+ num < highlights.length &&
132
+ num >= 0) {
133
133
  scrollToEyeLevel(highlights[num]);
134
134
  }
135
135
  }
@@ -142,10 +142,13 @@ function scrollToLastLocation() {
142
142
  }
143
143
  }
144
144
  else {
145
- // If we got to this page through a refresh, scroll to
146
- const entries = performance.getEntriesByType("navigation");
145
+ // If we got to this page through a refresh, scroll to
146
+ const entries = performance.getEntriesByType('navigation');
147
147
  const position = localStorage.getItem('scrollposition');
148
- if (position !== null && entries.length > 0 && entries[entries.length - 1].type === "reload") {
148
+ if (position !== null &&
149
+ entries.length > 0 &&
150
+ entries[entries.length - 1]
151
+ .type === 'reload') {
149
152
  // Scroll to the previous position, if there was one, so that refresh preserves position.
150
153
  window.scrollTo(0, parseInt(position));
151
154
  }
@@ -155,39 +158,58 @@ function scrollToLastLocation() {
155
158
  }
156
159
  }
157
160
  }
158
- function getHighlightedWord() { return location.search.split("&")[0]?.split("=")[1] ?? undefined; }
161
+ /** Account for static builds, where location isn't defined */
162
+ function getLocation() {
163
+ return typeof location === 'undefined' ? undefined : location;
164
+ }
165
+ function getHighlightedWord() {
166
+ return getLocation()?.search.split('&')[0]?.split('=')[1] ?? undefined;
167
+ }
159
168
  function getHighlightedNumber() {
160
- const number = location.search.split("&")[1]?.split("=")[1];
169
+ const number = getLocation()?.search.split('&')[1]?.split('=')[1];
161
170
  return number === undefined ? undefined : parseInt(number);
162
171
  }
163
172
  // Prepare to render the chapter by getting some data from the chapter and book.
164
- $: chapterID = $currentChapter.getChapterID();
165
- $: chapterNumber = $edition.getChapterNumber(chapterID);
166
- $: chapterSection = $edition.getChapterSection(chapterID);
167
- $: chapterAST = $currentChapter.getAST();
173
+ $: chapterID = chapter.getID();
174
+ $: chapterNumber = $edition?.getChapterNumber(chapterID);
175
+ $: chapterSection = $edition?.getChapterSection(chapterID);
176
+ $: chapterAST = $edition ? chapter.getAST($edition) : undefined;
168
177
  $: citations = chapterAST ? chapterAST.getCitations() : undefined;
178
+ $: editionNumber = $edition ? $edition.getEditionNumber() : undefined;
169
179
  let chapterStore = writable();
170
180
  setContext(CHAPTER, chapterStore);
171
181
  $: chapterStore.set({
172
182
  chapter: chapter,
173
183
  highlightedWord: getHighlightedWord(),
174
184
  highlightedID: highlightedID,
175
- marginalID: marginal,
176
- setMarginal: (id) => marginal = id,
177
- layoutMarginals: layoutMarginals
185
+ marginal: marginal,
186
+ layoutMarginals: layoutMarginals,
178
187
  });
188
+ let editable = isBookEditable() ||
189
+ isEditionEditable() ||
190
+ isChapterEditable() ||
191
+ ($auth !== undefined &&
192
+ $auth.user !== null &&
193
+ chapter.isEditor($auth.user.uid));
179
194
  </script>
180
195
 
181
- <Page afterLoaded={scrollToLastLocation} title={`${$edition.getTitle()} - ${chapter.getTitle()}`}>
182
- <div class="bookish-chapter">
183
- <Header
196
+ {#if $edition}
197
+ <Page
198
+ afterLoaded={scrollToLastLocation}
199
+ title={`${$edition.getTitle()} - ${chapter.getTitle()}`}
200
+ >
201
+ <Header
202
+ editable={isChapterEditable()}
203
+ id={chapter.id}
184
204
  header={chapter.getTitle()}
185
205
  label="Chapter title"
186
206
  tags={$edition.getTags()}
187
- save={ text => chapter.setTitle(text) }
207
+ save={(text) =>
208
+ setChapter(edition, chapter, chapter.withTitle(text))}
188
209
  getImage={() => chapter.getImage()}
189
- setImage={embed => chapter.setImage(embed)}
190
- print={print}
210
+ setImage={(embed) =>
211
+ setChapter(edition, chapter, chapter.withImage(embed))}
212
+ {print}
191
213
  >
192
214
  <!-- Collapse the outline if a marginal is selected. -->
193
215
  <Outline
@@ -195,10 +217,9 @@ $: chapterStore.set({
195
217
  collapse={marginal !== undefined}
196
218
  previous={$edition.getPreviousChapterID(chapterID)}
197
219
  next={$edition.getNextChapterID(chapterID)}
198
- listener={ expanded => {
220
+ listener={(expanded) => {
199
221
  // If the outline is being expanded, hide the marginal, otherwise leave it alone.
200
- if(expanded)
201
- marginal = undefined;
222
+ if (expanded) marginal.set(undefined);
202
223
 
203
224
  // Check if we need to hide the outline after positioning.
204
225
  hideOutlineIfObscured();
@@ -206,96 +227,166 @@ $: chapterStore.set({
206
227
  />
207
228
  <!-- Add an editable chapter ID if in editor mode -->
208
229
  <svelte:fragment slot="before">
209
- {#if editable }
210
- <span class="bookish-muted">
211
- <TextEditor
212
- startText={chapter.getChapterID()}
230
+ {#if editable && $book}
231
+ <Muted>
232
+ <TextEditor
233
+ text={chapter.getID()}
213
234
  label="Chapter URL ID editor"
214
- save={
215
- // After the ID is edited, reload the page with the new URL.
216
- id => chapter.setChapterID(id)?.then(() => {
217
- const ref = $edition.getRef();
218
- if(ref?.id)
219
- goto(`/write/${ref?.id}/chapter/${id}`)
220
- })
221
- }
235
+ save={// After the ID is edited, reload the page with the new URL.
236
+ (newChapterID) => {
237
+ if ($book) {
238
+ chapter.withChapterID(newChapterID);
239
+ // Navigate to the new ID
240
+ goto(
241
+ `/write/${$book.ref.id}/${editionNumber}/${newChapterID}`
242
+ );
243
+ }
244
+ }}
222
245
  placeholder="chapter ID"
223
- valid={(newChapterID) =>
224
- !/^[a-zA-Z0-9]+$/.test(newChapterID) ? "Chapter IDs must be one or more letters or numbers" :
225
- chapter.getChapterID() !== newChapterID && $edition.hasChapter(newChapterID) ? "There's already a chapter that has this ID." :
226
- undefined
227
- }
246
+ valid={(newChapterID) =>
247
+ !/^[a-zA-Z0-9]+$/.test(newChapterID)
248
+ ? 'Chapter IDs must be one or more letters or numbers'
249
+ : chapter.getID() !== newChapterID &&
250
+ $edition?.hasChapter(newChapterID)
251
+ ? "There's already a chapter that has this ID."
252
+ : undefined}
228
253
  saveOnExit={true}
229
254
  />
230
- <br/>
231
- </span>
255
+ </Muted>
232
256
  {/if}
233
- {#if editable }
234
- <Toggle on={chapter.isNumbered()} save={ on => chapter.setNumbered(on) }>
235
- {#if chapterNumber !== undefined }
236
- <span class="bookish-chapter-number">Chapter {chapterNumber}</span>
237
- {:else}
238
- <span class="bookish-muted">Unnumbered</span>
239
- {/if}
257
+ {#if editable}
258
+ <Toggle
259
+ on={chapter.isNumbered()}
260
+ save={(on) =>
261
+ setChapter(
262
+ edition,
263
+ chapter,
264
+ chapter.asNumbered(on)
265
+ )}
266
+ >
267
+ <ChapterNumber
268
+ >{#if chapterNumber !== undefined}Chapter {chapterNumber}{:else}<Muted
269
+ >Unnumbered</Muted
270
+ >{/if}</ChapterNumber
271
+ >
240
272
  </Toggle>
241
- {:else if chapterNumber !== undefined }
242
- <span class="bookish-chapter-number">Chapter {chapterNumber}</span>
273
+ {:else if chapterNumber !== undefined}
274
+ <ChapterNumber>Chapter {chapterNumber}</ChapterNumber>
243
275
  {/if}
244
- {#if chapterSection !== undefined }
245
- <span class="bookish-section-name">&nbsp;&nbsp;{chapterSection}</span>
276
+ {#if chapterSection !== undefined && chapterSection.length > 0}
277
+ <span class="section-name">{chapterSection}</span>
246
278
  {/if}
247
- </svelte:fragment>
279
+ </svelte:fragment>
248
280
  <!-- If there are chapter authors, render those, otherwise use the book authors -->
249
- <Authors
281
+ <Authors
282
+ editable={isChapterEditable()}
250
283
  slot="after"
251
- authors={ chapter.getAuthors() }
252
- inheritedAuthors={ $edition.getAuthors() }
253
- add={ () => chapter.addAuthor("") }
254
- edit={(index, text) => chapter.setAuthor(index, text) }
255
- remove={index => chapter.removeAuthor(index)}
284
+ authors={chapter.getAuthors()}
285
+ inheritedAuthors={$edition.getAuthors()}
286
+ add={() => setChapter(edition, chapter, chapter.withAuthor(''))}
287
+ edit={(index, text) =>
288
+ setChapter(
289
+ edition,
290
+ chapter,
291
+ chapter.withRenamedAuthor(index, text)
292
+ )}
293
+ remove={(index) =>
294
+ setChapter(edition, chapter, chapter.withoutAuthor(index))}
256
295
  />
257
296
  </Header>
258
- <!-- We load this on the page but hide it; it's used as a filter for highlighing in CSS -->
259
- <img src={"/svg/marker.svg"} alt="highlight mark" style="display: none"/>
260
- <Instructions>
261
- Edit your chapter's title, authors, and cover image above.
262
- You can also change the ID of the chapter, which appears in it's URL.
263
- Write your chapter text below, using the many formatting options in the toolbar above to format text, add headers, lists, tables, comments, citations, footnotes, and more.
264
- It's okay to try things, you can always undo!
265
- Saves are automatic, each time you stop typing.
297
+
298
+ <Instructions {editable}>
299
+ Edit your chapter's title, authors, and cover image above. You can
300
+ also change the ID of the chapter, which is the text that appears in
301
+ the chapter URL. Write your chapter text below, formatting options
302
+ in the toolbar above to add headers, lists, tables, comments,
303
+ citations, footnotes, and more. It's okay to try things, you can
304
+ always undo. Saves are automatic.
266
305
  </Instructions>
267
306
 
268
307
  <!-- Render the chapter body, passing some context -->
269
- {#if chapterAST }
270
- {#if editable }
271
- <BookishEditor
272
- ast={chapterAST}
273
- save={ node => node instanceof ChapterNode ? chapter.setAST(node) : undefined }
274
- chapter={true}
275
- autofocus
276
- component={ChapterBody}
277
- placeholder="Type here"
278
- />
308
+ <section class="chapter-content">
309
+ {#if chapterAST}
310
+ {#if editable}
311
+ <BookishEditor
312
+ text={chapterAST.toBookdown()}
313
+ parser={(text) => Parser.parseChapter($edition, text)}
314
+ save={(ast) =>
315
+ ast instanceof ChapterNode
316
+ ? setChapter(
317
+ edition,
318
+ chapter,
319
+ chapter.withAST(ast)
320
+ )
321
+ : undefined}
322
+ chapter={true}
323
+ autofocus
324
+ component={ChapterBody}
325
+ placeholder="write here"
326
+ leasee={getLeasee(auth, edition, chapter.id)}
327
+ lease={(lock) => lease(auth, edition, chapter.id, lock)}
328
+ />
329
+ {:else}
330
+ <ChapterBody node={chapterAST} />
331
+ {/if}
279
332
  {:else}
280
- <ChapterBody node={chapterAST} />
333
+ <span>Loading...</span>
281
334
  {/if}
282
- {:else}
283
- <span>Loading...</span>
284
- {/if}
285
- {#if citations && citations.size > 0 }
286
- {@const refs = $edition.getReferences() }
287
- <h1 id="references" class="bookish-header">References</h1>
335
+ </section>
336
+
337
+ {#if citations && citations.size > 0}
338
+ {@const refs = $edition.getReferences()}
339
+ <Title>References</Title>
288
340
  <ol>
289
- {#each [...citations].sort() as citationID }
290
- {#if citationID in refs }
291
- <li class={"bookish-reference"} id={"ref-" + citationID}>
292
- <PossibleReference node={Parser.parseReference(citationID, refs[citationID], $edition)}/>
341
+ {#each [...citations].sort() as citationID}
342
+ {#if citationID in refs}
343
+ <li
344
+ class={'bookish-reference'}
345
+ id={'ref-' + citationID}
346
+ >
347
+ <PossibleReference node={refs[citationID]} />
293
348
  </li>
294
349
  {:else}
295
- <li class="bookish-error">Unknown reference: <code>{citationID}</code></li>
350
+ <li
351
+ ><Problem
352
+ >Unknown reference: <code>{citationID}</code
353
+ ></Problem
354
+ ></li
355
+ >
296
356
  {/if}
297
357
  {/each}
298
358
  </ol>
299
359
  {/if}
300
- </div>
301
- </Page>
360
+
361
+ {#if editable || isEditionPartiallyEditable()}
362
+ <PageHeader>Editors</PageHeader>
363
+ <Instructions {editable}
364
+ >These authors can edit this chapter. Add an email here to
365
+ provide chapter-level edit permissions.</Instructions
366
+ >
367
+
368
+ <Permissions
369
+ uids={chapter.uids}
370
+ inheriteduids={Array.from(
371
+ new Set([...$edition.uids, ...($book ? $book.uids : [])])
372
+ )}
373
+ atleastone={false}
374
+ writable={isChapterEditable()}
375
+ change={(uids) =>
376
+ setChapter(edition, chapter, chapter.withEditors(uids))}
377
+ />
378
+ {/if}
379
+ </Page>
380
+ {/if}
381
+
382
+ <style>
383
+ .section-name {
384
+ display: inline-block;
385
+ font-family: var(--bookish-paragraph-font-family);
386
+ font-size: var(--bookish-small-font-size);
387
+ font-weight: normal;
388
+ font-style: normal;
389
+ color: var(--bookish-muted-color);
390
+ line-height: 1em;
391
+ }
392
+ </style>
@@ -10,9 +10,9 @@ declare const __propDef: {
10
10
  };
11
11
  slots: {};
12
12
  };
13
- export declare type ChapterProps = typeof __propDef.props;
14
- export declare type ChapterEvents = typeof __propDef.events;
15
- export declare type ChapterSlots = typeof __propDef.slots;
13
+ export type ChapterProps = typeof __propDef.props;
14
+ export type ChapterEvents = typeof __propDef.events;
15
+ export type ChapterSlots = typeof __propDef.slots;
16
16
  export default class Chapter extends SvelteComponentTyped<ChapterProps, ChapterEvents, ChapterSlots> {
17
17
  }
18
18
  export {};
@@ -1,10 +1,10 @@
1
- import type Chapter from "../../models/book/Chapter";
2
- declare type ChapterContext = {
1
+ import type { Writable } from 'svelte/store';
2
+ import type Chapter from '../../models/book/Chapter';
3
+ type ChapterContext = {
3
4
  chapter: Chapter;
4
5
  highlightedWord?: string;
5
6
  highlightedID?: string;
6
- marginalID?: string;
7
- setMarginal: (id: string | undefined) => void;
7
+ marginal: Writable<string | undefined>;
8
8
  layoutMarginals: () => void;
9
9
  } | undefined;
10
10
  export default ChapterContext;