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,302 +1,568 @@
1
1
  import { test, expect } from 'vitest';
2
- import CalloutNode from "./CalloutNode";
3
- import ChapterNode from "./ChapterNode";
4
- import CodeNode from "./CodeNode";
5
- import EmbedNode from "./EmbedNode";
6
- import FootnoteNode from "./FootnoteNode";
7
- import FormatNode from "./FormatNode";
8
- import ListNode from "./ListNode";
9
- import ParagraphNode from "./ParagraphNode";
2
+ import CalloutNode from './CalloutNode';
3
+ import ChapterNode from './ChapterNode';
4
+ import CodeNode from './CodeNode';
5
+ import EmbedNode from './EmbedNode';
6
+ import FootnoteNode from './FootnoteNode';
7
+ import FormatNode from './FormatNode';
8
+ import ListNode from './ListNode';
9
+ import ParagraphNode from './ParagraphNode';
10
10
  import Parser from './Parser';
11
- import QuoteNode from "./QuoteNode";
12
- import RuleNode from "./RuleNode";
13
- import TableNode from "./TableNode";
14
- import TextNode from "./TextNode";
15
- const firstText = "First paragraph.";
11
+ import QuoteNode from './QuoteNode';
12
+ import RuleNode from './RuleNode';
13
+ import TableNode from './TableNode';
14
+ import TextNode from './TextNode';
15
+ const firstText = 'First paragraph.';
16
16
  const firstTextNode = new TextNode(firstText);
17
- const firstFormat = new FormatNode("", [firstTextNode]);
17
+ const firstFormat = new FormatNode('', [firstTextNode]);
18
18
  const firstParagraph = new ParagraphNode(0, firstFormat);
19
- const lastText = "Last paragraph.";
19
+ const lastText = 'Last paragraph.';
20
20
  const lastTextNode = new TextNode(lastText);
21
- const lastFormat = new FormatNode("", [lastTextNode]);
21
+ const lastFormat = new FormatNode('', [lastTextNode]);
22
22
  const lastParagraph = new ParagraphNode(0, lastFormat);
23
- const footnoteText = new TextNode("This is my footnote.");
24
- const footnote = new FootnoteNode(new FormatNode("", [footnoteText]));
23
+ const footnoteText = new TextNode('This is my footnote.');
24
+ const footnote = new FootnoteNode(new FormatNode('', [footnoteText]));
25
25
  const paragraphChapter = new ChapterNode([firstParagraph, lastParagraph]);
26
26
  const numberedList = new ListNode([firstFormat, lastFormat], true);
27
27
  const bulletedList = new ListNode([firstFormat.copy(), lastFormat.copy()], false);
