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