bookish-press 0.4.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/components/Auth.svelte +27 -24
- package/components/Auth.svelte.d.ts +4 -4
- package/components/Authentication.d.ts +2 -2
- package/components/BookPreview.svelte +75 -59
- package/components/BookPreview.svelte.d.ts +5 -5
- package/components/External.svelte +1 -1
- package/components/External.svelte.d.ts +3 -3
- package/components/Link.svelte +49 -3
- package/components/Link.svelte.d.ts +3 -4
- package/components/app/BookList.svelte +19 -0
- package/components/app/BookList.svelte.d.ts +18 -0
- package/components/app/Button.svelte +49 -0
- package/components/app/Button.svelte.d.ts +22 -0
- package/components/app/Feedback.svelte +47 -0
- package/components/app/Feedback.svelte.d.ts +18 -0
- package/components/app/Head.svelte +15 -0
- package/components/app/Head.svelte.d.ts +18 -0
- package/components/app/Large.svelte +8 -0
- package/components/app/Large.svelte.d.ts +27 -0
- package/components/app/Lead.svelte +12 -0
- package/components/app/Lead.svelte.d.ts +27 -0
- package/components/app/Link.svelte +24 -0
- package/components/app/Link.svelte.d.ts +20 -0
- package/components/app/Options.svelte +24 -0
- package/components/app/Options.svelte.d.ts +19 -0
- package/components/app/Paragraph.svelte +20 -0
- package/components/app/Paragraph.svelte.d.ts +18 -0
- package/components/app/Section.svelte +12 -0
- package/components/app/Section.svelte.d.ts +27 -0
- package/components/app/Table.svelte +32 -0
- package/components/app/Table.svelte.d.ts +27 -0
- package/components/app/TextInput.svelte +38 -0
- package/components/app/TextInput.svelte.d.ts +22 -0
- package/components/chapter/Atom.svelte +20 -6
- package/components/chapter/Atom.svelte.d.ts +3 -3
- package/components/chapter/Block.svelte +26 -21
- package/components/chapter/Block.svelte.d.ts +4 -4
- package/components/chapter/Callout.svelte +38 -7
- package/components/chapter/Callout.svelte.d.ts +4 -4
- package/components/chapter/CaptionedCode.svelte +67 -24
- package/components/chapter/CaptionedCode.svelte.d.ts +4 -4
- package/components/chapter/ChapterBody.svelte +62 -9
- package/components/chapter/ChapterBody.svelte.d.ts +5 -4
- package/components/chapter/Citations.svelte +86 -20
- package/components/chapter/Citations.svelte.d.ts +4 -4
- package/components/chapter/Code.svelte +152 -21
- package/components/chapter/Code.svelte.d.ts +3 -3
- package/components/chapter/Comment.svelte +39 -17
- package/components/chapter/Comment.svelte.d.ts +3 -3
- package/components/chapter/Definition.svelte +52 -18
- package/components/chapter/Definition.svelte.d.ts +5 -8
- package/components/chapter/Embed.svelte +155 -67
- package/components/chapter/Embed.svelte.d.ts +6 -4
- package/components/chapter/ErrorMessage.svelte +7 -2
- package/components/chapter/ErrorMessage.svelte.d.ts +4 -4
- package/components/chapter/ExtendedPrism.d.ts +2 -0
- package/components/chapter/ExtendedPrism.js +69 -0
- package/components/chapter/Figure.svelte +90 -0
- package/components/chapter/Figure.svelte.d.ts +24 -0
- package/components/chapter/Footnote.svelte +75 -12
- package/components/chapter/Footnote.svelte.d.ts +4 -4
- package/components/chapter/Format.svelte +63 -38
- package/components/chapter/Format.svelte.d.ts +5 -4
- package/components/chapter/InlineCode.svelte +16 -6
- package/components/chapter/InlineCode.svelte.d.ts +4 -4
- package/components/chapter/Label.svelte +38 -9
- package/components/chapter/Label.svelte.d.ts +4 -4
- package/components/chapter/Link.svelte +24 -19
- package/components/chapter/Link.svelte.d.ts +4 -4
- package/components/chapter/List.svelte +75 -8
- package/components/chapter/List.svelte.d.ts +4 -4
- package/components/chapter/Marginal.svelte +169 -27
- package/components/chapter/Marginal.svelte.d.ts +6 -3
- package/components/chapter/Paragraph.svelte +79 -6
- package/components/chapter/Paragraph.svelte.d.ts +4 -4
- package/components/chapter/Positioned.svelte +33 -0
- package/components/chapter/Positioned.svelte.d.ts +19 -0
- package/components/chapter/Problem.svelte +15 -0
- package/components/chapter/Problem.svelte.d.ts +27 -0
- package/components/chapter/Python.svelte +68 -21
- package/components/chapter/Python.svelte.d.ts +4 -4
- package/components/chapter/Quote.svelte +64 -11
- package/components/chapter/Quote.svelte.d.ts +4 -4
- package/components/chapter/Rule.svelte +12 -1
- package/components/chapter/Rule.svelte.d.ts +4 -4
- package/components/chapter/Table.svelte +36 -25
- package/components/chapter/Table.svelte.d.ts +4 -4
- package/components/chapter/Text.svelte +61 -36
- package/components/chapter/Text.svelte.d.ts +5 -4
- package/components/editor/BookishEditor.svelte +373 -244
- package/components/editor/BookishEditor.svelte.d.ts +9 -6
- package/components/editor/CalloutEditor.svelte +5 -5
- package/components/editor/CalloutEditor.svelte.d.ts +4 -4
- package/components/editor/CaptionedCodeEditor.svelte +16 -12
- package/components/editor/CaptionedCodeEditor.svelte.d.ts +4 -4
- package/components/editor/CaretContext.d.ts +48 -16
- package/components/editor/CaretState.d.ts +16 -44
- package/components/editor/CaretUtilities.d.ts +2 -2
- package/components/editor/CaretView.svelte +82 -0
- package/components/editor/CaretView.svelte.d.ts +25 -0
- package/components/editor/CitationsEditor.svelte +36 -25
- package/components/editor/CitationsEditor.svelte.d.ts +4 -4
- package/components/editor/Clipboard.d.ts +2 -2
- package/components/editor/Command.d.ts +13 -12
- package/components/editor/Commands.d.ts +1 -1
- package/components/editor/Commands.js +1114 -571
- package/components/editor/ConfirmButton.svelte +18 -12
- package/components/editor/ConfirmButton.svelte.d.ts +5 -4
- package/components/editor/DefinitionEditor.svelte +29 -21
- package/components/editor/DefinitionEditor.svelte.d.ts +4 -4
- package/components/editor/EmbedEditor.svelte +93 -43
- package/components/editor/EmbedEditor.svelte.d.ts +3 -3
- package/components/editor/Icon.svelte +17 -0
- package/components/editor/Icon.svelte.d.ts +16 -0
- package/components/editor/ImageChooser.svelte +53 -34
- package/components/editor/ImageChooser.svelte.d.ts +3 -3
- package/components/editor/InlineCodeEditor.svelte +7 -4
- package/components/editor/InlineCodeEditor.svelte.d.ts +4 -4
- package/components/editor/LabelEditor.svelte +20 -11
- package/components/editor/LabelEditor.svelte.d.ts +4 -4
- package/components/editor/LanguageEditor.svelte +10 -7
- package/components/editor/LanguageEditor.svelte.d.ts +3 -3
- package/components/editor/LinkEditor.svelte +64 -39
- package/components/editor/LinkEditor.svelte.d.ts +4 -4
- package/components/editor/Note.svelte +4 -3
- package/components/editor/Note.svelte.d.ts +6 -2
- package/components/editor/Permissions.svelte +95 -0
- package/components/editor/Permissions.svelte.d.ts +20 -0
- package/components/editor/PositionEditor.svelte +9 -6
- package/components/editor/PositionEditor.svelte.d.ts +4 -4
- package/components/editor/QuoteEditor.svelte +7 -2
- package/components/editor/QuoteEditor.svelte.d.ts +4 -4
- package/components/editor/Switch.svelte +55 -28
- package/components/editor/Switch.svelte.d.ts +4 -4
- package/components/editor/TableEditor.svelte +10 -0
- package/components/editor/TableEditor.svelte.d.ts +17 -0
- package/components/editor/TextEditor.svelte +83 -45
- package/components/editor/TextEditor.svelte.d.ts +5 -4
- package/components/editor/Toggle.svelte +11 -8
- package/components/editor/Toggle.svelte.d.ts +4 -4
- package/components/editor/Toolbar.svelte +191 -144
- package/components/editor/Toolbar.svelte.d.ts +5 -8
- package/components/editor/ToolbarGroup.svelte +17 -23
- package/components/editor/ToolbarGroup.svelte.d.ts +3 -4
- package/components/editor/ToolbarSpacer.svelte +8 -1
- package/components/editor/ToolbarSpacer.svelte.d.ts +6 -2
- package/components/editor/URLEditor.svelte +6 -8
- package/components/editor/URLEditor.svelte.d.ts +3 -3
- package/components/editor/UndoState.d.ts +3 -3
- package/components/editor/icons/annotate.svg +1 -0
- package/components/editor/icons/block.svg +1 -0
- package/components/editor/icons/bold.svg +1 -0
- package/components/editor/icons/bullets.svg +1 -0
- package/components/editor/icons/callout.svg +1 -0
- package/components/editor/icons/citation.svg +8 -0
- package/components/editor/icons/clear.svg +1 -0
- package/components/editor/icons/clipboard.svg +1 -0
- package/components/editor/icons/code.svg +1 -0
- package/components/editor/icons/columnafter.svg +1 -0
- package/components/editor/icons/columnbefore.svg +1 -0
- package/components/editor/icons/comment.svg +1 -0
- package/components/editor/icons/copy.svg +1 -0
- package/components/editor/icons/cut.svg +1 -0
- package/components/editor/icons/define.svg +7 -0
- package/components/editor/icons/deletecolumn.svg +1 -0
- package/components/editor/icons/deleterow.svg +1 -0
- package/components/editor/icons/footnote.svg +8 -0
- package/components/editor/icons/header1.svg +7 -0
- package/components/editor/icons/header2.svg +7 -0
- package/components/editor/icons/header3.svg +7 -0
- package/components/editor/icons/home.svg +1 -0
- package/components/editor/icons/indent.svg +1 -0
- package/components/editor/icons/italic.svg +1 -0
- package/components/editor/icons/label.svg +1 -0
- package/components/editor/icons/left.svg +1 -0
- package/components/editor/icons/level.svg +1 -0
- package/components/editor/icons/link.svg +1 -0
- package/components/editor/icons/list.svg +1 -0
- package/components/editor/icons/media.svg +1 -0
- package/components/editor/icons/middle.svg +1 -0
- package/components/editor/icons/numbers.svg +10 -0
- package/components/editor/icons/paragraph.svg +1 -0
- package/components/editor/icons/paste.svg +10 -0
- package/components/editor/icons/quote.svg +1 -0
- package/components/editor/icons/redo.svg +1 -0
- package/components/editor/icons/right.svg +1 -0
- package/components/editor/icons/rowabove.svg +1 -0
- package/components/editor/icons/rowbelow.svg +1 -0
- package/components/editor/icons/rule.svg +1 -0
- package/components/editor/icons/sub.svg +1 -0
- package/components/editor/icons/super.svg +1 -0
- package/components/editor/icons/table.svg +1 -0
- package/components/editor/icons/text.svg +1 -0
- package/components/editor/icons/time.svg +1 -0
- package/components/editor/icons/undo.svg +1 -0
- package/components/editor/icons/unindent.svg +1 -0
- package/components/editor/icons/unlink.svg +1 -0
- package/components/page/Acknowledgements.svelte +35 -24
- package/components/page/Acknowledgements.svelte.d.ts +4 -4
- package/components/page/Authors.svelte +34 -17
- package/components/page/Authors.svelte.d.ts +7 -6
- package/components/page/BookLoader.svelte +59 -0
- package/components/page/BookLoader.svelte.d.ts +16 -0
- package/components/page/BulkReferenceEditor.svelte +54 -23
- package/components/page/BulkReferenceEditor.svelte.d.ts +4 -4
- package/components/page/Chapter.svelte +234 -143
- package/components/page/Chapter.svelte.d.ts +3 -3
- package/components/page/ChapterContext.d.ts +4 -4
- package/components/page/ChapterNumber.svelte +9 -0
- package/components/page/ChapterNumber.svelte.d.ts +27 -0
- package/components/page/ChapterTitle.svelte +16 -0
- package/components/page/ChapterTitle.svelte.d.ts +18 -0
- package/components/page/Contexts.d.ts +42 -22
- package/components/page/Contexts.js +129 -17
- package/components/page/DefinitionView.svelte +129 -90
- package/components/page/DefinitionView.svelte.d.ts +3 -3
- package/components/page/Description.svelte +31 -19
- package/components/page/Description.svelte.d.ts +4 -4
- package/components/page/Edition.svelte +135 -80
- package/components/page/Edition.svelte.d.ts +5 -6
- package/components/page/EditionLoader.svelte +99 -0
- package/components/page/EditionLoader.svelte.d.ts +18 -0
- package/components/page/Editions.svelte +106 -0
- package/components/page/Editions.svelte.d.ts +14 -0
- package/components/page/Glossary.svelte +65 -49
- package/components/page/Glossary.svelte.d.ts +4 -4
- package/components/page/Header.svelte +143 -56
- package/components/page/Header.svelte.d.ts +8 -6
- package/components/page/Index.svelte +116 -80
- package/components/page/Index.svelte.d.ts +4 -4
- package/components/page/Instructions.svelte +18 -17
- package/components/page/Instructions.svelte.d.ts +6 -4
- package/components/page/License.svelte +39 -23
- package/components/page/License.svelte.d.ts +4 -4
- package/components/page/Loading.svelte +102 -12
- package/components/page/Loading.svelte.d.ts +6 -2
- package/components/page/Media.svelte +81 -53
- package/components/page/Media.svelte.d.ts +4 -4
- package/components/page/MediaPreview.svelte +26 -8
- package/components/page/MediaPreview.svelte.d.ts +3 -3
- package/components/page/Muted.svelte +10 -0
- package/components/page/Muted.svelte.d.ts +27 -0
- package/components/page/Outline.svelte +279 -59
- package/components/page/Outline.svelte.d.ts +3 -3
- package/components/page/Page.svelte +40 -9
- package/components/page/Page.svelte.d.ts +3 -3
- package/components/page/PageHeader.svelte +14 -0
- package/components/page/PageHeader.svelte.d.ts +18 -0
- package/components/page/PageParagraph.svelte +18 -0
- package/components/page/PageParagraph.svelte.d.ts +27 -0
- package/components/page/PossibleChapter.svelte +7 -7
- package/components/page/PossibleChapter.svelte.d.ts +4 -4
- package/components/page/PossibleReference.svelte +6 -11
- package/components/page/PossibleReference.svelte.d.ts +6 -7
- package/components/page/Print.svelte +27 -3
- package/components/page/Print.svelte.d.ts +4 -4
- package/components/page/Publish.svelte +134 -0
- package/components/page/Publish.svelte.d.ts +14 -0
- package/components/page/Reference.svelte +259 -117
- package/components/page/Reference.svelte.d.ts +5 -5
- package/components/page/References.svelte +45 -48
- package/components/page/References.svelte.d.ts +4 -4
- package/components/page/Rows.svelte +54 -0
- package/components/page/Rows.svelte.d.ts +27 -0
- package/components/page/Search.svelte +88 -63
- package/components/page/Search.svelte.d.ts +4 -4
- package/components/page/Status.svelte +46 -39
- package/components/page/Status.svelte.d.ts +4 -9
- package/components/page/SubdomainEditor.svelte +41 -27
- package/components/page/SubdomainEditor.svelte.d.ts +4 -4
- package/components/page/TableOfContents.svelte +264 -191
- package/components/page/TableOfContents.svelte.d.ts +4 -4
- package/components/page/TableOfContentsImage.svelte +8 -8
- package/components/page/TableOfContentsImage.svelte.d.ts +3 -3
- package/components/page/TableOfContentsRow.svelte +97 -34
- package/components/page/TableOfContentsRow.svelte.d.ts +4 -4
- package/components/page/ThemeEditor.svelte +177 -39
- package/components/page/ThemeEditor.svelte.d.ts +4 -4
- package/components/page/ThemeEditorPreview.svelte +35 -23
- package/components/page/ThemeEditorPreview.svelte.d.ts +5 -5
- package/components/page/ThemeSetEditor.svelte +15 -13
- package/components/page/ThemeSetEditor.svelte.d.ts +4 -4
- package/components/page/ThemeVariableEditor.svelte +24 -15
- package/components/page/ThemeVariableEditor.svelte.d.ts +3 -3
- package/components/page/Title.svelte +12 -0
- package/components/page/Title.svelte.d.ts +27 -0
- package/components/page/Unknown.svelte +28 -21
- package/components/page/Unknown.svelte.d.ts +4 -4
- package/components/page/margins.js +50 -33
- package/index.d.ts +13 -0
- package/index.js +14 -0
- package/models/CRUD.d.ts +27 -0
- package/models/CRUD.js +262 -0
- package/models/Firebase.d.ts +1 -0
- package/models/Firebase.js +26 -16
- package/models/book/Book.d.ts +40 -39
- package/models/book/Book.js +121 -121
- package/models/book/BookMedia.d.ts +3 -3
- package/models/book/BookMedia.js +22 -16
- package/models/book/BookSaveStatus.d.ts +7 -0
- package/models/book/BookSaveStatus.js +8 -0
- package/models/book/Chapter.d.ts +50 -39
- package/models/book/Chapter.js +189 -198
- package/models/book/ChapterID.js +7 -7
- package/models/book/Definition.d.ts +1 -1
- package/models/book/Edition.d.ts +87 -61
- package/models/book/Edition.js +460 -309
- package/models/book/Reference.d.ts +24 -0
- package/models/book/Reference.js +78 -0
- package/models/book/Schema.d.ts +168 -0
- package/models/book/Schema.js +115 -0
- package/models/book/Theme.d.ts +44 -37
- package/models/book/Theme.js +452 -52
- package/models/book/ThemeColors.d.ts +1 -1
- package/models/book/Words.d.ts +2 -0
- package/models/book/Words.js +110 -0
- package/models/chapter/AtomNode.d.ts +4 -4
- package/models/chapter/AtomNode.js +20 -13
- package/models/chapter/BlockNode.d.ts +9 -10
- package/models/chapter/BlockNode.js +32 -13
- package/models/chapter/BlocksNode.d.ts +10 -10
- package/models/chapter/BlocksNode.js +315 -120
- package/models/chapter/BlocksNode.test.js +494 -228
- package/models/chapter/Bookkeeping.d.ts +1 -1
- package/models/chapter/CalloutNode.d.ts +3 -3
- package/models/chapter/CalloutNode.js +34 -12
- package/models/chapter/Caret.d.ts +9 -7
- package/models/chapter/Caret.js +11 -6
- package/models/chapter/ChapterNode.d.ts +11 -11
- package/models/chapter/ChapterNode.js +70 -33
- package/models/chapter/CitationsNode.d.ts +3 -3
- package/models/chapter/CitationsNode.js +31 -12
- package/models/chapter/CodeNode.d.ts +11 -6
- package/models/chapter/CodeNode.js +143 -34
- package/models/chapter/CommentNode.d.ts +5 -5
- package/models/chapter/CommentNode.js +29 -13
- package/models/chapter/DefinitionNode.d.ts +2 -2
- package/models/chapter/DefinitionNode.js +15 -7
- package/models/chapter/Edit.d.ts +3 -3
- package/models/chapter/EmbedNode.d.ts +9 -5
- package/models/chapter/EmbedNode.js +108 -35
- package/models/chapter/ErrorNode.d.ts +2 -2
- package/models/chapter/ErrorNode.js +34 -12
- package/models/chapter/FootnoteNode.d.ts +5 -5
- package/models/chapter/FootnoteNode.js +34 -16
- package/models/chapter/FormatNode.d.ts +10 -10
- package/models/chapter/FormatNode.js +237 -106
- package/models/chapter/FormatNode.test.js +87 -45
- package/models/chapter/InlineCodeNode.d.ts +2 -2
- package/models/chapter/InlineCodeNode.js +22 -9
- package/models/chapter/LabelNode.d.ts +4 -4
- package/models/chapter/LabelNode.js +31 -13
- package/models/chapter/LinkNode.d.ts +2 -2
- package/models/chapter/LinkNode.js +21 -9
- package/models/chapter/ListNode.d.ts +8 -8
- package/models/chapter/ListNode.js +99 -38
- package/models/chapter/ListNode.test.js +29 -24
- package/models/chapter/MetadataNode.d.ts +3 -3
- package/models/chapter/MetadataNode.js +13 -5
- package/models/chapter/Node.d.ts +5 -3
- package/models/chapter/Node.js +76 -29
- package/models/chapter/Node.test.js +20 -18
- package/models/chapter/ParagraphNode.d.ts +6 -6
- package/models/chapter/ParagraphNode.js +84 -29
- package/models/chapter/ParagraphNode.test.js +22 -13
- package/models/chapter/Parser.d.ts +27 -27
- package/models/chapter/Parser.js +220 -206
- package/models/chapter/Parser.test.js +16 -16
- package/models/chapter/Position.d.ts +1 -1
- package/models/chapter/QuoteNode.d.ts +6 -6
- package/models/chapter/QuoteNode.js +61 -23
- package/models/chapter/RootNode.d.ts +4 -4
- package/models/chapter/RuleNode.d.ts +2 -2
- package/models/chapter/RuleNode.js +31 -11
- package/models/chapter/TableNode.d.ts +8 -6
- package/models/chapter/TableNode.js +89 -34
- package/models/chapter/TableNode.test.js +22 -24
- package/models/chapter/TextNode.d.ts +6 -6
- package/models/chapter/TextNode.js +72 -32
- package/models/chapter/TextNode.test.js +4 -4
- package/package.json +108 -26
- package/util/getSubdomain.js +8 -6
- package/util/isMobile.js +1 -1
- package/util/mineReference.d.ts +3 -2
- package/util/mineReference.js +67 -29
- package/util/scrollToEyeLevel.js +6 -1
- package/components/chapter/renderPosition.d.ts +0 -3
- package/components/chapter/renderPosition.js +0 -4
- package/components/editor/ToolbarIcon.svelte +0 -22
- package/components/editor/ToolbarIcon.svelte.d.ts +0 -16
- package/components/page/Alert.svelte +0 -11
- package/components/page/Alert.svelte.d.ts +0 -23
- package/components/page/Revisions.svelte +0 -124
- package/components/page/Revisions.svelte.d.ts +0 -14
- package/models/BookLoader.d.ts +0 -2
- package/models/BookLoader.js +0 -67
- package/models/Firestore.d.ts +0 -22
- package/models/Firestore.js +0 -194
- package/models/chapter/ReferenceNode.d.ts +0 -29
- package/models/chapter/ReferenceNode.js +0 -48
- package/models/loadEdition.d.ts +0 -5
- package/models/loadEdition.js +0 -16
package/models/book/Chapter.js
CHANGED
|
@@ -1,221 +1,212 @@
|
|
|
1
|
-
import Parser from
|
|
2
|
-
import
|
|
3
|
-
import { loadChapterTextFromFirestore, updateChapterTextInFirestore } from "../Firestore";
|
|
1
|
+
import Parser from '../chapter/Parser';
|
|
2
|
+
import CommonWords from './Words';
|
|
4
3
|
export default class Chapter {
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
// Inputs
|
|
5
|
+
ref;
|
|
6
|
+
id;
|
|
7
|
+
title;
|
|
8
|
+
authors;
|
|
9
|
+
image;
|
|
10
|
+
numbered;
|
|
11
|
+
forthcoming;
|
|
12
|
+
section;
|
|
13
|
+
text;
|
|
14
|
+
uids;
|
|
15
|
+
// Derived values
|
|
16
|
+
_ast = undefined;
|
|
17
|
+
_index = undefined;
|
|
18
|
+
_wordCount = undefined;
|
|
12
19
|
// A list of requested edits, stored as promises, resolved
|
|
13
20
|
// when the book is ready to save.
|
|
14
21
|
edits = [];
|
|
15
22
|
lastEdit = 0;
|
|
16
23
|
// A set of listeners that are notified when the chapter text changes.
|
|
17
24
|
listeners = new Set();
|
|
18
|
-
constructor(
|
|
19
|
-
this.
|
|
25
|
+
constructor(ref, id, title, authors, image, numbered, forthcoming, section, text, uids) {
|
|
26
|
+
this.ref = ref;
|
|
27
|
+
this.id = id;
|
|
28
|
+
this.title = title;
|
|
29
|
+
this.authors = authors.slice();
|
|
30
|
+
this.image = image;
|
|
31
|
+
this.numbered = numbered;
|
|
32
|
+
this.forthcoming = forthcoming;
|
|
33
|
+
this.section = section;
|
|
34
|
+
this.text = text;
|
|
35
|
+
this.uids = uids;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert a chapter spec and it's text into a chapter object.
|
|
39
|
+
* The spec may contain the text itself, but it may not, so we require it to be
|
|
40
|
+
* repeated here to guarantee its provided.
|
|
41
|
+
*/
|
|
42
|
+
static fromJSON(spec, text) {
|
|
20
43
|
// Copy the spec, filling in defaults as necessary.
|
|
21
|
-
|
|
22
|
-
ref: spec.ref,
|
|
23
|
-
id: spec.id,
|
|
24
|
-
title: spec.title,
|
|
25
|
-
authors: spec.authors ?? [],
|
|
26
|
-
image: spec.image ?? null,
|
|
27
|
-
numbered: spec.numbered === true || spec.numbered === undefined,
|
|
28
|
-
forthcoming: spec.forthcoming === true,
|
|
29
|
-
text: spec.text
|
|
30
|
-
};
|
|
31
|
-
// If the chapter has text, then parse it, count searchable words, and compute an index.
|
|
32
|
-
if (this.spec.text !== undefined)
|
|
33
|
-
this.setText(this.spec.text);
|
|
34
|
-
else if (this.spec.ref) {
|
|
35
|
-
loadChapterTextFromFirestore(this.spec.ref).then(text => this.setText(text.text));
|
|
36
|
-
}
|
|
37
|
-
// Otherwise, set them all to undefined.
|
|
38
|
-
else {
|
|
39
|
-
this.ast = undefined;
|
|
40
|
-
this.wordCount = 0;
|
|
41
|
-
this.index = undefined;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
saveEdits() {
|
|
45
|
-
if (this.edition.editionRef && this.spec.ref && this.spec.text !== undefined) {
|
|
46
|
-
// If it's been more than a second since our last edit and there
|
|
47
|
-
// are edits that haven't been saved, try updating the book,
|
|
48
|
-
// and if we succeed, resolve all of the edits, and if we fail,
|
|
49
|
-
// then reject them.
|
|
50
|
-
if (Date.now() - this.lastEdit > 1000 && this.edits.length > 0) {
|
|
51
|
-
// Tell listeners that this book model changed.
|
|
52
|
-
this.edition.notifyListeners(BookSaveStatus.Saving);
|
|
53
|
-
updateChapterTextInFirestore(this.edition.editionRef, this.spec.ref, this.spec.text)
|
|
54
|
-
.then(() => {
|
|
55
|
-
// Approve the edits.
|
|
56
|
-
this.edits.forEach(edit => edit.resolve());
|
|
57
|
-
this.edition.notifyListeners(BookSaveStatus.Saved);
|
|
58
|
-
})
|
|
59
|
-
.catch(() => {
|
|
60
|
-
// Reject the edits.
|
|
61
|
-
this.edits.forEach(edit => edit.reject());
|
|
62
|
-
this.edition.notifyListeners(BookSaveStatus.Error);
|
|
63
|
-
})
|
|
64
|
-
.finally(() => {
|
|
65
|
-
// Reset the edit queue.
|
|
66
|
-
this.edits = [];
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
44
|
+
return new Chapter(spec.ref, spec.id, spec.title, spec.authors ?? [], spec.image ?? null, spec.numbered === true || spec.numbered === undefined, spec.forthcoming === true, spec.section, spec.text ?? text, spec.uids);
|
|
70
45
|
}
|
|
71
|
-
|
|
72
|
-
removeListener(listener) { this.listeners.delete(listener); }
|
|
73
|
-
notifyListeners() {
|
|
74
|
-
this.listeners.forEach(listener => this.spec.text !== undefined ? listener.call(undefined, this.spec.text) : undefined);
|
|
75
|
-
}
|
|
76
|
-
// Adds a save request to the queue, to be resolved later after a period of
|
|
77
|
-
// inactivity. Returns a promise that will eventually be resolved.
|
|
78
|
-
requestSave() {
|
|
79
|
-
// Tell listeners that this chapter model changed.
|
|
80
|
-
this.edition.notifyListeners(BookSaveStatus.Changed);
|
|
81
|
-
// Return a promise that will resolve or reject later after this model saves the edits to the database.
|
|
82
|
-
this.lastEdit = Date.now();
|
|
83
|
-
const promise = new Promise((resolve, reject) => {
|
|
84
|
-
this.edits.push({ resolve: resolve, reject: reject });
|
|
85
|
-
});
|
|
86
|
-
return promise;
|
|
87
|
-
}
|
|
88
|
-
toObject() {
|
|
89
|
-
// Deep copy to prevent external mutations.
|
|
90
|
-
const payload = JSON.parse(JSON.stringify(this.spec));
|
|
91
|
-
// Reassign a copy of the Firebase ref, since the deep copy doesn't work for it.
|
|
92
|
-
payload.ref = this.spec.ref;
|
|
46
|
+
toJSON() {
|
|
93
47
|
// Note that we don't include the chapter text in the payload; that's stored in the chapters subcollection.
|
|
94
48
|
// We just return the chapter metadata here, which is stored in the book collection.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
49
|
+
const json = {
|
|
50
|
+
id: this.id,
|
|
51
|
+
title: this.title,
|
|
52
|
+
authors: this.authors.slice(),
|
|
53
|
+
image: this.image,
|
|
54
|
+
numbered: this.numbered,
|
|
55
|
+
forthcoming: this.forthcoming,
|
|
56
|
+
uids: this.uids,
|
|
57
|
+
};
|
|
58
|
+
if (this.ref)
|
|
59
|
+
json.ref = this.ref;
|
|
60
|
+
if (this.section)
|
|
61
|
+
json.section = this.section;
|
|
62
|
+
return json;
|
|
106
63
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (this.spec.section !== section) {
|
|
110
|
-
this.spec.section = section;
|
|
111
|
-
return this.edition.requestSave();
|
|
112
|
-
}
|
|
64
|
+
getRef() {
|
|
65
|
+
return this.ref;
|
|
113
66
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (this.spec.forthcoming !== forthcoming) {
|
|
117
|
-
this.spec.forthcoming = forthcoming;
|
|
118
|
-
return this.edition.requestSave();
|
|
119
|
-
}
|
|
67
|
+
withEditors(uids) {
|
|
68
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, uids);
|
|
120
69
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (numbered !== this.spec.numbered) {
|
|
124
|
-
this.spec.numbered = numbered;
|
|
125
|
-
return this.edition.requestSave();
|
|
126
|
-
}
|
|
70
|
+
withRef(ref) {
|
|
71
|
+
return new Chapter(ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
127
72
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.setAST(Parser.parseChapter(this.edition, text));
|
|
131
|
-
}
|
|
132
|
-
setAST(node) {
|
|
133
|
-
this.ast = node;
|
|
134
|
-
const newText = this.ast.toBookdown();
|
|
135
|
-
const changed = this.spec.text !== newText;
|
|
136
|
-
this.spec.text = newText;
|
|
137
|
-
this.wordCount = this.ast.toText().split(/\s+/).length;
|
|
138
|
-
this.index = this.computeIndex();
|
|
139
|
-
// Don't save if its the same. This is just an optimization.
|
|
140
|
-
if (changed) {
|
|
141
|
-
this.notifyListeners();
|
|
142
|
-
if (this.edition.editionRef && this.spec.ref)
|
|
143
|
-
return this.requestSave();
|
|
144
|
-
}
|
|
73
|
+
withoutRef() {
|
|
74
|
+
return new Chapter(undefined, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
145
75
|
}
|
|
146
|
-
|
|
147
|
-
this.
|
|
148
|
-
return this.edition.requestSave();
|
|
76
|
+
getID() {
|
|
77
|
+
return this.id;
|
|
149
78
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (index >= 0 && index < this.spec.authors.length) {
|
|
153
|
-
this.spec.authors[index] = name;
|
|
154
|
-
return this.edition.requestSave();
|
|
155
|
-
}
|
|
79
|
+
withChapterID(id) {
|
|
80
|
+
return new Chapter(this.ref, id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
156
81
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this.spec.authors.splice(index, 1);
|
|
160
|
-
return this.edition.requestSave();
|
|
161
|
-
}
|
|
82
|
+
getSection() {
|
|
83
|
+
return this.section;
|
|
162
84
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
85
|
+
withSection(section) {
|
|
86
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, section, this.text, this.uids);
|
|
87
|
+
}
|
|
88
|
+
isForthcoming() {
|
|
89
|
+
return this.forthcoming;
|
|
90
|
+
}
|
|
91
|
+
asForthcoming(forthcoming) {
|
|
92
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, forthcoming, this.section, this.text, this.uids);
|
|
93
|
+
}
|
|
94
|
+
isNumbered() {
|
|
95
|
+
return this.numbered;
|
|
96
|
+
}
|
|
97
|
+
asNumbered(numbered) {
|
|
98
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
99
|
+
}
|
|
100
|
+
isEditor(uid) {
|
|
101
|
+
return this.uids.includes(uid);
|
|
102
|
+
}
|
|
103
|
+
getText() {
|
|
104
|
+
return this.text;
|
|
105
|
+
}
|
|
106
|
+
withText(text) {
|
|
107
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, text, this.uids);
|
|
108
|
+
}
|
|
109
|
+
withAST(ast) {
|
|
110
|
+
const newChapter = new Chapter(this.ref, this.id, this.title, this.authors, this.image, this.numbered, this.forthcoming, this.section, ast.toBookdown(), this.uids);
|
|
111
|
+
newChapter._ast = ast;
|
|
112
|
+
return newChapter;
|
|
113
|
+
}
|
|
114
|
+
getAuthors() {
|
|
115
|
+
return this.authors;
|
|
116
|
+
}
|
|
117
|
+
withAuthor(name) {
|
|
118
|
+
return new Chapter(this.ref, this.id, this.title, [...this.authors, name], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
119
|
+
}
|
|
120
|
+
withRenamedAuthor(index, name) {
|
|
121
|
+
if (index < 0 || index >= this.authors.length)
|
|
122
|
+
return this;
|
|
123
|
+
return new Chapter(this.ref, this.id, this.title, [
|
|
124
|
+
...this.authors.slice(0, index),
|
|
125
|
+
name,
|
|
126
|
+
...this.authors.slice(index + 1),
|
|
127
|
+
], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
128
|
+
}
|
|
129
|
+
withoutAuthor(index) {
|
|
130
|
+
if (index < 0 || index >= this.authors.length)
|
|
131
|
+
return this;
|
|
132
|
+
return new Chapter(this.ref, this.id, this.title, [...this.authors.slice(0, index), ...this.authors.slice(index + 1)], this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
133
|
+
}
|
|
134
|
+
getTitle() {
|
|
135
|
+
return this.title;
|
|
136
|
+
}
|
|
137
|
+
withTitle(title) {
|
|
138
|
+
return new Chapter(this.ref, this.id, title, this.authors, this.image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
139
|
+
}
|
|
140
|
+
getImage() {
|
|
141
|
+
return this.image;
|
|
142
|
+
}
|
|
143
|
+
withImage(image) {
|
|
144
|
+
return new Chapter(this.ref, this.id, this.title, this.authors, image, this.numbered, this.forthcoming, this.section, this.text, this.uids);
|
|
145
|
+
}
|
|
146
|
+
getAST(edition) {
|
|
147
|
+
// Compute the cache if necessary
|
|
148
|
+
if (this._ast === undefined)
|
|
149
|
+
this._ast = Parser.parseChapter(edition, this.text);
|
|
150
|
+
return this._ast;
|
|
151
|
+
}
|
|
152
|
+
getWordCount(edition) {
|
|
153
|
+
if (this._wordCount === undefined)
|
|
154
|
+
this._wordCount = this.getAST(edition).toText().split(/\s+/).length;
|
|
155
|
+
return this._wordCount;
|
|
169
156
|
}
|
|
170
|
-
getPosition() { return this.edition.getChapterPosition(this.getChapterID()); }
|
|
171
|
-
move(increment) { return this.edition.moveChapter(this.getChapterID(), increment); }
|
|
172
|
-
delete() { return this.edition.deleteChapter(this.getChapterID()); }
|
|
173
|
-
getImage() { return this.spec.image; }
|
|
174
|
-
setImage(embed) {
|
|
175
|
-
if (this.spec.image === embed)
|
|
176
|
-
return;
|
|
177
|
-
this.spec.image = embed;
|
|
178
|
-
return this.edition.requestSave();
|
|
179
|
-
}
|
|
180
|
-
getIndex() { return this.index; }
|
|
181
|
-
getAST() { return this.ast; }
|
|
182
157
|
// Utility function
|
|
183
|
-
getReadingTime() {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
word
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
158
|
+
getReadingTime(edition) {
|
|
159
|
+
return this.isForthcoming()
|
|
160
|
+
? undefined
|
|
161
|
+
: Math.max(1, Math.round(this.getWordCount(edition) / 150));
|
|
162
|
+
}
|
|
163
|
+
getIndex(edition) {
|
|
164
|
+
if (this._index === undefined) {
|
|
165
|
+
const ast = this.getAST(edition);
|
|
166
|
+
// Build a list of common words
|
|
167
|
+
let commonWords = new Set();
|
|
168
|
+
CommonWords.forEach((word) => commonWords.add(word));
|
|
169
|
+
// Get all the text in the chapter.
|
|
170
|
+
let text = ast.toText();
|
|
171
|
+
// Split by word boundaries.
|
|
172
|
+
const words = text.split(/\b/);
|
|
173
|
+
// Index the words
|
|
174
|
+
const index = {};
|
|
175
|
+
words.forEach((word, wordNumber) => {
|
|
176
|
+
// Skip non words. We keep them for search results.
|
|
177
|
+
if (!/[a-zA-Z\u2019]+/.test(word))
|
|
178
|
+
return;
|
|
179
|
+
word = word.toLowerCase();
|
|
180
|
+
// Should we include?
|
|
181
|
+
// • It shouldn't be a common word
|
|
182
|
+
// • It shouldn't have an apostrophe
|
|
183
|
+
// • It should be longer than two letters
|
|
184
|
+
// • It shouldn't end in 'ly'
|
|
185
|
+
if (!commonWords.has(word) &&
|
|
186
|
+
word.indexOf('\u2019') < 0 &&
|
|
187
|
+
word.length > 2 &&
|
|
188
|
+
word.substring(word.length - 2, word.length) !== 'ly') {
|
|
189
|
+
// If we haven't started a list of occurrences, start one.
|
|
190
|
+
if (!(word in index))
|
|
191
|
+
index[word] = [];
|
|
192
|
+
let match = {
|
|
193
|
+
left: words
|
|
194
|
+
.slice(Math.max(0, wordNumber - 10), Math.max(0, wordNumber - 1) + 1)
|
|
195
|
+
.join(''),
|
|
196
|
+
match: words[wordNumber],
|
|
197
|
+
right: words
|
|
198
|
+
.slice(Math.min(words.length - 1, wordNumber + 1), Math.min(words.length - 1, wordNumber + 10) + 1)
|
|
199
|
+
.join(''),
|
|
200
|
+
};
|
|
201
|
+
// Add the occurrence, but a lower case canonical version.
|
|
202
|
+
index[word.toLowerCase()].push(match);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
this._index = index;
|
|
206
|
+
}
|
|
207
|
+
return this._index;
|
|
208
|
+
}
|
|
209
|
+
toString() {
|
|
210
|
+
return `${this.title} by ${this.authors.join(', ')}: ${this.text.substring(0, 32)}}`;
|
|
220
211
|
}
|
|
221
212
|
}
|
package/models/book/ChapterID.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const ChapterIDs = {
|
|
2
|
-
TableOfContentsID:
|
|
3
|
-
ReferencesID:
|
|
4
|
-
SearchID:
|
|
5
|
-
MediaID:
|
|
6
|
-
IndexID:
|
|
7
|
-
GlossaryID:
|
|
8
|
-
UnknownID:
|
|
2
|
+
TableOfContentsID: '',
|
|
3
|
+
ReferencesID: 'references',
|
|
4
|
+
SearchID: 'search',
|
|
5
|
+
MediaID: 'media',
|
|
6
|
+
IndexID: 'index',
|
|
7
|
+
GlossaryID: 'glossary',
|
|
8
|
+
UnknownID: 'unknown',
|
|
9
9
|
};
|
|
10
10
|
export default ChapterIDs;
|
package/models/book/Edition.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import Chapter from './Chapter';
|
|
2
2
|
import type { ChapterSpecification } from './Chapter';
|
|
3
|
-
import EmbedNode from
|
|
4
|
-
import
|
|
3
|
+
import EmbedNode from '../chapter/EmbedNode';
|
|
4
|
+
import Reference from './Reference';
|
|
5
5
|
import type Theme from './Theme';
|
|
6
6
|
import type Definition from './Definition.js';
|
|
7
|
-
import type Book from './Book.js';
|
|
8
7
|
import type { DocumentReference } from 'firebase/firestore';
|
|
9
|
-
|
|
8
|
+
import type Book from './Book';
|
|
9
|
+
import type FormatNode from '../chapter/FormatNode';
|
|
10
|
+
import type { EditionInfo } from './Book';
|
|
11
|
+
export type EditionSpecification = {
|
|
12
|
+
bookRef: DocumentReference;
|
|
10
13
|
title: string;
|
|
14
|
+
number: number;
|
|
15
|
+
summary: string;
|
|
16
|
+
published: number | null;
|
|
11
17
|
authors: string[];
|
|
12
18
|
images: Record<string, string | null>;
|
|
13
19
|
description: string;
|
|
@@ -15,87 +21,104 @@ export declare type EditionSpecification = {
|
|
|
15
21
|
license: string;
|
|
16
22
|
acknowledgements: string;
|
|
17
23
|
tags: string[];
|
|
18
|
-
revisions: [string, string][];
|
|
19
24
|
sources: Record<string, string>;
|
|
20
25
|
references: Record<string, string | string[]>;
|
|
21
26
|
symbols: Record<string, string>;
|
|
22
27
|
glossary: Record<string, Definition>;
|
|
23
28
|
theme: Theme | null;
|
|
24
|
-
uids:
|
|
25
|
-
|
|
29
|
+
uids: string[];
|
|
30
|
+
chapteruids: string[];
|
|
31
|
+
active: Record<string, string>;
|
|
26
32
|
};
|
|
27
|
-
export declare enum BookSaveStatus {
|
|
28
|
-
Changed = 0,
|
|
29
|
-
Saving = 1,
|
|
30
|
-
Saved = 2,
|
|
31
|
-
Error = 3
|
|
32
|
-
}
|
|
33
33
|
export default class Edition {
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
readonly bookRef: DocumentReference;
|
|
35
|
+
readonly editionRef: DocumentReference | undefined;
|
|
36
|
+
readonly uids: string[];
|
|
37
|
+
readonly title: string;
|
|
38
|
+
readonly authors: string[];
|
|
39
|
+
readonly number: number;
|
|
40
|
+
readonly summary: string;
|
|
41
|
+
readonly published: number | null;
|
|
42
|
+
readonly images: Record<string, string | null>;
|
|
43
|
+
readonly description: string;
|
|
44
|
+
readonly chapters: Chapter[];
|
|
45
|
+
readonly license: string;
|
|
46
|
+
readonly acknowledgements: string;
|
|
47
|
+
readonly tags: string[];
|
|
48
|
+
readonly sources: Record<string, string>;
|
|
49
|
+
readonly references: Record<string, Reference | FormatNode>;
|
|
50
|
+
readonly symbols: Record<string, string>;
|
|
51
|
+
readonly glossary: Record<string, Definition>;
|
|
52
|
+
readonly theme: Theme | null;
|
|
53
|
+
readonly active: Record<string, string>;
|
|
54
|
+
constructor(bookRef: DocumentReference, editionRef: DocumentReference | undefined, uids: string[], title: string, authors: string[], number: number, summary: string, published: number | null, images: Record<string, string | null>, description: string, chapters: Chapter[], license: string, acknowledgements: string, tags: string[], sources: Record<string, string>, references: Record<string, string | string[]> | Record<string, FormatNode | Reference>, symbols: Record<string, string>, glossary: Record<string, Definition>, theme: Theme | null, active: Record<string, string>);
|
|
55
|
+
static fromJSON(editionRef: DocumentReference | undefined, spec: EditionSpecification): Edition;
|
|
56
|
+
static parseReference(citationID: string, ref: string | string[], edition: Edition, short?: boolean): FormatNode | Reference;
|
|
57
|
+
toObject(): EditionSpecification;
|
|
58
|
+
getBookRef(): DocumentReference<import("@firebase/firestore").DocumentData>;
|
|
59
|
+
getEditionRef(): DocumentReference<import("@firebase/firestore").DocumentData> | undefined;
|
|
60
|
+
getChapterUIDS(): string[];
|
|
61
|
+
withRef(editionRef: DocumentReference | undefined): Edition;
|
|
56
62
|
getTitle(): string;
|
|
57
|
-
|
|
63
|
+
withTitle(title: string): Edition;
|
|
58
64
|
getDescription(): string;
|
|
59
|
-
setDescription(
|
|
65
|
+
setDescription(description: string): Edition;
|
|
60
66
|
getAcknowledgements(): string;
|
|
61
|
-
|
|
67
|
+
withAcknowledgements(acks: string): Edition;
|
|
68
|
+
withSummary(summary: string): Edition;
|
|
69
|
+
asPublished(published: boolean): Edition;
|
|
62
70
|
getLicense(): string;
|
|
63
|
-
setLicense(
|
|
71
|
+
setLicense(license: string): Edition;
|
|
64
72
|
getChapters(): Chapter[];
|
|
65
73
|
hasChapter(chapterID: string): boolean;
|
|
66
74
|
getChapter(chapterID: string): Chapter | undefined;
|
|
75
|
+
getChapterByRef(ref: DocumentReference): Chapter | undefined;
|
|
67
76
|
getChapterPosition(chapterID: string): number | undefined;
|
|
68
77
|
getChapterCount(): number;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
withChapters(chapters: Chapter[]): Edition;
|
|
79
|
+
withChapterText(text: [DocumentReference, string][]): Edition;
|
|
80
|
+
withRevisedChapter(previous: Chapter, edited: Chapter): Edition;
|
|
81
|
+
withoutRefs(): Edition;
|
|
82
|
+
withIncrementedEditionNumber(): Edition;
|
|
83
|
+
withNewChapter(): Edition;
|
|
84
|
+
withoutChapter(chapterID: string): Edition;
|
|
85
|
+
withMovedChapter(chapterID: string, increment: number): Edition;
|
|
72
86
|
getSymbols(): Record<string, string>;
|
|
73
87
|
hasReferences(): boolean;
|
|
74
|
-
getReferences(): Record<string,
|
|
75
|
-
getReference(citationID: string):
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
getReferences(): Record<string, FormatNode | Reference>;
|
|
89
|
+
getReference(citationID: string): FormatNode | Reference | undefined;
|
|
90
|
+
withReferences(newReferences: Record<string, FormatNode | Reference>): Edition;
|
|
91
|
+
withNewReferences(references: Reference[]): Edition;
|
|
92
|
+
withEditedReference(ref: Reference): Edition;
|
|
93
|
+
withEditedReferenceID(newCitationID: string, ref: Reference): Edition | undefined;
|
|
94
|
+
withoutReference(citationID: string): Edition;
|
|
80
95
|
hasGlossary(): boolean;
|
|
81
96
|
getGlossary(): Record<string, Definition>;
|
|
82
97
|
hasDefinition(id: string): boolean;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
withGlossary(glossary: Record<string, Definition>): Edition;
|
|
99
|
+
withDefinition(id: string, phrase: string, definition: string, synonyms: string[]): Edition;
|
|
100
|
+
withoutDefinition(id: string): Edition;
|
|
101
|
+
withEditedDefinition(id: string, definition: Definition): Edition;
|
|
102
|
+
withEditedDefinitionID(id: string, newID: string): Edition | undefined;
|
|
87
103
|
getTags(): string[];
|
|
88
104
|
getTheme(): Theme | null;
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
withTheme(theme: Theme | null): Edition;
|
|
106
|
+
withThemeValue(group: string, name: string, value: string): Edition;
|
|
91
107
|
getAuthors(): string[];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
withAuthors(authors: string[]): Edition;
|
|
109
|
+
withAuthor(name: string): Edition;
|
|
110
|
+
withAuthorName(index: number, name: string): Edition;
|
|
111
|
+
withoutAuthor(index: number): Edition;
|
|
112
|
+
withEditors(uids: string[]): Edition;
|
|
96
113
|
hasImage(id: string): boolean;
|
|
97
114
|
getImage(id: string): string | null;
|
|
98
|
-
|
|
115
|
+
withImage(id: string, embed: string | null): Edition;
|
|
116
|
+
isEditor(uid: string): boolean;
|
|
117
|
+
isChapterEditor(uid: string): boolean;
|
|
118
|
+
getLeasee(content: string): string | undefined;
|
|
119
|
+
hasLease(uid: string, content: string): boolean;
|
|
120
|
+
isLeased(contentID: string): boolean;
|
|
121
|
+
withLock(uid: string, content: string, lock: boolean): Edition;
|
|
99
122
|
getBookReadingTime(): number | undefined;
|
|
100
123
|
getChapterNumber(chapterID: string): undefined;
|
|
101
124
|
getSource(sourceID: string): string | null;
|
|
@@ -106,6 +129,9 @@ export default class Edition {
|
|
|
106
129
|
getNextChapterID(chapterID: string): string | null;
|
|
107
130
|
getPreviousChapterID(chapterID: string): string | null;
|
|
108
131
|
getEmbeds(): EmbedNode[];
|
|
109
|
-
|
|
110
|
-
|
|
132
|
+
isLatestEdition(book: Book): boolean;
|
|
133
|
+
isLatestPublishedEdition(book: Book): boolean;
|
|
134
|
+
getEditionNumber(): number;
|
|
135
|
+
getEditionLabel(): string;
|
|
136
|
+
getInfo(): EditionInfo | undefined;
|
|
111
137
|
}
|