bookish-press 0.4.47 → 0.4.49
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.
- package/components/Auth.svelte +55 -0
- package/components/Auth.svelte.d.ts +16 -0
- package/{src/lib/components/Authentication.ts → components/Authentication.d.ts} +0 -2
- package/components/Authentication.js +1 -0
- package/{src/lib/components → components}/BookPreview.svelte +22 -27
- package/components/BookPreview.svelte.d.ts +18 -0
- package/{src/lib/components → components}/External.svelte +1 -2
- package/components/External.svelte.d.ts +18 -0
- package/components/Link.svelte +51 -0
- package/components/Link.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/BookList.svelte +3 -6
- package/components/app/BookList.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/Button.svelte +4 -5
- package/components/app/Button.svelte.d.ts +22 -0
- package/{src/lib/components → components}/app/Feedback.svelte +7 -11
- package/components/app/Feedback.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/Head.svelte +1 -2
- package/components/app/Head.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/Large.svelte +0 -0
- package/components/app/Large.svelte.d.ts +27 -0
- package/{src/lib/components → components}/app/Lead.svelte +0 -0
- package/components/app/Lead.svelte.d.ts +27 -0
- package/{src/lib/components → components}/app/Link.svelte +3 -4
- package/components/app/Link.svelte.d.ts +20 -0
- package/{src/lib/components → components}/app/Options.svelte +4 -5
- package/components/app/Options.svelte.d.ts +19 -0
- package/{src/lib/components → components}/app/Paragraph.svelte +1 -2
- package/components/app/Paragraph.svelte.d.ts +18 -0
- package/{src/lib/components → components}/app/Section.svelte +0 -0
- package/components/app/Section.svelte.d.ts +27 -0
- package/{src/lib/components → components}/app/Table.svelte +0 -0
- package/components/app/Table.svelte.d.ts +27 -0
- package/{src/lib/components → components}/app/TextInput.svelte +9 -12
- package/components/app/TextInput.svelte.d.ts +22 -0
- package/{src/lib/components → components}/chapter/Atom.svelte +12 -18
- package/components/chapter/Atom.svelte.d.ts +19 -0
- package/components/chapter/Block.svelte +37 -0
- package/components/chapter/Block.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Callout.svelte +3 -6
- package/components/chapter/Callout.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/CaptionedCode.svelte +13 -21
- package/components/chapter/CaptionedCode.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/ChapterBody.svelte +9 -13
- package/components/chapter/ChapterBody.svelte.d.ts +19 -0
- package/{src/lib/components → components}/chapter/Citations.svelte +33 -34
- package/components/chapter/Citations.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Code.svelte +60 -64
- package/components/chapter/Code.svelte.d.ts +22 -0
- package/{src/lib/components → components}/chapter/Comment.svelte +18 -30
- package/components/chapter/Comment.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Definition.svelte +17 -23
- package/components/chapter/Definition.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Embed.svelte +77 -97
- package/components/chapter/Embed.svelte.d.ts +20 -0
- package/components/chapter/ErrorMessage.svelte +9 -0
- package/components/chapter/ErrorMessage.svelte.d.ts +17 -0
- package/components/chapter/ExtendedPrism.d.ts +2 -0
- package/{src/lib/components → components}/chapter/ExtendedPrism.js +0 -0
- package/{src/lib/components → components}/chapter/Figure.svelte +26 -34
- package/components/chapter/Figure.svelte.d.ts +24 -0
- package/{src/lib/components → components}/chapter/Footnote.svelte +20 -32
- package/components/chapter/Footnote.svelte.d.ts +19 -0
- package/{src/lib/components → components}/chapter/Format.svelte +34 -39
- package/components/chapter/Format.svelte.d.ts +19 -0
- package/{src/lib/components → components}/chapter/InlineCode.svelte +5 -9
- package/components/chapter/InlineCode.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Label.svelte +14 -23
- package/components/chapter/Label.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Link.svelte +21 -27
- package/components/chapter/Link.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/List.svelte +3 -5
- package/components/chapter/List.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Marginal.svelte +41 -54
- package/components/chapter/Marginal.svelte.d.ts +22 -0
- package/{src/lib/components → components}/chapter/Paragraph.svelte +20 -25
- package/components/chapter/Paragraph.svelte.d.ts +18 -0
- package/{src/lib/components → components}/chapter/Positioned.svelte +1 -4
- package/components/chapter/Positioned.svelte.d.ts +19 -0
- package/{src/lib/components → components}/chapter/Problem.svelte +0 -0
- package/components/chapter/Problem.svelte.d.ts +27 -0
- package/components/chapter/Python.svelte +128 -0
- package/components/chapter/Python.svelte.d.ts +18 -0
- package/{src/lib/components → components}/chapter/Quote.svelte +19 -13
- package/components/chapter/Quote.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Rule.svelte +1 -4
- package/components/chapter/Rule.svelte.d.ts +17 -0
- package/{src/lib/components → components}/chapter/Table.svelte +7 -11
- package/components/chapter/Table.svelte.d.ts +17 -0
- package/components/chapter/Text.svelte +87 -0
- package/components/chapter/Text.svelte.d.ts +18 -0
- package/components/editor/BookishEditor.svelte +884 -0
- package/components/editor/BookishEditor.svelte.d.ts +25 -0
- package/components/editor/CalloutEditor.svelte +10 -0
- package/components/editor/CalloutEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/CaptionedCodeEditor.svelte +6 -10
- package/components/editor/CaptionedCodeEditor.svelte.d.ts +17 -0
- package/components/editor/CaretContext.d.ts +50 -0
- package/components/editor/CaretContext.js +1 -0
- package/{src/lib/components/editor/CaretState.ts → components/editor/CaretState.d.ts} +7 -6
- package/components/editor/CaretState.js +1 -0
- package/{src/lib/components/editor/CaretUtilities.ts → components/editor/CaretUtilities.d.ts} +0 -1
- package/components/editor/CaretUtilities.js +1 -0
- package/{src/lib/components → components}/editor/CaretView.svelte +20 -25
- package/components/editor/CaretView.svelte.d.ts +25 -0
- package/components/editor/CitationsEditor.svelte +53 -0
- package/components/editor/CitationsEditor.svelte.d.ts +17 -0
- package/{src/lib/components/editor/Clipboard.ts → components/editor/Clipboard.d.ts} +1 -2
- package/components/editor/Clipboard.js +1 -0
- package/{src/lib/components/editor/Command.ts → components/editor/Command.d.ts} +2 -8
- package/components/editor/Command.js +1 -0
- package/components/editor/Commands.d.ts +3 -0
- package/{src/lib/components/editor/Commands.ts → components/editor/Commands.js} +315 -730
- package/components/editor/ConfirmButton.svelte +49 -0
- package/components/editor/ConfirmButton.svelte.d.ts +19 -0
- package/components/editor/DefinitionEditor.svelte +36 -0
- package/components/editor/DefinitionEditor.svelte.d.ts +17 -0
- package/components/editor/EmbedEditor.svelte +137 -0
- package/components/editor/EmbedEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/Icon.svelte +1 -2
- package/components/editor/Icon.svelte.d.ts +16 -0
- package/{src/lib/components → components}/editor/ImageChooser.svelte +19 -24
- package/components/editor/ImageChooser.svelte.d.ts +18 -0
- package/components/editor/InlineCodeEditor.svelte +12 -0
- package/components/editor/InlineCodeEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/LabelEditor.svelte +9 -14
- package/components/editor/LabelEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/LanguageEditor.svelte +5 -8
- package/components/editor/LanguageEditor.svelte.d.ts +17 -0
- package/components/editor/LinkEditor.svelte +100 -0
- package/components/editor/LinkEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/Note.svelte +0 -0
- package/components/editor/Note.svelte.d.ts +27 -0
- package/{src/lib/components → components}/editor/Permissions.svelte +36 -43
- package/components/editor/Permissions.svelte.d.ts +20 -0
- package/components/editor/PositionEditor.svelte +17 -0
- package/components/editor/PositionEditor.svelte.d.ts +18 -0
- package/components/editor/QuoteEditor.svelte +10 -0
- package/components/editor/QuoteEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/Switch.svelte +11 -14
- package/components/editor/Switch.svelte.d.ts +20 -0
- package/components/editor/TableEditor.svelte +10 -0
- package/components/editor/TableEditor.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/TextEditor.svelte +89 -101
- package/components/editor/TextEditor.svelte.d.ts +24 -0
- package/components/editor/Toggle.svelte +41 -0
- package/components/editor/Toggle.svelte.d.ts +19 -0
- package/components/editor/Toolbar.svelte +249 -0
- package/components/editor/Toolbar.svelte.d.ts +17 -0
- package/{src/lib/components → components}/editor/ToolbarGroup.svelte +3 -5
- package/components/editor/ToolbarGroup.svelte.d.ts +18 -0
- package/{src/lib/components → components}/editor/ToolbarSpacer.svelte +0 -0
- package/components/editor/ToolbarSpacer.svelte.d.ts +23 -0
- package/components/editor/URLEditor.svelte +13 -0
- package/components/editor/URLEditor.svelte.d.ts +18 -0
- package/{src/lib/components/editor/UndoState.ts → components/editor/UndoState.d.ts} +2 -3
- package/components/editor/UndoState.js +1 -0
- package/{src/lib/components → components}/editor/icons/annotate.svg +0 -0
- package/{src/lib/components → components}/editor/icons/block.svg +0 -0
- package/{src/lib/components → components}/editor/icons/bold.svg +0 -0
- package/{src/lib/components → components}/editor/icons/bullets.svg +0 -0
- package/{src/lib/components → components}/editor/icons/callout.svg +0 -0
- package/{src/lib/components → components}/editor/icons/citation.svg +0 -0
- package/{src/lib/components → components}/editor/icons/clear.svg +0 -0
- package/{src/lib/components → components}/editor/icons/clipboard.svg +0 -0
- package/{src/lib/components → components}/editor/icons/code.svg +0 -0
- package/{src/lib/components → components}/editor/icons/columnafter.svg +0 -0
- package/{src/lib/components → components}/editor/icons/columnbefore.svg +0 -0
- package/{src/lib/components → components}/editor/icons/comment.svg +0 -0
- package/{src/lib/components → components}/editor/icons/copy.svg +0 -0
- package/{src/lib/components → components}/editor/icons/cut.svg +0 -0
- package/{src/lib/components → components}/editor/icons/define.svg +0 -0
- package/{src/lib/components → components}/editor/icons/deletecolumn.svg +0 -0
- package/{src/lib/components → components}/editor/icons/deleterow.svg +0 -0
- package/{src/lib/components → components}/editor/icons/footnote.svg +0 -0
- package/{src/lib/components → components}/editor/icons/header1.svg +0 -0
- package/{src/lib/components → components}/editor/icons/header2.svg +0 -0
- package/{src/lib/components → components}/editor/icons/header3.svg +0 -0
- package/{src/lib/components → components}/editor/icons/home.svg +0 -0
- package/{src/lib/components → components}/editor/icons/indent.svg +0 -0
- package/{src/lib/components → components}/editor/icons/italic.svg +0 -0
- package/{src/lib/components → components}/editor/icons/label.svg +0 -0
- package/{src/lib/components → components}/editor/icons/left.svg +0 -0
- package/{src/lib/components → components}/editor/icons/level.svg +0 -0
- package/{src/lib/components → components}/editor/icons/link.svg +0 -0
- package/{src/lib/components → components}/editor/icons/list.svg +0 -0
- package/{src/lib/components → components}/editor/icons/media.svg +0 -0
- package/{src/lib/components → components}/editor/icons/middle.svg +0 -0
- package/{src/lib/components → components}/editor/icons/numbers.svg +0 -0
- package/{src/lib/components → components}/editor/icons/paragraph.svg +0 -0
- package/{src/lib/components → components}/editor/icons/paste.svg +0 -0
- package/{src/lib/components → components}/editor/icons/quote.svg +0 -0
- package/{src/lib/components → components}/editor/icons/redo.svg +0 -0
- package/{src/lib/components → components}/editor/icons/right.svg +0 -0
- package/{src/lib/components → components}/editor/icons/rowabove.svg +0 -0
- package/{src/lib/components → components}/editor/icons/rowbelow.svg +0 -0
- package/{src/lib/components → components}/editor/icons/rule.svg +0 -0
- package/{src/lib/components → components}/editor/icons/sub.svg +0 -0
- package/{src/lib/components → components}/editor/icons/super.svg +0 -0
- package/{src/lib/components → components}/editor/icons/table.svg +0 -0
- package/{src/lib/components → components}/editor/icons/text.svg +0 -0
- package/{src/lib/components → components}/editor/icons/time.svg +0 -0
- package/{src/lib/components → components}/editor/icons/undo.svg +0 -0
- package/{src/lib/components → components}/editor/icons/unindent.svg +0 -0
- package/{src/lib/components → components}/editor/icons/unlink.svg +0 -0
- package/{src/lib/components → components}/page/Acknowledgements.svelte +10 -19
- package/components/page/Acknowledgements.svelte.d.ts +14 -0
- package/components/page/Authors.svelte +85 -0
- package/components/page/Authors.svelte.d.ts +21 -0
- package/components/page/BookLoader.svelte +59 -0
- package/components/page/BookLoader.svelte.d.ts +16 -0
- package/components/page/BulkReferenceEditor.svelte +63 -0
- package/components/page/BulkReferenceEditor.svelte.d.ts +14 -0
- package/components/page/Chapter.svelte +393 -0
- package/components/page/Chapter.svelte.d.ts +18 -0
- package/components/page/ChapterContext.d.ts +10 -0
- package/components/page/ChapterContext.js +1 -0
- package/{src/lib/components → components}/page/ChapterNumber.svelte +0 -0
- package/components/page/ChapterNumber.svelte.d.ts +27 -0
- package/{src/lib/components → components}/page/ChapterTitle.svelte +2 -4
- package/components/page/ChapterTitle.svelte.d.ts +18 -0
- package/components/page/Contexts.d.ts +47 -0
- package/components/page/Contexts.js +133 -0
- package/{src/lib/components → components}/page/DefinitionView.svelte +38 -53
- package/components/page/DefinitionView.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/Description.svelte +7 -15
- package/components/page/Description.svelte.d.ts +14 -0
- package/components/page/Edition.svelte +161 -0
- package/components/page/Edition.svelte.d.ts +20 -0
- package/components/page/EditionLoader.svelte +99 -0
- package/components/page/EditionLoader.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/Editions.svelte +18 -22
- package/components/page/Editions.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Glossary.svelte +28 -33
- package/components/page/Glossary.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Header.svelte +52 -59
- package/components/page/Header.svelte.d.ts +29 -0
- package/{src/lib/components → components}/page/Index.svelte +47 -50
- package/components/page/Index.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Instructions.svelte +1 -2
- package/components/page/Instructions.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/License.svelte +9 -17
- package/components/page/License.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Loading.svelte +0 -0
- package/components/page/Loading.svelte.d.ts +23 -0
- package/{src/lib/components → components}/page/Media.svelte +27 -44
- package/components/page/Media.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/MediaPreview.svelte +2 -3
- package/components/page/MediaPreview.svelte.d.ts +19 -0
- package/{src/lib/components → components}/page/Muted.svelte +0 -0
- package/components/page/Muted.svelte.d.ts +27 -0
- package/{src/lib/components → components}/page/Outline.svelte +110 -140
- package/components/page/Outline.svelte.d.ts +19 -0
- package/components/page/Page.svelte +84 -0
- package/components/page/Page.svelte.d.ts +19 -0
- package/{src/lib/components → components}/page/PageHeader.svelte +1 -2
- package/components/page/PageHeader.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/PageParagraph.svelte +0 -0
- package/components/page/PageParagraph.svelte.d.ts +27 -0
- package/components/page/PossibleChapter.svelte +14 -0
- package/components/page/PossibleChapter.svelte.d.ts +14 -0
- package/components/page/PossibleReference.svelte +11 -0
- package/components/page/PossibleReference.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/Print.svelte +3 -5
- package/components/page/Print.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Publish.svelte +52 -59
- package/components/page/Publish.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Reference.svelte +30 -39
- package/components/page/Reference.svelte.d.ts +17 -0
- package/{src/lib/components → components}/page/References.svelte +14 -18
- package/components/page/References.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Rows.svelte +0 -0
- package/components/page/Rows.svelte.d.ts +27 -0
- package/components/page/Search.svelte +133 -0
- package/components/page/Search.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/Status.svelte +3 -5
- package/components/page/Status.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/SubdomainEditor.svelte +13 -16
- package/components/page/SubdomainEditor.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/TableOfContents.svelte +68 -79
- package/components/page/TableOfContents.svelte.d.ts +14 -0
- package/components/page/TableOfContentsImage.svelte +18 -0
- package/components/page/TableOfContentsImage.svelte.d.ts +16 -0
- package/{src/lib/components → components}/page/TableOfContentsRow.svelte +24 -34
- package/components/page/TableOfContentsRow.svelte.d.ts +24 -0
- package/{src/lib/components → components}/page/ThemeEditor.svelte +33 -44
- package/components/page/ThemeEditor.svelte.d.ts +14 -0
- package/{src/lib/components → components}/page/ThemeEditorPreview.svelte +12 -21
- package/components/page/ThemeEditorPreview.svelte.d.ts +17 -0
- package/components/page/ThemeSetEditor.svelte +19 -0
- package/components/page/ThemeSetEditor.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/ThemeVariableEditor.svelte +14 -18
- package/components/page/ThemeVariableEditor.svelte.d.ts +18 -0
- package/{src/lib/components → components}/page/Title.svelte +0 -0
- package/components/page/Title.svelte.d.ts +27 -0
- package/{src/lib/components → components}/page/Unknown.svelte +8 -10
- package/components/page/Unknown.svelte.d.ts +16 -0
- package/components/page/margins.d.ts +2 -0
- package/{src/lib/components/page/margins.ts → components/page/margins.js} +46 -79
- package/index.d.ts +15 -0
- package/{src/lib/index.js → index.js} +0 -0
- package/models/CRUD.d.ts +27 -0
- package/models/CRUD.js +262 -0
- package/models/Firebase.d.ts +5 -0
- package/{src/lib/models/Firebase.ts → models/Firebase.js} +16 -26
- package/models/book/Book.d.ts +61 -0
- package/models/book/Book.js +135 -0
- package/models/book/BookMedia.d.ts +23 -0
- package/models/book/BookMedia.js +108 -0
- package/models/book/BookSaveStatus.d.ts +7 -0
- package/models/book/BookSaveStatus.js +8 -0
- package/models/book/Chapter.d.ts +81 -0
- package/models/book/Chapter.js +212 -0
- package/models/book/ChapterID.d.ts +10 -0
- package/{src/lib/models/book/ChapterID.ts → models/book/ChapterID.js} +0 -1
- package/models/book/Definition.d.ts +6 -0
- package/models/book/Definition.js +1 -0
- package/models/book/Edition.d.ts +139 -0
- package/models/book/Edition.js +620 -0
- package/models/book/Reference.d.ts +24 -0
- package/models/book/Reference.js +78 -0
- package/models/book/Schema.d.ts +174 -0
- package/{src/lib/models/book/Schema.ts → models/book/Schema.js} +0 -1
- package/models/book/Theme.d.ts +113 -0
- package/{src/lib/models/book/Theme.ts → models/book/Theme.js} +6 -110
- package/{src/lib/models/book/ThemeColors.ts → models/book/ThemeColors.d.ts} +0 -6
- package/models/book/ThemeColors.js +1 -0
- package/models/book/Words.d.ts +2 -0
- package/{src/lib/models/book/Words.ts → models/book/Words.js} +0 -1
- package/models/chapter/AtomNode.d.ts +18 -0
- package/{src/lib/models/chapter/AtomNode.ts → models/chapter/AtomNode.js} +10 -30
- package/models/chapter/BlockNode.d.ts +20 -0
- package/{src/lib/models/chapter/BlockNode.ts → models/chapter/BlockNode.js} +47 -80
- package/models/chapter/BlocksNode.d.ts +50 -0
- package/{src/lib/models/chapter/BlocksNode.ts → models/chapter/BlocksNode.js} +359 -571
- package/models/chapter/BlocksNode.test.d.ts +1 -0
- package/models/chapter/BlocksNode.test.js +568 -0
- package/{src/lib/models/chapter/Bookkeeping.ts → models/chapter/Bookkeeping.d.ts} +0 -0
- package/models/chapter/Bookkeeping.js +1 -0
- package/models/chapter/CalloutNode.d.ts +17 -0
- package/models/chapter/CalloutNode.js +58 -0
- package/models/chapter/Caret.d.ts +23 -0
- package/{src/lib/models/chapter/Caret.ts → models/chapter/Caret.js} +26 -50
- package/models/chapter/ChapterNode.d.ts +34 -0
- package/models/chapter/ChapterNode.js +117 -0
- package/models/chapter/CitationsNode.d.ts +16 -0
- package/{src/lib/models/chapter/CitationsNode.ts → models/chapter/CitationsNode.js} +10 -17
- package/models/chapter/CodeNode.d.ts +35 -0
- package/{src/lib/models/chapter/CodeNode.ts → models/chapter/CodeNode.js} +62 -125
- package/models/chapter/CommentNode.d.ts +18 -0
- package/models/chapter/CommentNode.js +48 -0
- package/models/chapter/DefinitionNode.d.ts +12 -0
- package/{src/lib/models/chapter/DefinitionNode.ts → models/chapter/DefinitionNode.js} +8 -14
- package/models/chapter/Edit.d.ts +7 -0
- package/models/chapter/Edit.js +1 -0
- package/models/chapter/EmbedNode.d.ts +45 -0
- package/models/chapter/EmbedNode.js +168 -0
- package/models/chapter/ErrorNode.d.ts +17 -0
- package/{src/lib/models/chapter/ErrorNode.ts → models/chapter/ErrorNode.js} +8 -15
- package/models/chapter/FootnoteNode.d.ts +18 -0
- package/models/chapter/FootnoteNode.js +47 -0
- package/models/chapter/FormatNode.d.ts +60 -0
- package/{src/lib/models/chapter/FormatNode.ts → models/chapter/FormatNode.js} +262 -443
- package/models/chapter/FormatNode.test.d.ts +1 -0
- package/models/chapter/FormatNode.test.js +96 -0
- package/models/chapter/InlineCodeNode.d.ts +12 -0
- package/{src/lib/models/chapter/InlineCodeNode.ts → models/chapter/InlineCodeNode.js} +9 -17
- package/models/chapter/LabelNode.d.ts +17 -0
- package/{src/lib/models/chapter/LabelNode.ts → models/chapter/LabelNode.js} +10 -26
- package/models/chapter/LinkNode.d.ts +12 -0
- package/{src/lib/models/chapter/LinkNode.ts → models/chapter/LinkNode.js} +7 -12
- package/models/chapter/ListNode.d.ts +51 -0
- package/{src/lib/models/chapter/ListNode.ts → models/chapter/ListNode.js} +200 -277
- package/models/chapter/ListNode.test.d.ts +1 -0
- package/{src/lib/models/chapter/ListNode.test.ts → models/chapter/ListNode.test.js} +20 -57
- package/models/chapter/MetadataNode.d.ts +17 -0
- package/models/chapter/MetadataNode.js +32 -0
- package/models/chapter/Node.d.ts +38 -0
- package/{src/lib/models/chapter/Node.ts → models/chapter/Node.js} +71 -155
- package/models/chapter/Node.test.d.ts +1 -0
- package/{src/lib/models → models}/chapter/Node.test.js +0 -0
- package/models/chapter/ParagraphNode.d.ts +33 -0
- package/{src/lib/models/chapter/ParagraphNode.ts → models/chapter/ParagraphNode.js} +58 -95
- package/models/chapter/ParagraphNode.test.d.ts +1 -0
- package/models/chapter/ParagraphNode.test.js +30 -0
- package/models/chapter/Parser.d.ts +75 -0
- package/{src/lib/models/chapter/Parser.ts → models/chapter/Parser.js} +184 -369
- package/models/chapter/Parser.test.d.ts +1 -0
- package/{src/lib/models/chapter/Parser.test.ts → models/chapter/Parser.test.js} +0 -7
- package/{src/lib/models/chapter/Position.ts → models/chapter/Position.d.ts} +0 -0
- package/models/chapter/Position.js +1 -0
- package/models/chapter/QuoteNode.d.ts +25 -0
- package/models/chapter/QuoteNode.js +99 -0
- package/{src/lib/models/chapter/RootNode.ts → models/chapter/RootNode.d.ts} +0 -2
- package/models/chapter/RootNode.js +1 -0
- package/models/chapter/RuleNode.d.ts +15 -0
- package/{src/lib/models/chapter/RuleNode.ts → models/chapter/RuleNode.js} +6 -9
- package/models/chapter/TableNode.d.ts +37 -0
- package/{src/lib/models/chapter/TableNode.ts → models/chapter/TableNode.js} +82 -141
- package/models/chapter/TableNode.test.d.ts +1 -0
- package/{src/lib/models/chapter/TableNode.test.ts → models/chapter/TableNode.test.js} +10 -27
- package/models/chapter/TextNode.d.ts +36 -0
- package/{src/lib/models/chapter/TextNode.ts → models/chapter/TextNode.js} +65 -117
- package/models/chapter/TextNode.test.d.ts +1 -0
- package/{src/lib/models/chapter/TextNode.test.ts → models/chapter/TextNode.test.js} +0 -2
- package/package.json +270 -53
- package/util/getSubdomain.d.ts +3 -0
- package/{src/lib/util/getSubdomain.ts → util/getSubdomain.js} +8 -14
- package/util/isMobile.d.ts +2 -0
- package/{src/lib/util/isMobile.ts → util/isMobile.js} +0 -1
- package/util/mineReference.d.ts +4 -0
- package/{src/lib/util/mineReference.ts → util/mineReference.js} +25 -45
- package/util/scrollToEyeLevel.d.ts +2 -0
- package/{src/lib/util/scrollToEyeLevel.ts → util/scrollToEyeLevel.js} +2 -4
- package/.env.example +0 -8
- package/.firebaserc +0 -8
- package/.prettierignore +0 -8
- package/.prettierrc.json +0 -5
- package/_update-notifier-last-checked +0 -0
- package/firebase.json +0 -46
- package/firestore.indexes.json +0 -4
- package/firestore.rules +0 -59
- package/functions/.eslintrc.js +0 -28
- package/functions/package-lock.json +0 -12595
- package/functions/package.json +0 -43
- package/functions/src/index.ts +0 -345
- package/functions/tsconfig.dev.json +0 -3
- package/functions/tsconfig.json +0 -15
- package/scripts/claims.cjs +0 -99
- package/src/app.d.ts +0 -9
- package/src/app.html +0 -24
- package/src/lib/components/Auth.svelte +0 -65
- package/src/lib/components/Link.svelte +0 -58
- package/src/lib/components/chapter/Block.svelte +0 -42
- package/src/lib/components/chapter/ErrorMessage.svelte +0 -12
- package/src/lib/components/chapter/Python.svelte +0 -144
- package/src/lib/components/chapter/Text.svelte +0 -109
- package/src/lib/components/editor/BookishEditor.svelte +0 -1101
- package/src/lib/components/editor/CalloutEditor.svelte +0 -14
- package/src/lib/components/editor/CaretContext.ts +0 -55
- package/src/lib/components/editor/CitationsEditor.svelte +0 -64
- package/src/lib/components/editor/ConfirmButton.svelte +0 -51
- package/src/lib/components/editor/DefinitionEditor.svelte +0 -44
- package/src/lib/components/editor/EmbedEditor.svelte +0 -152
- package/src/lib/components/editor/InlineCodeEditor.svelte +0 -16
- package/src/lib/components/editor/LinkEditor.svelte +0 -110
- package/src/lib/components/editor/PositionEditor.svelte +0 -21
- package/src/lib/components/editor/QuoteEditor.svelte +0 -14
- package/src/lib/components/editor/TableEditor.svelte +0 -14
- package/src/lib/components/editor/Toggle.svelte +0 -47
- package/src/lib/components/editor/Toolbar.svelte +0 -297
- package/src/lib/components/editor/URLEditor.svelte +0 -15
- package/src/lib/components/page/Authors.svelte +0 -92
- package/src/lib/components/page/BookLoader.svelte +0 -77
- package/src/lib/components/page/BulkReferenceEditor.svelte +0 -86
- package/src/lib/components/page/Chapter.svelte +0 -449
- package/src/lib/components/page/ChapterContext.ts +0 -13
- package/src/lib/components/page/Contexts.ts +0 -176
- package/src/lib/components/page/Edition.svelte +0 -189
- package/src/lib/components/page/EditionLoader.svelte +0 -123
- package/src/lib/components/page/Page.svelte +0 -94
- package/src/lib/components/page/PossibleChapter.svelte +0 -16
- package/src/lib/components/page/PossibleReference.svelte +0 -14
- package/src/lib/components/page/Search.svelte +0 -153
- package/src/lib/components/page/TableOfContentsImage.svelte +0 -22
- package/src/lib/components/page/ThemeSetEditor.svelte +0 -21
- package/src/lib/models/CRUD.ts +0 -469
- package/src/lib/models/book/Book.ts +0 -283
- package/src/lib/models/book/BookMedia.ts +0 -182
- package/src/lib/models/book/BookSaveStatus.ts +0 -8
- package/src/lib/models/book/Chapter.ts +0 -462
- package/src/lib/models/book/Definition.ts +0 -2
- package/src/lib/models/book/Edition.ts +0 -1216
- package/src/lib/models/book/Reference.ts +0 -171
- package/src/lib/models/chapter/BlocksNode.test.ts +0 -867
- package/src/lib/models/chapter/CalloutNode.ts +0 -79
- package/src/lib/models/chapter/ChapterNode.ts +0 -169
- package/src/lib/models/chapter/CommentNode.ts +0 -61
- package/src/lib/models/chapter/Edit.ts +0 -6
- package/src/lib/models/chapter/EmbedNode.ts +0 -257
- package/src/lib/models/chapter/FootnoteNode.ts +0 -59
- package/src/lib/models/chapter/FormatNode.test.ts +0 -137
- package/src/lib/models/chapter/MetadataNode.ts +0 -44
- package/src/lib/models/chapter/ParagraphNode.test.ts +0 -54
- package/src/lib/models/chapter/QuoteNode.ts +0 -135
- package/src/params/edition.ts +0 -3
- package/src/routes/+error.svelte +0 -12
- package/src/routes/+layout.svelte +0 -241
- package/src/routes/+page.svelte +0 -43
- package/src/routes/Footer.svelte +0 -0
- package/src/routes/Header.svelte +0 -112
- package/src/routes/[bookid]/+layout.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/+error.svelte +0 -14
- package/src/routes/[bookid]/[[editionid=edition]]/+layout.svelte +0 -7
- package/src/routes/[bookid]/[[editionid=edition]]/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/glossary/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/media/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/print/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/references/+page.svelte +0 -5
- package/src/routes/[bookid]/[[editionid=edition]]/search/+page.svelte +0 -5
- package/src/routes/[bookid]/editions/+page.svelte +0 -20
- package/src/routes/about/+page.svelte +0 -102
- package/src/routes/confirm/+page.svelte +0 -62
- package/src/routes/email/+page.svelte +0 -99
- package/src/routes/login/+page.svelte +0 -66
- package/src/routes/read/+page.svelte +0 -38
- package/src/routes/write/+error.svelte +0 -10
- package/src/routes/write/+layout.svelte +0 -11
- package/src/routes/write/+page.svelte +0 -114
- package/src/routes/write/[bookid]/+layout.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/+layout.svelte +0 -7
- package/src/routes/write/[bookid]/[[editionid=edition]]/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/glossary/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/media/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/print/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/references/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/search/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/theme/+page.svelte +0 -5
- package/src/routes/write/[bookid]/[[editionid=edition]]/unknown/+page.svelte +0 -5
- package/src/routes/write/[bookid]/editions/+page.svelte +0 -20
- package/src/vite-env.d.ts +0 -1
- package/static/icons/favicon.png +0 -0
- package/static/icons/icon.png +0 -0
- package/static/icons/ios-icon.png +0 -0
- package/storage.rules +0 -9
- package/svelte.config.js +0 -19
- package/tsconfig.json +0 -18
- package/tsconfig.node.json +0 -9
- package/vite.config.ts +0 -8
- package/vite.reader.config.ts +0 -32
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import BookMedia from './BookMedia';
|
|
2
|
+
export default class Book {
|
|
3
|
+
ref;
|
|
4
|
+
title;
|
|
5
|
+
authors;
|
|
6
|
+
description;
|
|
7
|
+
cover;
|
|
8
|
+
published;
|
|
9
|
+
editions;
|
|
10
|
+
domain;
|
|
11
|
+
uids;
|
|
12
|
+
media;
|
|
13
|
+
constructor(ref, title, authors, description, cover, editions, domain, uids) {
|
|
14
|
+
this.ref = ref;
|
|
15
|
+
this.title = title;
|
|
16
|
+
this.authors = authors;
|
|
17
|
+
this.description = description;
|
|
18
|
+
this.cover = cover;
|
|
19
|
+
// The published state is always true if some edition's published flag isn't null.
|
|
20
|
+
this.published = editions.some((edition) => edition.published !== null);
|
|
21
|
+
// We always keep editions in reversed edition number for easy reference.
|
|
22
|
+
this.editions = editions.sort((a, b) => a.number - b.number);
|
|
23
|
+
this.domain = domain;
|
|
24
|
+
this.uids = uids;
|
|
25
|
+
this.media = new BookMedia(this);
|
|
26
|
+
}
|
|
27
|
+
getMedia() {
|
|
28
|
+
return this.media;
|
|
29
|
+
}
|
|
30
|
+
static fromJSON(ref, book) {
|
|
31
|
+
return new Book(ref, book.title, book.authors, book.description, book.cover, book.editions, book.domain, book.uids);
|
|
32
|
+
}
|
|
33
|
+
toJSON() {
|
|
34
|
+
const json = {
|
|
35
|
+
title: this.title,
|
|
36
|
+
authors: this.authors,
|
|
37
|
+
description: this.description,
|
|
38
|
+
cover: this.cover,
|
|
39
|
+
published: this.published,
|
|
40
|
+
domain: this.domain,
|
|
41
|
+
editions: this.editions,
|
|
42
|
+
uids: this.uids,
|
|
43
|
+
readuids: Array.from(new Set(this.editions
|
|
44
|
+
.map((edition) => [
|
|
45
|
+
...edition.editionuids,
|
|
46
|
+
...edition.chapteruids,
|
|
47
|
+
])
|
|
48
|
+
.flat())),
|
|
49
|
+
};
|
|
50
|
+
return json;
|
|
51
|
+
}
|
|
52
|
+
getSubdomain() {
|
|
53
|
+
return this.domain;
|
|
54
|
+
}
|
|
55
|
+
withSubdomain(domain) {
|
|
56
|
+
return new Book(this.ref, this.title, this.authors, this.description, this.cover, this.editions, domain.length === 0 ? null : domain, this.uids);
|
|
57
|
+
}
|
|
58
|
+
getTitle() {
|
|
59
|
+
return this.title;
|
|
60
|
+
}
|
|
61
|
+
withTitle(title) {
|
|
62
|
+
return new Book(this.ref, title, this.authors, this.description, this.cover, this.editions, this.domain, this.uids);
|
|
63
|
+
}
|
|
64
|
+
getDescription() {
|
|
65
|
+
return this.description;
|
|
66
|
+
}
|
|
67
|
+
withDescription(description) {
|
|
68
|
+
return new Book(this.ref, this.title, this.authors, description, this.cover, this.editions, this.domain, this.uids);
|
|
69
|
+
}
|
|
70
|
+
getCover() {
|
|
71
|
+
return this.cover;
|
|
72
|
+
}
|
|
73
|
+
withCover(cover) {
|
|
74
|
+
return new Book(this.ref, this.title, this.authors, this.description, cover, this.editions, this.domain, this.uids);
|
|
75
|
+
}
|
|
76
|
+
getAuthors() {
|
|
77
|
+
return this.authors;
|
|
78
|
+
}
|
|
79
|
+
withAuthors(authors) {
|
|
80
|
+
return new Book(this.ref, this.title, authors, this.description, this.cover, this.editions, this.domain, this.uids);
|
|
81
|
+
}
|
|
82
|
+
getRef() {
|
|
83
|
+
return this.ref;
|
|
84
|
+
}
|
|
85
|
+
getRefID() {
|
|
86
|
+
return this.ref.id;
|
|
87
|
+
}
|
|
88
|
+
getEditionNumberID(number) {
|
|
89
|
+
// Get the ID corresponding to this number.
|
|
90
|
+
const edition = this.editions.find((ed) => ed.number === number);
|
|
91
|
+
return edition ? edition.ref.id : undefined;
|
|
92
|
+
}
|
|
93
|
+
getLatestPublishedEditionID() {
|
|
94
|
+
return this.editions.filter((ed) => ed.published !== null)[0]?.ref.id;
|
|
95
|
+
}
|
|
96
|
+
getLatestEditionID() {
|
|
97
|
+
return this.editions[0]?.ref.id;
|
|
98
|
+
}
|
|
99
|
+
getEditions() {
|
|
100
|
+
return this.editions.slice();
|
|
101
|
+
}
|
|
102
|
+
getPublishedEditionCount() {
|
|
103
|
+
return this.editions.filter((edition) => edition.published).length;
|
|
104
|
+
}
|
|
105
|
+
isEditor(uid) {
|
|
106
|
+
return this.uids.includes(uid);
|
|
107
|
+
}
|
|
108
|
+
withEditors(uids) {
|
|
109
|
+
return new Book(this.ref, this.title, this.authors, this.description, this.cover, this.editions, this.domain, uids);
|
|
110
|
+
}
|
|
111
|
+
withEditions(revisions) {
|
|
112
|
+
return new Book(this.ref, this.title, this.authors, this.description, this.cover, revisions, this.domain, this.uids);
|
|
113
|
+
}
|
|
114
|
+
withRevisedEdition(previous, revised) {
|
|
115
|
+
// Get the new info.
|
|
116
|
+
const info = revised.getInfo();
|
|
117
|
+
if (info === undefined)
|
|
118
|
+
return this;
|
|
119
|
+
// If no previous addition, just add it.
|
|
120
|
+
if (previous === undefined)
|
|
121
|
+
return this.withEditions([...this.editions, info]);
|
|
122
|
+
// Find the corresponding edition.
|
|
123
|
+
const index = this.editions.findIndex((edition) => edition.number === previous.number);
|
|
124
|
+
return index < 0
|
|
125
|
+
? this
|
|
126
|
+
: this.withEditions([
|
|
127
|
+
...this.editions.slice(0, index),
|
|
128
|
+
info,
|
|
129
|
+
...this.editions.slice(index + 1),
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
hasPublishedEdition() {
|
|
133
|
+
return this.editions.some((revision) => revision.published !== null);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StorageReference } from 'firebase/storage';
|
|
2
|
+
import type Book from './Book';
|
|
3
|
+
export type Image = {
|
|
4
|
+
url: string;
|
|
5
|
+
ref: StorageReference;
|
|
6
|
+
};
|
|
7
|
+
export default class BookMedia {
|
|
8
|
+
readonly book: Book;
|
|
9
|
+
_images: Image[] | undefined;
|
|
10
|
+
readonly observers: Set<(images: Image[]) => void>;
|
|
11
|
+
constructor(book: Book);
|
|
12
|
+
notify(observer: (images: Image[]) => void): void;
|
|
13
|
+
stopNotifying(observer: (images: Image[]) => void): void;
|
|
14
|
+
/** Get all non-thumbnail images. */
|
|
15
|
+
getImages(): Promise<Image[]>;
|
|
16
|
+
getImagePath(): string;
|
|
17
|
+
/** Get a listing of all of the images for the book. */
|
|
18
|
+
cacheImages(): Promise<Image[]>;
|
|
19
|
+
retrieveImages(): Promise<(Image | undefined)[]>;
|
|
20
|
+
getThumbnailURL(url: string, thumbnailRef: StorageReference, error: (message: string) => void, finished: (url: string, thumbnailURL: string) => void, attempt?: number): void;
|
|
21
|
+
upload(file: File, progressHandler: (progress: number) => void, errorHandler: (message: string) => void, finishedHandler: (url: string, thumbnailURL: string) => void): void;
|
|
22
|
+
remove(image: Image): Promise<Image[] | undefined>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { deleteObject, getDownloadURL, listAll, ref, uploadBytes, } from 'firebase/storage';
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import { storage } from '../Firebase';
|
|
4
|
+
export default class BookMedia {
|
|
5
|
+
book;
|
|
6
|
+
_images;
|
|
7
|
+
// A list of functions to call when the book media changes.
|
|
8
|
+
observers = new Set();
|
|
9
|
+
constructor(book) {
|
|
10
|
+
this.book = book;
|
|
11
|
+
}
|
|
12
|
+
notify(observer) {
|
|
13
|
+
this.observers.add(observer);
|
|
14
|
+
// Notify it right away!
|
|
15
|
+
this.getImages().then((images) => observer(images));
|
|
16
|
+
}
|
|
17
|
+
stopNotifying(observer) {
|
|
18
|
+
this.observers.delete(observer);
|
|
19
|
+
}
|
|
20
|
+
/** Get all non-thumbnail images. */
|
|
21
|
+
async getImages() {
|
|
22
|
+
return this._images === undefined ? this.cacheImages() : this._images;
|
|
23
|
+
}
|
|
24
|
+
getImagePath() {
|
|
25
|
+
return `images/${this.book.getRefID()}/`;
|
|
26
|
+
}
|
|
27
|
+
/** Get a listing of all of the images for the book. */
|
|
28
|
+
async cacheImages() {
|
|
29
|
+
if (storage === undefined)
|
|
30
|
+
return [];
|
|
31
|
+
// Find all the prefixes and items.
|
|
32
|
+
this._images = (await this.retrieveImages()).filter((image) => image !== undefined);
|
|
33
|
+
// Notify observers
|
|
34
|
+
for (const observer of this.observers)
|
|
35
|
+
observer(this._images.slice());
|
|
36
|
+
return this._images;
|
|
37
|
+
}
|
|
38
|
+
async retrieveImages() {
|
|
39
|
+
if (storage === undefined)
|
|
40
|
+
return [];
|
|
41
|
+
// Create a reference under which you want to list
|
|
42
|
+
const listRef = ref(storage, this.getImagePath());
|
|
43
|
+
// Find all the prefixes and items.
|
|
44
|
+
return listAll(listRef).then((res) => Promise.all(res.items.map((itemRef) => getDownloadURL(itemRef).then((url) => {
|
|
45
|
+
const image = {
|
|
46
|
+
url: url,
|
|
47
|
+
description: '',
|
|
48
|
+
ref: itemRef,
|
|
49
|
+
};
|
|
50
|
+
if (this._images !== undefined) {
|
|
51
|
+
this._images.push(image);
|
|
52
|
+
}
|
|
53
|
+
return image;
|
|
54
|
+
}))));
|
|
55
|
+
}
|
|
56
|
+
getThumbnailURL(url, thumbnailRef, error, finished, attempt = 0) {
|
|
57
|
+
getDownloadURL(thumbnailRef)
|
|
58
|
+
.then((thumbnail) => finished(url, thumbnail))
|
|
59
|
+
// Try again in a bit.
|
|
60
|
+
.catch(() => attempt > 25
|
|
61
|
+
? error("Couldn't get the image URL. Connection issues?")
|
|
62
|
+
: setTimeout(() => this.getThumbnailURL(url, thumbnailRef, error, finished, attempt + 1), 250));
|
|
63
|
+
}
|
|
64
|
+
upload(file, progressHandler, errorHandler, finishedHandler) {
|
|
65
|
+
progressHandler;
|
|
66
|
+
if (storage === undefined)
|
|
67
|
+
return;
|
|
68
|
+
// The canonical path format for Bookish images in the store is image/{bookid}/{imageid}
|
|
69
|
+
// where {bookid} is the Firestore ID of the book being edited and {imageid} is just a random id.
|
|
70
|
+
const imageName = `image-${uuidv4()}`;
|
|
71
|
+
const imageRef = ref(storage, `${this.getImagePath()}/${imageName}`);
|
|
72
|
+
const thumbnailRef = ref(storage, `${this.getImagePath()}/thumbnails/${imageName}`);
|
|
73
|
+
uploadBytes(imageRef, file)
|
|
74
|
+
.then((snapshot) => {
|
|
75
|
+
getDownloadURL(snapshot.ref)
|
|
76
|
+
.then((url) => {
|
|
77
|
+
// Give some time for the cloud function to create a thumbnail, then try to get it's URL.
|
|
78
|
+
setTimeout(() => this.getThumbnailURL(url, thumbnailRef, errorHandler, finishedHandler), 250);
|
|
79
|
+
})
|
|
80
|
+
.catch(() => errorHandler('Unable to get image URL.'));
|
|
81
|
+
})
|
|
82
|
+
.then(() => this.cacheImages());
|
|
83
|
+
// This seems to be broken in Firebase right now. Switched above to a no-feedback approach.
|
|
84
|
+
// const uploadTask = uploadBytesResumable(imageRef, file);
|
|
85
|
+
// uploadTask.on("state_changed",
|
|
86
|
+
// // During upload, notify of progress by sending an integer percent complete.
|
|
87
|
+
// (snapshot) => progressHandler(Math.round((snapshot.bytesTransferred / snapshot.totalBytes) * 100)),
|
|
88
|
+
// // If there's an error, map it to a message.
|
|
89
|
+
// // https://firebase.google.com/docs/storage/web/handle-errors
|
|
90
|
+
// (error) => {
|
|
91
|
+
// console.error(error);
|
|
92
|
+
// errorHandler(
|
|
93
|
+
// error.code === "storage/unauthorized" ? "Wrong permissions to upload" :
|
|
94
|
+
// error.code === "storage/canceled" ? "Upload canceled" :
|
|
95
|
+
// error.code === "storage/quota-exceeded" ? "Storage limit reached" :
|
|
96
|
+
// error.code === "storage/unauthenticated" ? "Log in again to upload" :
|
|
97
|
+
// "Unknown upload error"
|
|
98
|
+
// )
|
|
99
|
+
// },
|
|
100
|
+
}
|
|
101
|
+
async remove(image) {
|
|
102
|
+
if (storage === undefined)
|
|
103
|
+
return;
|
|
104
|
+
const imageRef = ref(storage, image.ref.fullPath);
|
|
105
|
+
await deleteObject(imageRef);
|
|
106
|
+
return await this.cacheImages();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var BookSaveStatus;
|
|
2
|
+
(function (BookSaveStatus) {
|
|
3
|
+
BookSaveStatus[BookSaveStatus["Changed"] = 0] = "Changed";
|
|
4
|
+
BookSaveStatus[BookSaveStatus["Saving"] = 1] = "Saving";
|
|
5
|
+
BookSaveStatus[BookSaveStatus["Saved"] = 2] = "Saved";
|
|
6
|
+
BookSaveStatus[BookSaveStatus["Error"] = 3] = "Error";
|
|
7
|
+
})(BookSaveStatus || (BookSaveStatus = {}));
|
|
8
|
+
export default BookSaveStatus;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type ChapterNode from '../chapter/ChapterNode';
|
|
2
|
+
import type Edition from './Edition';
|
|
3
|
+
import type { DocumentReference } from 'firebase/firestore';
|
|
4
|
+
export type ChapterSpecification = {
|
|
5
|
+
ref?: DocumentReference;
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
authors: string[];
|
|
9
|
+
image: string | null;
|
|
10
|
+
numbered: boolean;
|
|
11
|
+
forthcoming: boolean;
|
|
12
|
+
section?: string;
|
|
13
|
+
text?: string;
|
|
14
|
+
uids: string[];
|
|
15
|
+
};
|
|
16
|
+
export type ChapterContent = {
|
|
17
|
+
text: string;
|
|
18
|
+
};
|
|
19
|
+
export type Match = {
|
|
20
|
+
left: string;
|
|
21
|
+
match: string;
|
|
22
|
+
right: string;
|
|
23
|
+
};
|
|
24
|
+
export default class Chapter {
|
|
25
|
+
readonly ref: DocumentReference | undefined;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly title: string;
|
|
28
|
+
readonly authors: string[];
|
|
29
|
+
readonly image: string | null;
|
|
30
|
+
readonly numbered: boolean;
|
|
31
|
+
readonly forthcoming: boolean;
|
|
32
|
+
readonly section: string | undefined;
|
|
33
|
+
readonly text: string;
|
|
34
|
+
readonly uids: string[];
|
|
35
|
+
_ast: ChapterNode | undefined;
|
|
36
|
+
_index: Record<string, Array<Match>> | undefined;
|
|
37
|
+
_wordCount: number | undefined;
|
|
38
|
+
edits: {
|
|
39
|
+
resolve: Function;
|
|
40
|
+
reject: Function;
|
|
41
|
+
}[];
|
|
42
|
+
lastEdit: number;
|
|
43
|
+
listeners: Set<(text: string) => void>;
|
|
44
|
+
constructor(ref: DocumentReference | undefined, id: string, title: string, authors: string[], image: string | null, numbered: boolean, forthcoming: boolean, section: string | undefined, text: string, uids: string[]);
|
|
45
|
+
/**
|
|
46
|
+
* Convert a chapter spec and it's text into a chapter object.
|
|
47
|
+
* The spec may contain the text itself, but it may not, so we require it to be
|
|
48
|
+
* repeated here to guarantee its provided.
|
|
49
|
+
*/
|
|
50
|
+
static fromJSON(spec: ChapterSpecification, text: string): Chapter;
|
|
51
|
+
toJSON(): ChapterSpecification;
|
|
52
|
+
getRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
|
|
53
|
+
withEditors(uids: string[]): Chapter;
|
|
54
|
+
withRef(ref: DocumentReference): Chapter;
|
|
55
|
+
withoutRef(): Chapter;
|
|
56
|
+
getID(): string;
|
|
57
|
+
withChapterID(id: string): Chapter;
|
|
58
|
+
getSection(): string | undefined;
|
|
59
|
+
withSection(section: string): Chapter;
|
|
60
|
+
isForthcoming(): boolean;
|
|
61
|
+
asForthcoming(forthcoming: boolean): Chapter;
|
|
62
|
+
isNumbered(): boolean;
|
|
63
|
+
asNumbered(numbered: boolean): Chapter;
|
|
64
|
+
isEditor(uid: string): boolean;
|
|
65
|
+
getText(): string;
|
|
66
|
+
withText(text: string): Chapter;
|
|
67
|
+
withAST(ast: ChapterNode): Chapter;
|
|
68
|
+
getAuthors(): string[];
|
|
69
|
+
withAuthor(name: string): Chapter;
|
|
70
|
+
withRenamedAuthor(index: number, name: string): Chapter;
|
|
71
|
+
withoutAuthor(index: number): Chapter;
|
|
72
|
+
getTitle(): string;
|
|
73
|
+
withTitle(title: string): Chapter;
|
|
74
|
+
getImage(): string | null;
|
|
75
|
+
withImage(image: string | null): Chapter;
|
|
76
|
+
getAST(edition: Edition): ChapterNode;
|
|
77
|
+
getWordCount(edition: Edition): number;
|
|
78
|
+
getReadingTime(edition: Edition): number | undefined;
|
|
79
|
+
getIndex(edition: Edition): Record<string, Match[]>;
|
|
80
|
+
toString(): string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import Parser from '../chapter/Parser';
|
|
2
|
+
import CommonWords from './Words';
|
|
3
|
+
export default class Chapter {
|
|
4
|
+
// Inputs
|
|
5
|
+
ref;
|
|
6
|
+
id;
|
|
7
|
+
title;
|
|
8
|
+
authors;
|
|
9
|
+
image;
|
|
10
|
+
numbered;
|
|
11
|
+
forthcoming;
|
|
12
|
+
section;
|
|
13
|
+
text;
|
|
14
|
+
uids;
|
|
15
|
+
// Derived values
|
|
16
|
+
_ast = undefined;
|
|
17
|
+
_index = undefined;
|
|
18
|
+
_wordCount = undefined;
|
|
19
|
+
// A list of requested edits, stored as promises, resolved
|
|
20
|
+
// when the book is ready to save.
|
|
21
|
+
edits = [];
|
|
22
|
+
lastEdit = 0;
|
|
23
|
+
// A set of listeners that are notified when the chapter text changes.
|
|
24
|
+
listeners = new Set();
|
|
25
|
+
constructor(ref, id, title, authors, image, numbered, forthcoming, section, text, uids) {
|
|
26
|
+
this.ref = ref;
|
|
27
|
+
this.id = id;
|
|
28
|
+
this.title = title;
|
|
29
|
+
this.authors = authors.slice();
|
|
30
|
+
this.image = image;
|
|
31
|
+
this.numbered = numbered;
|
|
32
|
+
this.forthcoming = forthcoming;
|
|
33
|
+
this.section = section;
|
|
34
|
+
this.text = text;
|
|
35
|
+
this.uids = uids;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert a chapter spec and it's text into a chapter object.
|
|
39
|
+
* The spec may contain the text itself, but it may not, so we require it to be
|
|
40
|
+
* repeated here to guarantee its provided.
|
|
41
|
+
*/
|
|
42
|
+
static fromJSON(spec, text) {
|
|
43
|
+
// Copy the spec, filling in defaults as necessary.
|
|
44
|
+
return new Chapter(spec.ref, spec.id, spec.title, spec.authors ?? [], spec.image ?? null, spec.numbered === true || spec.numbered === undefined, spec.forthcoming === true, spec.section, spec.text ?? text, spec.uids);
|
|
45
|
+
}
|
|
46
|
+
toJSON() {
|
|
47
|
+
// Note that we don't include the chapter text in the payload; that's stored in the chapters subcollection.
|
|
48
|
+
// We just return the chapter metadata here, which is stored in the book collection.
|
|
49
|
+
const json = {
|
|
50
|
+
id: this.id,
|
|
51
|
+
title: this.title,
|
|
52
|
+
authors: this.authors.slice(),
|
|
53
|
+
image: this.image,
|
|
54
|
+
numbered: this.numbered,
|
|
55
|
+
forthcoming: this.forthcoming,
|
|
56
|
+
uids: this.uids,
|
|
57
|
+
};
|
|
58
|
+
if (this.ref)
|
|
59
|
+
json.ref = this.ref;
|
|
60
|
+
if (this.section)
|
|
61
|
+
json.section = this.section;
|
|
62
|
+
return json;
|
|
63
|
+
}
|
|
64
|
+
getRef() {
|
|
65
|
+
return this.ref;
|
|
66
|
+
}
|
|
67
|
+
withEditors(uids) {
|
|
68
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, uids);
|
|
69
|
+
}
|
|
70
|
+
withRef(ref) {
|
|
71
|
+
return new Chapter(ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
72
|
+
}
|
|
73
|
+
withoutRef() {
|
|
74
|
+
return new Chapter(undefined, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
75
|
+
}
|
|
76
|
+
getID() {
|
|
77
|
+
return this.id;
|
|
78
|
+
}
|
|
79
|
+
withChapterID(id) {
|
|
80
|
+
return new Chapter(this.ref, id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
81
|
+
}
|
|
82
|
+
getSection() {
|
|
83
|
+
return this.section;
|
|
84
|
+
}
|
|
85
|
+
withSection(section) {
|
|
86
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, section, this.text, this.uids);
|
|
87
|
+
}
|
|
88
|
+
isForthcoming() {
|
|
89
|
+
return this.forthcoming;
|
|
90
|
+
}
|
|
91
|
+
asForthcoming(forthcoming) {
|
|
92
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, forthcoming, this.section, this.text, this.uids);
|
|
93
|
+
}
|
|
94
|
+
isNumbered() {
|
|
95
|
+
return this.numbered;
|
|
96
|
+
}
|
|
97
|
+
asNumbered(numbered) {
|
|
98
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
99
|
+
}
|
|
100
|
+
isEditor(uid) {
|
|
101
|
+
return this.uids.includes(uid);
|
|
102
|
+
}
|
|
103
|
+
getText() {
|
|
104
|
+
return this.text;
|
|
105
|
+
}
|
|
106
|
+
withText(text) {
|
|
107
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, text, this.uids);
|
|
108
|
+
}
|
|
109
|
+
withAST(ast) {
|
|
110
|
+
const newChapter = new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, ast.toBookdown(), this.uids);
|
|
111
|
+
newChapter._ast = ast;
|
|
112
|
+
return newChapter;
|
|
113
|
+
}
|
|
114
|
+
getAuthors() {
|
|
115
|
+
return this.authors;
|
|
116
|
+
}
|
|
117
|
+
withAuthor(name) {
|
|
118
|
+
return new Chapter(this.ref, this.id, this.title, [...this.authors, name], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
119
|
+
}
|
|
120
|
+
withRenamedAuthor(index, name) {
|
|
121
|
+
if (index < 0 || index >= this.authors.length)
|
|
122
|
+
return this;
|
|
123
|
+
return new Chapter(this.ref, this.id, this.title, [
|
|
124
|
+
...this.authors.slice(0, index),
|
|
125
|
+
name,
|
|
126
|
+
...this.authors.slice(index + 1),
|
|
127
|
+
], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
128
|
+
}
|
|
129
|
+
withoutAuthor(index) {
|
|
130
|
+
if (index < 0 || index >= this.authors.length)
|
|
131
|
+
return this;
|
|
132
|
+
return new Chapter(this.ref, this.id, this.title, [...this.authors.slice(0, index), ...this.authors.slice(index + 1)], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
133
|
+
}
|
|
134
|
+
getTitle() {
|
|
135
|
+
return this.title;
|
|
136
|
+
}
|
|
137
|
+
withTitle(title) {
|
|
138
|
+
return new Chapter(this.ref, this.id, title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
139
|
+
}
|
|
140
|
+
getImage() {
|
|
141
|
+
return this.image;
|
|
142
|
+
}
|
|
143
|
+
withImage(image) {
|
|
144
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
145
|
+
}
|
|
146
|
+
getAST(edition) {
|
|
147
|
+
// Compute the cache if necessary
|
|
148
|
+
if (this._ast === undefined)
|
|
149
|
+
this._ast = Parser.parseChapter(edition, this.text);
|
|
150
|
+
return this._ast;
|
|
151
|
+
}
|
|
152
|
+
getWordCount(edition) {
|
|
153
|
+
if (this._wordCount === undefined)
|
|
154
|
+
this._wordCount = this.getAST(edition).toText().split(/\s+/).length;
|
|
155
|
+
return this._wordCount;
|
|
156
|
+
}
|
|
157
|
+
// Utility function
|
|
158
|
+
getReadingTime(edition) {
|
|
159
|
+
return this.isForthcoming()
|
|
160
|
+
? undefined
|
|
161
|
+
: Math.max(1, Math.round(this.getWordCount(edition) / 150));
|
|
162
|
+
}
|
|
163
|
+
getIndex(edition) {
|
|
164
|
+
if (this._index === undefined) {
|
|
165
|
+
const ast = this.getAST(edition);
|
|
166
|
+
// Build a list of common words
|
|
167
|
+
let commonWords = new Set();
|
|
168
|
+
CommonWords.forEach((word) => commonWords.add(word));
|
|
169
|
+
// Get all the text in the chapter.
|
|
170
|
+
let text = ast.toText();
|
|
171
|
+
// Split by word boundaries.
|
|
172
|
+
const words = text.split(/\b/);
|
|
173
|
+
// Index the words
|
|
174
|
+
const index = {};
|
|
175
|
+
words.forEach((word, wordNumber) => {
|
|
176
|
+
// Skip non words. We keep them for search results.
|
|
177
|
+
if (!/[a-zA-Z\u2019]+/.test(word))
|
|
178
|
+
return;
|
|
179
|
+
word = word.toLowerCase();
|
|
180
|
+
// Should we include?
|
|
181
|
+
// • It shouldn't be a common word
|
|
182
|
+
// • It shouldn't have an apostrophe
|
|
183
|
+
// • It should be longer than two letters
|
|
184
|
+
// • It shouldn't end in 'ly'
|
|
185
|
+
if (!commonWords.has(word) &&
|
|
186
|
+
word.indexOf('\u2019') < 0 &&
|
|
187
|
+
word.length > 2 &&
|
|
188
|
+
word.substring(word.length - 2, word.length) !== 'ly') {
|
|
189
|
+
// If we haven't started a list of occurrences, start one.
|
|
190
|
+
if (!(word in index))
|
|
191
|
+
index[word] = [];
|
|
192
|
+
let match = {
|
|
193
|
+
left: words
|
|
194
|
+
.slice(Math.max(0, wordNumber - 10), Math.max(0, wordNumber - 1) + 1)
|
|
195
|
+
.join(''),
|
|
196
|
+
match: words[wordNumber],
|
|
197
|
+
right: words
|
|
198
|
+
.slice(Math.min(words.length - 1, wordNumber + 1), Math.min(words.length - 1, wordNumber + 10) + 1)
|
|
199
|
+
.join(''),
|
|
200
|
+
};
|
|
201
|
+
// Add the occurrence, but a lower case canonical version.
|
|
202
|
+
index[word.toLowerCase()].push(match);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
this._index = index;
|
|
206
|
+
}
|
|
207
|
+
return this._index;
|
|
208
|
+
}
|
|
209
|
+
toString() {
|
|
210
|
+
return `${this.title} by ${this.authors.join(', ')}: ${this.text.substring(0, 32)}}`;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|