28
- const beforeBold = new TextNode("I am a ");
29
- const bold = new TextNode("bold");
30
- const afterBold = new TextNode(" word.");
31
- const boldChapter = new ChapterNode([new ParagraphNode(0, new FormatNode("", [beforeBold, new FormatNode("*", [bold]), afterBold]))]);
32
- test("Insert a block", () => {
33
- expect(paragraphChapter.withBlockInserted(firstParagraph, new RuleNode(), true)?.toBookdown()).toBe(`\n\n-\n\n${firstText}\n\n${lastText}`);
34
- expect(paragraphChapter.withBlockInserted(firstParagraph, new RuleNode(), false)?.toBookdown()).toBe(`${firstText}\n\n-\n\n${lastText}`);
35
- expect(paragraphChapter.withBlockInserted(lastParagraph, new RuleNode(), false)?.toBookdown()).toBe(`${firstText}\n\n${lastText}\n\n-\n\n`);
28
+ const beforeBold = new TextNode('I am a ');
29
+ const bold = new TextNode('bold');
30
+ const afterBold = new TextNode(' word.');
31
+ const boldChapter = new ChapterNode([
32
+ new ParagraphNode(0, new FormatNode('', [beforeBold, new FormatNode('*', [bold]), afterBold])),
33
+ ]);
34
+ const itemOneTextNode = new TextNode('one');
35
+ const itemOneFormat = new FormatNode('', [itemOneTextNode]);
36
+ const itemTwoTextNode = new TextNode('two');
37
+ const itemTwoFormat = new FormatNode('', [itemTwoTextNode]);
38
+ const paragraphListChapter = new ChapterNode([
39
+ firstParagraph,
40
+ new ListNode([itemOneFormat, itemTwoFormat], true),
41
+ lastParagraph,
42
+ ]);
43
+ test('Insert a block', () => {
44
+ expect(paragraphChapter
45
+ .withBlockInserted(firstParagraph, new RuleNode(), true)
46
+ ?.toBookdown()).toBe(`-\n\n${firstText}\n\n${lastText}`);
47
+ expect(paragraphChapter
48
+ .withBlockInserted(firstParagraph, new RuleNode(), false)
49
+ ?.toBookdown()).toBe(`${firstText}\n\n-\n\n${lastText}`);
50
+ expect(paragraphChapter
51
+ .withBlockInserted(lastParagraph, new RuleNode(), false)
52
+ ?.toBookdown()).toBe(`${firstText}\n\n${lastText}\n\n-`);
36
53
  });
37
- test("Remove a block", () => {
54
+ test('Remove a block', () => {
38
55
  expect(paragraphChapter.withoutBlock(firstParagraph)?.toBookdown()).toBe(lastText);
39
56
  });
40
- test("Merge adjascent lists", () => {
41
- expect(new ChapterNode([numberedList, bulletedList]).toBookdown()).toBe(`\n\n1. ${firstText}\n2. ${lastText}\n\n\n\n* ${firstText}\n* ${lastText}\n\n`);
42
- expect(new ChapterNode([numberedList, numberedList]).toBookdown()).toBe(`\n\n1. ${firstText}\n2. ${lastText}\n3. ${firstText}\n4. ${lastText}\n\n`);
43
- expect(new ChapterNode([bulletedList, bulletedList]).toBookdown()).toBe(`\n\n* ${firstText}\n* ${lastText}\n* ${firstText}\n* ${lastText}\n\n`);
57
+ test('Remove all blocks', () => {
58
+ expect(paragraphChapter
59
+ .withoutRange({
60
+ start: { node: firstTextNode, index: 0 },
61
+ end: { node: lastTextNode, index: lastText.length },
62
+ })
63
+ ?.root.toBookdown()).toBe('');
44
64
  });
45
- test("Format range", () => {
65
+ test('Merge adjascent lists', () => {
66
+ expect(new ChapterNode([numberedList, bulletedList]).toBookdown()).toBe(`1. ${firstText}\n2. ${lastText}\n\n* ${firstText}\n* ${lastText}`);
67
+ expect(new ChapterNode([numberedList, numberedList]).toBookdown()).toBe(`1. ${firstText}\n2. ${lastText}\n3. ${firstText}\n4. ${lastText}`);
68
+ expect(new ChapterNode([bulletedList, bulletedList]).toBookdown()).toBe(`* ${firstText}\n* ${lastText}\n* ${firstText}\n* ${lastText}`);
69
+ });
70
+ test('Delete across start of paragraph/list boundary', () => {
71
+ expect(paragraphListChapter
72
+ .withoutRange({
73
+ start: { node: firstTextNode, index: 1 },
74
+ end: { node: itemOneTextNode, index: 1 },
75
+ })
76
+ ?.root.toBookdown()).toBe('F\n\nne\n\n1. two\n\nLast paragraph.');
77
+ });
78
+ test('Delete across end of paragraph/list boundary', () => {
79
+ expect(paragraphListChapter
80
+ .withoutRange({
81
+ start: { node: itemOneTextNode, index: 1 },
82
+ end: { node: lastTextNode, index: 1 },
83
+ })
84
+ ?.root.toBookdown()).toBe('First paragraph.\n\n1. o\n\nast paragraph.');
85
+ });
86
+ test('Format range', () => {
46
87
  // Bold part of a paragraph.
47
- expect(paragraphChapter.withRangeFormatted({ start: { node: firstTextNode, index: 6 }, end: { node: firstTextNode, index: 10 } }, "*")?.root.toBookdown())
48
- .toBe(`First *para*graph.\n\n${lastText}`);
88
+ expect(paragraphChapter
89
+ .withRangeFormatted({
90
+ start: { node: firstTextNode, index: 6 },
91
+ end: { node: firstTextNode, index: 10 },
92
+ }, '*')
93
+ ?.root.toBookdown()).toBe(`First *para*graph.\n\n${lastText}`);
49
94
  // Remove part of a paragraph.
50
- expect(paragraphChapter.withRangeFormatted({ start: { node: firstTextNode, index: 6 }, end: { node: firstTextNode, index: 10 } }, undefined)?.root.toBookdown())
51
- .toBe(`First graph.\n\n${lastText}`);
95
+ expect(paragraphChapter
96
+ .withRangeFormatted({
97
+ start: { node: firstTextNode, index: 6 },
98
+ end: { node: firstTextNode, index: 10 },
99
+ }, undefined)
100
+ ?.root.toBookdown()).toBe(`First graph.\n\n${lastText}`);
52
101
  // Unbold the bold part of a paragraph with the selection outside the bold.
53
- expect(boldChapter.withRangeFormatted({ start: { node: beforeBold, index: beforeBold.getLength() }, end: { node: afterBold, index: 0 } }, "")?.root.toBookdown())
54
- .toBe(`I am a bold word.`);
102
+ expect(boldChapter
103
+ .withRangeFormatted({
104
+ start: { node: beforeBold, index: beforeBold.getLength() },
105
+ end: { node: afterBold, index: 0 },
106
+ }, '')
107
+ ?.root.toBookdown()).toBe(`I am a bold word.`);
55
108
  // Unbold the bold part of a paragraph with the selection inside the bold.
56
- expect(boldChapter.withRangeFormatted({ start: { node: bold, index: 0 }, end: { node: bold, index: bold.getLength() } }, "")?.root.toBookdown())
57
- .toBe(`I am a bold word.`);
109
+ expect(boldChapter
110
+ .withRangeFormatted({
111
+ start: { node: bold, index: 0 },
112
+ end: { node: bold, index: bold.getLength() },
113
+ }, '')
114
+ ?.root.toBookdown()).toBe(`I am a bold word.`);
58
115
  // Expand the bold part of a paragraph.
59
- expect(boldChapter.withRangeFormatted({ start: { node: beforeBold, index: beforeBold.getLength() - 2 }, end: { node: afterBold, index: 0 } }, "*")?.root.toBookdown())
60
- .toBe(`I am *a bold* word.`);
116
+ expect(boldChapter
117
+ .withRangeFormatted({
118
+ start: {
119
+ node: beforeBold,
120
+ index: beforeBold.getLength() - 2,
121
+ },
122
+ end: { node: afterBold, index: 0 },
123
+ }, '*')
124
+ ?.root.toBookdown()).toBe(`I am *a bold* word.`);
61
125
  // Delete across a paragraph boundary.
62
- expect(paragraphChapter.withoutRange({ start: { node: firstTextNode, index: 6 }, end: { node: lastTextNode, index: 5 } })?.root.toBookdown())
63
- .toBe(`First paragraph.`);
126
+ expect(paragraphChapter
127
+ .withoutRange({
128
+ start: { node: firstTextNode, index: 6 },
129
+ end: { node: lastTextNode, index: 5 },
130
+ })
131
+ ?.root.toBookdown()).toBe(`First paragraph.`);
64
132
  // Bold across a paragraph boundary.
65
- expect(paragraphChapter.withRangeFormatted({ start: { node: firstTextNode, index: 6 }, end: { node: lastTextNode, index: 4 } }, "*")?.root.toBookdown())
66
- .toBe(`First *paragraph.*\n\n*Last* paragraph.`);
133
+ expect(paragraphChapter
134
+ .withRangeFormatted({
135
+ start: { node: firstTextNode, index: 6 },
136
+ end: { node: lastTextNode, index: 4 },
137
+ }, '*')
138
+ ?.root.toBookdown()).toBe(`First *paragraph.*\n\n*Last* paragraph.`);
67
139
  });
68
- test("Split selection", () => {
140
+ test('Split selection', () => {
69
141
  const caret = { node: firstTextNode, index: 5 };
70
142
  const chapter = new ChapterNode([firstParagraph]);
71
143
  // Split a paragraph
72
144
  const split = chapter.withSelectionSplit({ start: caret, end: caret });
73
- expect(split?.root.toBookdown()).toBe("First\n\n paragraph.");
74
- expect(split?.range.start.node.toBookdown()).toBe(" paragraph.");
145
+ expect(split?.root.toBookdown()).toBe('First\n\n paragraph.');
146
+ expect(split?.range.start.node.toBookdown()).toBe(' paragraph.');
75
147
  expect(split?.range.start.index).toBe(0);
76
148
  // Delete a selection and then split
77
- const selectSplit = chapter.withSelectionSplit({ start: { node: firstTextNode, index: 5 }, end: { node: firstTextNode, index: 10 } });
78
- expect(selectSplit?.root.toBookdown()).toBe("First\n\ngraph.");
149
+ const selectSplit = chapter.withSelectionSplit({
150
+ start: { node: firstTextNode, index: 5 },
151
+ end: { node: firstTextNode, index: 10 },
152
+ });
153
+ expect(selectSplit?.root.toBookdown()).toBe('First\n\ngraph.');
79
154
  // Split at the beginning
80
155
  const startCaret = { node: firstTextNode, index: 0 };
81
- const startSplit = chapter.withSelectionSplit({ start: startCaret, end: startCaret });
156
+ const startSplit = chapter.withSelectionSplit({
157
+ start: startCaret,
158
+ end: startCaret,
159
+ });
82
160
  expect(startSplit?.root.toBookdown()).toBe(`\n\n${firstText}`);
83
161
  // Split at the end
84
162
  const endCaret = { node: firstTextNode, index: 16 };
85
- const endSplit = chapter.withSelectionSplit({ start: endCaret, end: endCaret });
163
+ const endSplit = chapter.withSelectionSplit({
164
+ start: endCaret,
165
+ end: endCaret,
166
+ });
86
167
  expect(endSplit?.root.toBookdown()).toBe(`${firstText}\n\n`);
87
168
  });
88
- test("Without atom", () => {
89
- const chapterAtomEnd = new ChapterNode([new ParagraphNode(0, new FormatNode("", [firstFormat, footnote]))]);
90
- expect(chapterAtomEnd.withoutAtom(footnote)?.root.toBookdown())
91
- .toBe(`${firstText}`);
92
- const chapterAtomBegin = new ChapterNode([new ParagraphNode(0, new FormatNode("", [footnote, firstFormat]))]);
93
- expect(chapterAtomBegin.withoutAtom(footnote)?.root.toBookdown())
94
- .toBe(`${firstText}`);
95
- const chapterAtomMiddle = new ChapterNode([new ParagraphNode(0, new FormatNode("", [firstFormat, footnote, lastFormat]))]);
96
- expect(chapterAtomMiddle.withoutAtom(footnote)?.root.toBookdown())
97
- .toBe(`${firstText}${lastText}`);
169
+ test('Without atom', () => {
170
+ const chapterAtomEnd = new ChapterNode([
171
+ new ParagraphNode(0, new FormatNode('', [firstFormat, footnote])),
172
+ ]);
173
+ expect(chapterAtomEnd.withoutAtom(footnote)?.root.toBookdown()).toBe(`${firstText}`);
174
+ const chapterAtomBegin = new ChapterNode([
175
+ new ParagraphNode(0, new FormatNode('', [footnote, firstFormat])),
176
+ ]);
177
+ expect(chapterAtomBegin.withoutAtom(footnote)?.root.toBookdown()).toBe(`${firstText}`);
178
+ const chapterAtomMiddle = new ChapterNode([
179
+ new ParagraphNode(0, new FormatNode('', [firstFormat, footnote, lastFormat])),
180
+ ]);
181
+ expect(chapterAtomMiddle.withoutAtom(footnote)?.root.toBookdown()).toBe(`${firstText}${lastText}`);
98
182
  });
99
- test("Insert atom", () => {
100
- const endOfFirst = { node: firstTextNode, index: firstTextNode.getLength() };
183
+ test('Insert atom', () => {
184
+ const endOfFirst = {
185
+ node: firstTextNode,
186
+ index: firstTextNode.getLength(),
187
+ };
101
188
  // Insert empty footnote
102
- expect(paragraphChapter.withSegmentAtSelection({ start: endOfFirst, end: endOfFirst }, text => new FootnoteNode(new FormatNode("", [new TextNode(text)])))?.root.toBookdown())
103
- .toBe(`${firstText}{}\n\n${lastText}`);
189
+ expect(paragraphChapter
190
+ .withSegmentAtSelection({ start: endOfFirst, end: endOfFirst }, (text) => new FootnoteNode(new FormatNode('', [new TextNode(text)])))
191
+ ?.root.toBookdown()).toBe(`${firstText}{}\n\n${lastText}`);
104
192
  // Convert selection to footnote
105
- expect(paragraphChapter.withSegmentAtSelection({ start: { node: firstTextNode, index: 6 }, end: { node: firstTextNode, index: 15 } }, text => new FootnoteNode(new FormatNode("", [new TextNode(text)])))?.root.toBookdown())
106
- .toBe(`First {paragraph}.\n\n${lastText}`);
193
+ expect(paragraphChapter
194
+ .withSegmentAtSelection({
195
+ start: { node: firstTextNode, index: 6 },
196
+ end: { node: firstTextNode, index: 15 },
197
+ }, (text) => new FootnoteNode(new FormatNode('', [new TextNode(text)])))
198
+ ?.root.toBookdown()).toBe(`First {paragraph}.\n\n${lastText}`);
107
199
  });
108
- test("Convert paragraphs to lists", () => {
200
+ test('Convert paragraphs to lists', () => {
109
201
  // Convert a single paragraph to a list item.
110
- expect(paragraphChapter.withParagraphsAsLists({ start: { node: firstTextNode, index: 0 }, end: { node: firstTextNode, index: 0 } }, false)?.toBookdown())
111
- .toBe(`\n\n* ${firstText}\n\n${lastText}`);
202
+ expect(paragraphChapter
203
+ .withParagraphsAsLists({
204
+ start: { node: firstTextNode, index: 0 },
205
+ end: { node: firstTextNode, index: 0 },
206
+ }, false)
207
+ ?.toBookdown()).toBe(`* ${firstText}\n\n${lastText}`);
112
208
  // Convert two paragraphs to a single list
113
- expect(paragraphChapter.withParagraphsAsLists({ start: { node: firstTextNode, index: 0 }, end: { node: lastTextNode, index: 0 } }, true)?.toBookdown())
114
- .toBe(`\n\n1. ${firstText}\n2. ${lastText}\n\n`);
209
+ expect(paragraphChapter
210
+ .withParagraphsAsLists({
211
+ start: { node: firstTextNode, index: 0 },
212
+ end: { node: lastTextNode, index: 0 },
213
+ }, true)
214
+ ?.toBookdown()).toBe(`1. ${firstText}\n2. ${lastText}`);
115
215
  // Convert paragraphs that span a blocks boundary to separate lists.
116
- expect(new ChapterNode([firstParagraph, new CalloutNode([lastParagraph])]).withParagraphsAsLists({ start: { node: firstTextNode, index: 0 }, end: { node: lastTextNode, index: 0 } }, true)?.toBookdown())
117
- .toBe(`\n\n1. ${firstText}\n\n\n\n=\n\n\n1. ${lastText}\n\n\n=\n\n`);
216
+ expect(new ChapterNode([firstParagraph, new CalloutNode([lastParagraph])])
217
+ .withParagraphsAsLists({
218
+ start: { node: firstTextNode, index: 0 },
219
+ end: { node: lastTextNode, index: 0 },
220
+ }, true)
221
+ ?.toBookdown()).toBe(`1. ${firstText}\n\n=\n1. ${lastText}\n=`);
118
222
  // Convert non-paragraphs to lists
119
- expect(new ChapterNode([numberedList]).withParagraphsAsLists({ start: { node: firstTextNode, index: 0 }, end: { node: lastTextNode, index: 0 } }, true))
120
- .toBeUndefined();
223
+ expect(new ChapterNode([numberedList]).withParagraphsAsLists({
224
+ start: { node: firstTextNode, index: 0 },
225
+ end: { node: lastTextNode, index: 0 },
226
+ }, true)).toBeUndefined();
121
227
  });
122
- test("Convert lists to paragraphs", () => {
228
+ test('Convert lists to paragraphs', () => {
123
229
  // Convert lists to paragraphs
124
- expect(new ChapterNode([numberedList]).withListsAsParagraphs({ start: { node: firstTextNode, index: 0 }, end: { node: firstTextNode, index: 5 } })?.toBookdown())
125
- .toBe(`\n\n${firstText}\n\n${lastText}\n\n`);
230
+ expect(new ChapterNode([numberedList])
231
+ .withListsAsParagraphs({
232
+ start: { node: firstTextNode, index: 0 },
233
+ end: { node: firstTextNode, index: 5 },
234
+ })
235
+ ?.toBookdown()).toBe(`${firstText}\n\n${lastText}`);
126
236
  // Convert both items to paragraphs.
127
- expect(new ChapterNode([numberedList]).withListsAsParagraphs({ start: { node: firstTextNode, index: 0 }, end: { node: lastTextNode, index: 5 } })?.toBookdown())
128
- .toBe(`\n\n${firstText}\n\n${lastText}\n\n`);
237
+ expect(new ChapterNode([numberedList])
238
+ .withListsAsParagraphs({
239
+ start: { node: firstTextNode, index: 0 },
240
+ end: { node: lastTextNode, index: 5 },
241
+ })
242
+ ?.toBookdown()).toBe(`${firstText}\n\n${lastText}`);
129
243
  // Convert non-list to paragraphs.
130
- expect(paragraphChapter.withListsAsParagraphs({ start: { node: firstTextNode, index: 0 }, end: { node: lastTextNode, index: 5 } })?.toBookdown())
131
- .toBeUndefined();
244
+ expect(paragraphChapter
245
+ .withListsAsParagraphs({
246
+ start: { node: firstTextNode, index: 0 },
247
+ end: { node: lastTextNode, index: 5 },
248
+ })
249
+ ?.toBookdown()).toBeUndefined();
132
250
  // Convert two contiguous lists to paragraphs.
133
- expect(new ChapterNode([numberedList, bulletedList]).withListsAsParagraphs({ start: { node: firstTextNode, index: 0 }, end: { node: bulletedList.getFirstItem()?.getFirstTextNode(), index: 0 } })?.toBookdown())
134
- .toBe(`\n\n${firstText}\n\n${lastText}\n\n\n\n${firstText}\n\n${lastText}\n\n`);
251
+ expect(new ChapterNode([numberedList, bulletedList])
252
+ .withListsAsParagraphs({
253
+ start: { node: firstTextNode, index: 0 },
254
+ end: {
255
+ node: bulletedList
256
+ .getFirstItem()
257
+ ?.getFirstTextNode(),
258
+ index: 0,
259
+ },
260
+ })
261
+ ?.toBookdown()).toBe(`${firstText}\n\n${lastText}\n\n${firstText}\n\n${lastText}`);
135
262
  // Convert two non-contiguous lists to paragraphs.
136
- expect(new ChapterNode([numberedList, new ParagraphNode(0, new FormatNode("", [new TextNode("Intruder!")])), bulletedList]).withListsAsParagraphs({ start: { node: firstTextNode, index: 0 }, end: { node: bulletedList.getFirstItem()?.getFirstTextNode(), index: 0 } })?.toBookdown())
137
- .toBe(`\n\n${firstText}\n\n${lastText}\n\nIntruder!\n\n${firstText}\n\n${lastText}\n\n`);
263
+ expect(new ChapterNode([
264
+ numberedList,
265
+ new ParagraphNode(0, new FormatNode('', [new TextNode('Intruder!')])),
266
+ bulletedList,
267
+ ])
268
+ .withListsAsParagraphs({
269
+ start: { node: firstTextNode, index: 0 },
270
+ end: {
271
+ node: bulletedList
272
+ .getFirstItem()
273
+ ?.getFirstTextNode(),
274
+ index: 0,
275
+ },
276
+ })
277
+ ?.toBookdown()).toBe(`${firstText}\n\n${lastText}\n\nIntruder!\n\n${firstText}\n\n${lastText}`);
138
278
  // Convert various subparts of a nested list into paragraphs.
139
- const oneText = new TextNode("one");
140
- const twoText = new TextNode("two");
141
- const threeText = new TextNode("three");
142
- const fourText = new TextNode("four");
143
- const list = new ListNode([new FormatNode("", [oneText]), new ListNode([new FormatNode("", [twoText]), new FormatNode("", [threeText])], true), new FormatNode("", [fourText])], true);
144
- expect(new ChapterNode([list]).withListsAsParagraphs({ start: { node: oneText, index: 0 }, end: { node: fourText, index: 0 } })?.toBookdown())
145
- .toBe(`\n\n${oneText.getText()}\n\n${twoText.getText()}\n\n${threeText.getText()}\n\n${fourText.getText()}\n\n`);
146
- expect(new ChapterNode([list]).withListsAsParagraphs({ start: { node: oneText, index: 0 }, end: { node: twoText, index: 0 } })?.toBookdown())
147
- .toBe(`\n\n${oneText.getText()}\n\n${twoText.getText()}\n\n${threeText.getText()}\n\n${fourText.getText()}\n\n`);
148
- expect(new ChapterNode([list]).withListsAsParagraphs({ start: { node: twoText, index: 0 }, end: { node: threeText, index: 0 } })?.toBookdown())
149
- .toBe(`\n\n${oneText.getText()}\n\n${twoText.getText()}\n\n${threeText.getText()}\n\n${fourText.getText()}\n\n`);
279
+ const oneText = new TextNode('one');
280
+ const twoText = new TextNode('two');
281
+ const threeText = new TextNode('three');
282
+ const fourText = new TextNode('four');
283
+ const list = new ListNode([
284
+ new FormatNode('', [oneText]),
285
+ new ListNode([
286
+ new FormatNode('', [twoText]),
287
+ new FormatNode('', [threeText]),
288
+ ], true),
289
+ new FormatNode('', [fourText]),
290
+ ], true);
291
+ expect(new ChapterNode([list])
292
+ .withListsAsParagraphs({
293
+ start: { node: oneText, index: 0 },
294
+ end: { node: fourText, index: 0 },
295
+ })
296
+ ?.toBookdown()).toBe(`${oneText.getText()}\n\n${twoText.getText()}\n\n${threeText.getText()}\n\n${fourText.getText()}`);
297
+ expect(new ChapterNode([list])
298
+ .withListsAsParagraphs({
299
+ start: { node: oneText, index: 0 },
300
+ end: { node: twoText, index: 0 },
301
+ })
302
+ ?.toBookdown()).toBe(`${oneText.getText()}\n\n${twoText.getText()}\n\n${threeText.getText()}\n\n${fourText.getText()}`);
303
+ expect(new ChapterNode([list])
304
+ .withListsAsParagraphs({
305
+ start: { node: twoText, index: 0 },
306
+ end: { node: threeText, index: 0 },
307
+ })
308
+ ?.toBookdown()).toBe(`${oneText.getText()}\n\n${twoText.getText()}\n\n${threeText.getText()}\n\n${fourText.getText()}`);
150
309
  });
151
- test("Indent/unindent list items", () => {
152
- expect(new ChapterNode([numberedList]).withListsIndented({ start: { node: firstTextNode, index: 0 }, end: { node: firstTextNode, index: 0 } }, true)?.toBookdown()).toBe("\n\n1.. First paragraph.\n2. Last paragraph.\n\n");
153
- const indented = new ChapterNode([numberedList]).withListsIndented({ start: { node: firstTextNode, index: 0 }, end: { node: lastTextNode, index: 0 } }, true);
154
- expect(indented?.toBookdown()).toBe("\n\n1.. First paragraph.\n2.. Last paragraph.\n\n");
155
- expect(indented?.withListsIndented({ start: { node: firstTextNode, index: 0 }, end: { node: lastTextNode, index: 0 } }, false)?.toBookdown()).toBe("\n\n1. First paragraph.\n2. Last paragraph.\n\n");
310
+ test('Indent/unindent list items', () => {
311
+ expect(new ChapterNode([numberedList])
312
+ .withListsIndented({
313
+ start: { node: firstTextNode, index: 0 },
314
+ end: { node: firstTextNode, index: 0 },
315
+ }, true)
316
+ ?.toBookdown()).toBe('1.. First paragraph.\n2. Last paragraph.');
317
+ const indented = new ChapterNode([numberedList]).withListsIndented({
318
+ start: { node: firstTextNode, index: 0 },
319
+ end: { node: lastTextNode, index: 0 },
320
+ }, true);
321
+ expect(indented?.toBookdown()).toBe('1.. First paragraph.\n2.. Last paragraph.');
322
+ expect(indented
323
+ ?.withListsIndented({
324
+ start: { node: firstTextNode, index: 0 },
325
+ end: { node: lastTextNode, index: 0 },
326
+ }, false)
327
+ ?.toBookdown()).toBe('1. First paragraph.\n2. Last paragraph.');
156
328
  });
157
- test("Style lists", () => {
158
- expect(new ChapterNode([numberedList]).withListAsStyle(numberedList, false)?.toBookdown())
159
- .toBe(`\n\n* ${firstText}\n* ${lastText}\n\n`);
329
+ test('Style lists', () => {
330
+ expect(new ChapterNode([numberedList])
331
+ .withListAsStyle(numberedList, false)
332
+ ?.toBookdown()).toBe(`* ${firstText}\n* ${lastText}`);
160
333
  });
161
- test("Backspace/delete", () => {
334
+ test('Backspace/delete', () => {
162
335
  const chapter = new ChapterNode([firstParagraph, lastParagraph]);
163
- expect(chapter.withoutAdjacentContent({ node: lastTextNode, index: 1 }, true)?.root.toBookdown())
164
- .toBe(`${firstText}\n\nLst paragraph.`);
165
- expect(chapter.withoutAdjacentContent({ node: lastTextNode, index: 1 }, false)?.root.toBookdown())
166
- .toBe(`${firstText}\n\nast paragraph.`);
167
- expect(chapter.withoutAdjacentContent({ node: lastTextNode, index: 0 }, false)?.root.toBookdown())
168
- .toBe(`${firstText}${lastText}`);
169
- expect(chapter.withoutAdjacentContent({ node: firstTextNode, index: firstTextNode.getLength() }, true)?.root.toBookdown())
170
- .toBe(`${firstText}${lastText}`);
171
- expect(chapter.withoutAdjacentContent({ node: firstTextNode, index: 0 }, false)?.root.toBookdown())
172
- .toBeUndefined();
173
- const beforeText = new TextNode("Before");
174
- const beforeParagraph = new ParagraphNode(0, new FormatNode("", [beforeText]));
175
- const afterText = new TextNode("After");
176
- const afterParagraph = new ParagraphNode(0, new FormatNode("", [afterText]));
177
- const listChapter = new ChapterNode([beforeParagraph, numberedList, afterParagraph]);
336
+ expect(chapter
337
+ .withoutAdjacentContent({ node: lastTextNode, index: 1 }, true)
338
+ ?.root.toBookdown()).toBe(`${firstText}\n\nLst paragraph.`);
339
+ expect(chapter
340
+ .withoutAdjacentContent({ node: lastTextNode, index: 1 }, false)
341
+ ?.root.toBookdown()).toBe(`${firstText}\n\nast paragraph.`);
342
+ expect(chapter
343
+ .withoutAdjacentContent({ node: lastTextNode, index: 0 }, false)
344
+ ?.root.toBookdown()).toBe(`${firstText}${lastText}`);
345
+ expect(chapter
346
+ .withoutAdjacentContent({ node: firstTextNode, index: firstTextNode.getLength() }, true)
347
+ ?.root.toBookdown()).toBe(`${firstText}${lastText}`);
348
+ expect(chapter
349
+ .withoutAdjacentContent({ node: firstTextNode, index: 0 }, false)
350
+ ?.root.toBookdown()).toBeUndefined();
351
+ const beforeText = new TextNode('Before');
352
+ const beforeParagraph = new ParagraphNode(0, new FormatNode('', [beforeText]));
353
+ const afterText = new TextNode('After');
354
+ const afterParagraph = new ParagraphNode(0, new FormatNode('', [afterText]));
355
+ const listChapter = new ChapterNode([
356
+ beforeParagraph,
357
+ numberedList,
358
+ afterParagraph,
359
+ ]);
178
360
  // Do nothing when backspacing at the beginning of a list.
179
- expect(listChapter.withoutAdjacentContent({ node: firstTextNode, index: 0 }, false)?.root.toBookdown())
180
- .toBeUndefined();
361
+ expect(listChapter
362
+ .withoutAdjacentContent({ node: firstTextNode, index: 0 }, false)
363
+ ?.root.toBookdown()).toBeUndefined();
181
364
  // Delete a character in a list
182
- expect(listChapter.withoutAdjacentContent({ node: firstTextNode, index: 0 }, true)?.root.toBookdown())
183
- .toBe(`Before\n\n1. irst paragraph.\n2. ${lastText}\n\nAfter`);
365
+ expect(listChapter
366
+ .withoutAdjacentContent({ node: firstTextNode, index: 0 }, true)
367
+ ?.root.toBookdown()).toBe(`Before\n\n1. irst paragraph.\n2. ${lastText}\n\nAfter`);
184
368
  // Can't forward delete into a list
185
- expect(listChapter.withoutAdjacentContent({ node: beforeText, index: beforeText.getLength() }, true)?.root.toBookdown())
186
- .toBe(`Before${firstText}\n\n1. ${lastText}\n\nAfter`);
369
+ expect(listChapter
370
+ .withoutAdjacentContent({ node: beforeText, index: beforeText.getLength() }, true)
371
+ ?.root.toBookdown()).toBe(`Before${firstText}\n\n1. ${lastText}\n\nAfter`);
187
372
  // Backspace a paragraph into the last list item
188
- expect(listChapter.withoutAdjacentContent({ node: afterText, index: 0 }, false)?.root.toBookdown())
189
- .toBe(`Before\n\n1. ${firstText}\n2. ${lastText}After\n\n`);
373
+ expect(listChapter
374
+ .withoutAdjacentContent({ node: afterText, index: 0 }, false)
375
+ ?.root.toBookdown()).toBe(`Before\n\n1. ${firstText}\n2. ${lastText}After`);
190
376
  // Select two list items for deletion.
191
- expect(listChapter.withoutRange({ start: { node: firstTextNode, index: 0 }, end: { node: lastTextNode, index: 5 } })?.root.toBookdown())
192
- .toBe(`Before\n\n1. paragraph.\n\nAfter`);
377
+ expect(listChapter
378
+ .withoutRange({
379
+ start: { node: firstTextNode, index: 0 },
380
+ end: { node: lastTextNode, index: 5 },
381
+ })
382
+ ?.root.toBookdown()).toBe(`Before\n\n1. paragraph.\n\nAfter`);
193
383
  // Backspace over a block
194
384
  const quoteChapter = new ChapterNode([new QuoteNode([]), firstParagraph]);
195
- expect(quoteChapter.withoutAdjacentContent({ node: firstTextNode, index: 0 }, false)?.root.toBookdown())
196
- .toBe(`\n\n${firstText}`);
385
+ expect(quoteChapter
386
+ .withoutAdjacentContent({ node: firstTextNode, index: 0 }, false)
387
+ ?.root.toBookdown()).toBe(`${firstText}`);
197
388
  });
198
- test("Copy/paste", () => {
389
+ test('Copy/paste', () => {
199
390
  // Build a document with everything.
200
- const sentence1 = new TextNode("Hello, I am a sentence.");
201
- const paragraph1 = new ParagraphNode(0, new FormatNode("", [sentence1]));
202
- const sentence2 = new TextNode("Hello, I am another sentence.");
203
- const boldSentence3 = new TextNode(" Can you believe my size?");
204
- const paragraph2 = new ParagraphNode(0, new FormatNode("", [sentence2, new FormatNode("*", [boldSentence3])]));
205
- const sentence3 = new TextNode("Lonely last.");
206
- const paragraph3 = new ParagraphNode(0, new FormatNode("", [sentence3]));
207
- const imageCaption = new TextNode("no image");
208
- const imageCredit = new TextNode("Amy");
209
- const image = new EmbedNode("nope", "nothing", new FormatNode("", [imageCaption]), new FormatNode("", [imageCredit]));
210
- const js = new TextNode("let a = 1;");
211
- const code = new CodeNode(js, "js", "|", new FormatNode("", [new TextNode("assignment")]));
212
- const item1 = new TextNode("one");
213
- const item1a = new TextNode("one a");
214
- const item2 = new TextNode("two");
215
- const item3 = new TextNode("three");
216
- const list = new ListNode([new FormatNode("", [item1]), new ListNode([new FormatNode("", [item1a])], true), new FormatNode("", [item2]), new FormatNode("", [item3])], true);
217
- const afterList = new TextNode("Post-list");
218
- const afterListParagraph = new ParagraphNode(0, new FormatNode("", [afterList]));
219
- const cellr1c1 = new TextNode("a");
220
- const cellr1c2 = new TextNode("b");
221
- const cellr1c3 = new TextNode("c");
222
- const cellr2c1 = new TextNode("d");
223
- const cellr2c2 = new TextNode("e");
224
- const cellr2c3 = new TextNode("f");
225
- const cellr3c1 = new TextNode("g");
226
- const cellr3c2 = new TextNode("h");
227
- const cellr3c3 = new TextNode("i");
391
+ const sentence1 = new TextNode('Hello, I am a sentence.');
392
+ const paragraph1 = new ParagraphNode(0, new FormatNode('', [sentence1]));
393
+ const sentence2 = new TextNode('Hello, I am another sentence.');
394
+ const boldSentence3 = new TextNode(' Can you believe my size?');
395
+ const paragraph2 = new ParagraphNode(0, new FormatNode('', [sentence2, new FormatNode('*', [boldSentence3])]));
396
+ const sentence3 = new TextNode('Lonely last.');
397
+ const paragraph3 = new ParagraphNode(0, new FormatNode('', [sentence3]));
398
+ const imageCaption = new TextNode('no image');
399
+ const imageCredit = new TextNode('Amy');
400
+ const image = new EmbedNode('nope', 'nothing', new FormatNode('', [imageCaption]), new FormatNode('', [imageCredit]));
401
+ const js = new TextNode('let a = 1;');
402
+ const code = new CodeNode(js, 'js', '|', new FormatNode('', [new TextNode('assignment')]));
403
+ const item1 = new TextNode('one');
404
+ const item1a = new TextNode('one a');
405
+ const item2 = new TextNode('two');
406
+ const item3 = new TextNode('three');
407
+ const list = new ListNode([
408
+ new FormatNode('', [item1]),
409
+ new ListNode([new FormatNode('', [item1a])], true),
410
+ new FormatNode('', [item2]),
411
+ new FormatNode('', [item3]),
412
+ ], true);
413
+ const afterList = new TextNode('Post-list');
414
+ const afterListParagraph = new ParagraphNode(0, new FormatNode('', [afterList]));
415
+ const cellr1c1 = new TextNode('a');
416
+ const cellr1c2 = new TextNode('b');
417
+ const cellr1c3 = new TextNode('c');
418
+ const cellr2c1 = new TextNode('d');
419
+ const cellr2c2 = new TextNode('e');
420
+ const cellr2c3 = new TextNode('f');
421
+ const cellr3c1 = new TextNode('g');
422
+ const cellr3c2 = new TextNode('h');
423
+ const cellr3c3 = new TextNode('i');
228
424
  const table = new TableNode([
229
- [new FormatNode("", [cellr1c1]), new FormatNode("", [cellr1c2]), new FormatNode("", [cellr1c3])],
230
- [new FormatNode("", [cellr2c1]), new FormatNode("", [cellr2c2]), new FormatNode("", [cellr2c3])],
231
- [new FormatNode("", [cellr3c1]), new FormatNode("", [cellr3c2]), new FormatNode("", [cellr3c3])]
425
+ [
426
+ new FormatNode('', [cellr1c1]),
427
+ new FormatNode('', [cellr1c2]),
428
+ new FormatNode('', [cellr1c3]),
429
+ ],
430
+ [
431
+ new FormatNode('', [cellr2c1]),
432
+ new FormatNode('', [cellr2c2]),
433
+ new FormatNode('', [cellr2c3]),
434
+ ],
435
+ [
436
+ new FormatNode('', [cellr3c1]),
437
+ new FormatNode('', [cellr3c2]),
438
+ new FormatNode('', [cellr3c3]),
439
+ ],
440
+ ]);
441
+ const calloutOne = new TextNode('one');
442
+ const calloutTwo = new TextNode('two');
443
+ const calloutThree = new TextNode('three');
444
+ const callout = new CalloutNode([
445
+ new ParagraphNode(0, new FormatNode('', [calloutOne])),
446
+ new ParagraphNode(0, new FormatNode('', [calloutTwo])),
447
+ new ParagraphNode(0, new FormatNode('', [calloutThree])),
232
448
  ]);
233
- const calloutOne = new TextNode("one");
234
- const calloutTwo = new TextNode("two");
235
- const calloutThree = new TextNode("three");
236
- const callout = new CalloutNode([new ParagraphNode(0, new FormatNode("", [calloutOne])), new ParagraphNode(0, new FormatNode("", [calloutTwo])), new ParagraphNode(0, new FormatNode("", [calloutThree]))]);
237
449
  const quoteOne = new TextNode("I'm tired");
238
- const quoteCredit = new TextNode("Boomy");
239
- const quote = new QuoteNode([new ParagraphNode(0, new FormatNode("", [quoteOne]))], new FormatNode("", [quoteCredit]));
240
- const chapter = new ChapterNode([paragraph1, paragraph2, paragraph3, image, code, list, afterListParagraph, table, callout, quote]);
241
- const partialSegment = chapter.copyRange({ start: { node: sentence1, index: 12 }, end: { node: sentence1, index: 22 } });
242
- const reversedPartialSegment = chapter.copyRange({ start: { node: sentence1, index: 22 }, end: { node: sentence1, index: 12 } });
243
- const consecutivePartialParagraphs = chapter.copyRange({ start: { node: sentence1, index: 12 }, end: { node: sentence2, index: 5 } });
244
- const threeParagraphs = chapter.copyRange({ start: { node: sentence1, index: sentence1.getLength() - 1 }, end: { node: sentence3, index: 6 } });
450
+ const quoteCredit = new TextNode('Boomy');
451
+ const quote = new QuoteNode([new ParagraphNode(0, new FormatNode('', [quoteOne]))], new FormatNode('', [quoteCredit]));
452
+ const chapter = new ChapterNode([
453
+ paragraph1,
454
+ paragraph2,
455
+ paragraph3,
456
+ image,
457
+ code,
458
+ list,
459
+ afterListParagraph,
460
+ table,
461
+ callout,
462
+ quote,
463
+ ]);
464
+ const partialSegment = chapter.copyRange({
465
+ start: { node: sentence1, index: 12 },
466
+ end: { node: sentence1, index: 22 },
467
+ });
468
+ const reversedPartialSegment = chapter.copyRange({
469
+ start: { node: sentence1, index: 22 },
470
+ end: { node: sentence1, index: 12 },
471
+ });
472
+ const consecutivePartialParagraphs = chapter.copyRange({
473
+ start: { node: sentence1, index: 12 },
474
+ end: { node: sentence2, index: 5 },
475
+ });
476
+ const threeParagraphs = chapter.copyRange({
477
+ start: { node: sentence1, index: sentence1.getLength() - 1 },
478
+ end: { node: sentence3, index: 6 },
479
+ });
245
480
  // Paragraphs
246
- expect(partialSegment?.toBookdown())
247
- .toBe("a sentence");
248
- expect(reversedPartialSegment?.toBookdown())
249
- .toBe("a sentence");
250
- expect(consecutivePartialParagraphs?.toBookdown())
251
- .toBe("a sentence.\n\nHello");
252
- expect(threeParagraphs?.toBookdown())
253
- .toBe(`.\n\n${sentence2.toBookdown()}*${boldSentence3.toBookdown()}*\n\nLonely`);
254
- const partialImageCaption = chapter.copyRange({ start: { node: imageCaption, index: 3 }, end: { node: imageCaption, index: 8 } });
255
- const partialImageCredit = chapter.copyRange({ start: { node: imageCredit, index: 2 }, end: { node: imageCredit, index: 3 } });
256
- const imageCaptionAndCredit = chapter.copyRange({ start: { node: imageCaption, index: 3 }, end: { node: imageCredit, index: 1 } });
257
- const paragraphAndImage = chapter.copyRange({ start: { node: sentence3, index: 7 }, end: { node: imageCaption, index: 2 } });
481
+ expect(partialSegment?.toBookdown()).toBe('a sentence');
482
+ expect(reversedPartialSegment?.toBookdown()).toBe('a sentence');
483
+ expect(consecutivePartialParagraphs?.toBookdown()).toBe('a sentence.\n\nHello');
484
+ expect(threeParagraphs?.toBookdown()).toBe(`.\n\n${sentence2.toBookdown()}*${boldSentence3.toBookdown()}*\n\nLonely`);
485
+ const partialImageCaption = chapter.copyRange({
486
+ start: { node: imageCaption, index: 3 },
487
+ end: { node: imageCaption, index: 8 },
488
+ });
489
+ const partialImageCredit = chapter.copyRange({
490
+ start: { node: imageCredit, index: 2 },
491
+ end: { node: imageCredit, index: 3 },
492
+ });
493
+ const imageCaptionAndCredit = chapter.copyRange({
494
+ start: { node: imageCaption, index: 3 },
495
+ end: { node: imageCredit, index: 1 },
496
+ });
497
+ const paragraphAndImage = chapter.copyRange({
498
+ start: { node: sentence3, index: 7 },
499
+ end: { node: imageCaption, index: 2 },
500
+ });
258
501
  // Images
259
- expect(partialImageCaption?.toBookdown())
260
- .toBe(`image`);
261
- expect(partialImageCredit?.toBookdown())
262
- .toBe(`y`);
263
- expect(imageCaptionAndCredit?.toBookdown())
264
- .toBe(`|nope|nothing|no |my|`);
265
- expect(paragraphAndImage?.toBookdown())
266
- .toBe(`last.\n\n|nope|nothing|no|Amy|\n\n`);
267
- const imageAndCode = chapter.copyRange({ start: { node: imageCredit, index: 0 }, end: { node: js, index: 3 } });
502
+ expect(partialImageCaption?.toBookdown()).toBe(`image`);
503
+ expect(partialImageCredit?.toBookdown()).toBe(`y`);
504
+ expect(imageCaptionAndCredit?.toBookdown()).toBe(`|nope|nothing|image|A|`);
505
+ expect(paragraphAndImage?.toBookdown()).toBe(`last.\n\n|nope|nothing|no||`);
506
+ const imageAndCode = chapter.copyRange({
507
+ start: { node: imageCredit, index: 0 },
508
+ end: { node: js, index: 3 },
509
+ });
268
510
  // Code
269
- expect(imageAndCode?.toBookdown())
270
- .toBe(`\n\n|nope|nothing|no image|Amy|\n\n\n\n\`js\nlet\n\`\n\n`);
271
- const partialList = chapter.copyRange({ start: { node: item1a, index: 4 }, end: { node: item2, index: 1 } });
272
- const partialListAndParagraph = chapter.copyRange({ start: { node: item2, index: 0 }, end: { node: afterList, index: 4 } });
511
+ expect(imageAndCode?.toBookdown()).toBe(`|nope|nothing||Amy|\n\n\`js\nlet\n\``);
512
+ const partialList = chapter.copyRange({
513
+ start: { node: item1a, index: 4 },
514
+ end: { node: item2, index: 1 },
515
+ });
516
+ const partialListAndParagraph = chapter.copyRange({
517
+ start: { node: item2, index: 0 },
518
+ end: { node: afterList, index: 4 },
519
+ });
273
520
  // Lists
274
- expect(partialList?.toBookdown())
275
- .toBe(`1.. a\n2. t`);
276
- expect(partialListAndParagraph?.toBookdown())
277
- .toBe(`\n\n1. two\n2. three\n\nPost`);
521
+ expect(partialList?.toBookdown()).toBe(`1.. a\n2. t`);
522
+ expect(partialListAndParagraph?.toBookdown()).toBe(`1. two\n2. three\n\nPost`);
278
523
  // Tables
279
- const partialTable = chapter.copyRange({ start: { node: cellr2c2, index: 0 }, end: { node: cellr3c2, index: 1 } });
280
- const partialTableAndParagraph = chapter.copyRange({ start: { node: afterList, index: 0 }, end: { node: cellr1c2, index: 1 } });
281
- expect(partialTable?.toBookdown())
282
- .toBe(`,|e|f\n,g|h|\n`);
283
- expect(partialTableAndParagraph?.toBookdown())
284
- .toBe(`Post-list\n\n,a|b|\n\n\n`);
524
+ const partialTable = chapter.copyRange({
525
+ start: { node: cellr2c2, index: 0 },
526
+ end: { node: cellr3c2, index: 1 },
527
+ });
528
+ const partialTableAndParagraph = chapter.copyRange({
529
+ start: { node: afterList, index: 0 },
530
+ end: { node: cellr1c2, index: 1 },
531
+ });
532
+ expect(partialTable?.toBookdown()).toBe(`,|e|f\n,g|h|\n`);
533
+ expect(partialTableAndParagraph?.toBookdown()).toBe(`Post-list\n\n,a|b|\n`);
285
534
  // Callouts
286
- const partialCallout = chapter.copyRange({ start: { node: calloutOne, index: 0 }, end: { node: calloutTwo, index: 1 } });
287
- const partialTableAndCallout = chapter.copyRange({ start: { node: cellr3c3, index: 0 }, end: { node: calloutTwo, index: 3 } });
288
- expect(partialCallout?.toBookdown())
289
- .toBe(`=\none\n\nt\n=`);
290
- expect(partialTableAndCallout?.toBookdown())
291
- .toBe(`\n\n,||i\n\n\n\n\n=\none\n\ntwo\n=\n\n`);
535
+ const partialCallout = chapter.copyRange({
536
+ start: { node: calloutOne, index: 0 },
537
+ end: { node: calloutTwo, index: 1 },
538
+ });
539
+ const partialTableAndCallout = chapter.copyRange({
540
+ start: { node: cellr3c3, index: 0 },
541
+ end: { node: calloutTwo, index: 3 },
542
+ });
543
+ expect(partialCallout?.toBookdown()).toBe(`=\none\n\nt\n=`);
544
+ expect(partialTableAndCallout?.toBookdown()).toBe(`,||i\n\n\n=\none\n\ntwo\n=`);
292
545
  // Quote
293
- const partialCalloutAndQuote = chapter.copyRange({ start: { node: calloutThree, index: 0 }, end: { node: quoteOne, index: 9 } });
294
- expect(partialCalloutAndQuote?.toBookdown())
295
- .toBe(`\n\n=\nthree\n=\n\n\n\n"\nI'm tired\n"\n\n`);
546
+ const partialCalloutAndQuote = chapter.copyRange({
547
+ start: { node: calloutThree, index: 0 },
548
+ end: { node: quoteOne, index: 9 },
549
+ });
550
+ expect(partialCalloutAndQuote?.toBookdown()).toBe(`=\nthree\n=\n\n"\nI'm tired\n"`);
296
551
  });
297
- test("to HTML", () => {
298
- expect(Parser.parseChapter(undefined, "Hi.\n\nI am paragraphs.").toHTML()).toBe("<p>Hi.</p><p>I am paragraphs.</p>");
299
- expect(Parser.parseChapter(undefined, "* I am one\n\n* I am two\n\n* I am three").toHTML()).toBe("<p></p><ul><li>I am one</li><li>I am two</li><li>I am three</li></ul><p></p>");
300
- expect(Parser.parseChapter(undefined, "1. I am one\n\n2. I am two\n\n3. I am three").toHTML()).toBe("<p></p><ol><li>I am one</li><li>I am two</li><li>I am three</li></ol><p></p>");
301
- expect(Parser.parseChapter(undefined, "|image.jpg|A picture|A caption|A credit|").toHTML()).toBe('<p></p><img src="image.jpg" alt="A picture" /><p></p>');
552
+ test.each([
553
+ ['Hi.\n\nI am paragraphs.', '<p>Hi.</p><p>I am paragraphs.</p>'],
554
+ [
555
+ '* I am one\n\n* I am two\n\n* I am three',
556
+ '<ul><li>I am one</li><li>I am two</li><li>I am three</li></ul>',
557
+ ],
558
+ [
559
+ '1. I am one\n\n2. I am two\n\n3. I am three',
560
+ '<ol><li>I am one</li><li>I am two</li><li>I am three</li></ol>',
561
+ ],
562
+ [
563
+ '|image.jpg|A picture|A caption|A credit|',
564
+ '<img src="image.jpg" alt="A picture" />',
565
+ ],
566
+ ])('%s to HTML', (input, output) => {
567
+ expect(Parser.parseChapter(undefined, input).toHTML()).toBe(output);
302
568
  });