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,48 +1,190 @@
|
|
|
1
|
+
<svelte:options immutable={true} />
|
|
2
|
+
|
|
1
3
|
<script>import { isMobile, watchMobile } from '../../util/isMobile';
|
|
2
4
|
import { onMount } from 'svelte';
|
|
3
|
-
import { getChapter } from '../page/Contexts';
|
|
5
|
+
import { getCaret, getChapter, isChapterEditable, } from '../page/Contexts';
|
|
6
|
+
export let node;
|
|
4
7
|
export let id;
|
|
8
|
+
export let label;
|
|
5
9
|
let hovered = false;
|
|
6
10
|
let chapter = getChapter();
|
|
11
|
+
$: editable = isChapterEditable();
|
|
12
|
+
let caret = getCaret();
|
|
7
13
|
// If there's no marginal selected or this is different from the current selection, this is hidden.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
$: selectedMarginal = $chapter?.marginal;
|
|
15
|
+
$: isHidden = editable
|
|
16
|
+
? // If editable, it's hidden if the caret is not inside the marginal content.
|
|
17
|
+
!($caret?.range?.start.node === node ||
|
|
18
|
+
$caret?.range?.start.node
|
|
19
|
+
.getAncestors($caret.root)
|
|
20
|
+
.some((ancestor) => ancestor === node))
|
|
21
|
+
: // If not editable, it's hidden if it's not selected.
|
|
22
|
+
$selectedMarginal !== id;
|
|
11
23
|
function toggle() {
|
|
24
|
+
if (editable)
|
|
25
|
+
return;
|
|
12
26
|
if ($chapter) {
|
|
13
|
-
if (isMobile() && isHidden
|
|
14
|
-
$chapter.
|
|
27
|
+
if (isMobile() && isHidden)
|
|
28
|
+
$chapter.marginal.set(id);
|
|
15
29
|
// Otherwise, deselect.
|
|
16
30
|
else
|
|
17
|
-
$chapter.
|
|
31
|
+
$chapter.marginal.set(undefined);
|
|
18
32
|
}
|
|
19
33
|
}
|
|
20
|
-
function handleEnter() {
|
|
21
|
-
|
|
34
|
+
function handleEnter() {
|
|
35
|
+
hovered = true;
|
|
36
|
+
}
|
|
37
|
+
function handleExit() {
|
|
38
|
+
hovered = false;
|
|
39
|
+
}
|
|
22
40
|
onMount(() => {
|
|
23
41
|
const mediaWatch = watchMobile();
|
|
24
|
-
mediaWatch.addEventListener(
|
|
25
|
-
return () => mediaWatch.removeEventListener(
|
|
42
|
+
mediaWatch.addEventListener('change', toggle);
|
|
43
|
+
return () => mediaWatch.removeEventListener('change', toggle);
|
|
26
44
|
});
|
|
27
45
|
</script>
|
|
28
46
|
|
|
29
|
-
<span
|
|
30
|
-
class={
|
|
31
|
-
|
|
47
|
+
<span
|
|
48
|
+
class={`bookish-marginal-interactor ${
|
|
49
|
+
hovered ? ' bookish-marginal-hovered' : ''
|
|
50
|
+
} ${isHidden ? '' : 'bookish-marginal-selected'} ${
|
|
51
|
+
editable ? '' : 'interactive'
|
|
52
|
+
}`}
|
|
53
|
+
aria-label={label}
|
|
54
|
+
tabIndex="0"
|
|
32
55
|
on:mousedown={toggle}
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
on:keydown={(event) =>
|
|
57
|
+
event.key === 'Enter' || event.key === ' ' ? toggle() : undefined}
|
|
58
|
+
on:mouseenter={handleEnter}
|
|
59
|
+
on:mouseleave={handleExit}><slot name="interactor" /></span
|
|
60
|
+
><span
|
|
61
|
+
class={'bookish-marginal' +
|
|
62
|
+
(isHidden ? ' bookish-marginal-hidden' : '') +
|
|
63
|
+
(hovered ? ' bookish-marginal-hovered' : '')}
|
|
64
|
+
tabIndex={editable ? null : 0}
|
|
65
|
+
on:mousedown={toggle}
|
|
66
|
+
on:keydown={(event) =>
|
|
67
|
+
event.key === 'Enter' || event.key === ' ' ? toggle() : undefined}
|
|
68
|
+
on:mouseenter={handleEnter}
|
|
35
69
|
on:mouseleave={handleExit}
|
|
36
70
|
>
|
|
37
|
-
<slot name="
|
|
71
|
+
<slot name="content" />
|
|
38
72
|
</span>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
73
|
+
|
|
74
|
+
<style>
|
|
75
|
+
:global(.bookish-definition)
|
|
76
|
+
.bookish-marginal-interactor.bookish-marginal-hovered {
|
|
77
|
+
border-bottom-color: var(--bookish-link-color) !important;
|
|
78
|
+
border-bottom-width: 3px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Mobile */
|
|
82
|
+
@media screen and (max-width: 1200px) {
|
|
83
|
+
/* Fixed position for small screens. */
|
|
84
|
+
.bookish-marginal {
|
|
85
|
+
background-color: var(--bookish-background-color);
|
|
86
|
+
padding: 0.75em;
|
|
87
|
+
position: fixed;
|
|
88
|
+
width: auto;
|
|
89
|
+
height: auto;
|
|
90
|
+
left: 0;
|
|
91
|
+
right: 0;
|
|
92
|
+
bottom: 0;
|
|
93
|
+
z-index: 2;
|
|
94
|
+
transform: translateY(0);
|
|
95
|
+
transition: transform 0.2s ease-in;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.interactive {
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Handle nested marginals by just not showing them. */
|
|
103
|
+
.bookish-marginal :global(.bookish-marginal) {
|
|
104
|
+
display: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.bookish-marginal-interactor:hover {
|
|
108
|
+
font-weight: bold;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:global(.bookish-definition) .bookish-marginal-interactor:hover {
|
|
112
|
+
font-weight: normal;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:global(.bookish-definition:hover) {
|
|
116
|
+
border-bottom-color: var(--bookish-border-color-bold) !important;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.bookish-marginal-hidden {
|
|
120
|
+
transform: translateY(100%);
|
|
121
|
+
transition: transform 0.2s ease-out;
|
|
122
|
+
height: 0;
|
|
123
|
+
bottom: 0;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Desktop */
|
|
128
|
+
@media screen and (min-width: 1200px) {
|
|
129
|
+
/* On larger screens, put marginal right things in the right margin. */
|
|
130
|
+
.bookish-marginal {
|
|
131
|
+
float: right;
|
|
132
|
+
width: 12rem;
|
|
133
|
+
display: block;
|
|
134
|
+
padding-bottom: 0.5rem;
|
|
135
|
+
position: absolute;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
:global(
|
|
139
|
+
.bookish-definition
|
|
140
|
+
.bookish-marginal.bookish-marginal-hovered
|
|
141
|
+
.bookish-definition-entry
|
|
142
|
+
) {
|
|
143
|
+
background: linear-gradient(
|
|
144
|
+
to right,
|
|
145
|
+
var(--bookish-link-color) 0px,
|
|
146
|
+
var(--bookish-link-color) 3px,
|
|
147
|
+
transparent 3px
|
|
148
|
+
)
|
|
149
|
+
no-repeat right;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* A little circle around the citation and footer symbols, when hovered on a device that supports hovering. */
|
|
154
|
+
@media (hover: hover) {
|
|
155
|
+
.bookish-marginal-interactor.bookish-marginal-hovered
|
|
156
|
+
:global(.bookish-citation-symbol:before),
|
|
157
|
+
.bookish-marginal-interactor.bookish-marginal-hovered
|
|
158
|
+
:global(.bookish-footnote-symbol:before),
|
|
159
|
+
.bookish-marginal-interactor.bookish-marginal-hovered
|
|
160
|
+
:global(.bookish-comment-symbol:before) {
|
|
161
|
+
opacity: 0.3;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* A little circle around the citation and footer symbols, when hovered */
|
|
166
|
+
.bookish-marginal-interactor.bookish-marginal-selected
|
|
167
|
+
:global(.bookish-citation-symbol:before),
|
|
168
|
+
.bookish-marginal-interactor.bookish-marginal-selected
|
|
169
|
+
:global(.bookish-footnote-symbol:before),
|
|
170
|
+
.bookish-marginal-interactor.bookish-marginal-selected
|
|
171
|
+
:global(.bookish-comment-symbol:before) {
|
|
172
|
+
opacity: 0.7;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.bookish-marginal-interactor :global(.bookish-citation-symbol:before),
|
|
176
|
+
.bookish-marginal-interactor :global(.bookish-footnote-symbol:before),
|
|
177
|
+
.bookish-marginal-interactor :global(.bookish-comment-symbol:before) {
|
|
178
|
+
content: '';
|
|
179
|
+
width: 3em;
|
|
180
|
+
height: 3em;
|
|
181
|
+
top: -1em;
|
|
182
|
+
left: calc(-1.5em + 50%); /* Centered plus half of the span width */
|
|
183
|
+
border-radius: 3em;
|
|
184
|
+
position: absolute;
|
|
185
|
+
z-index: -1;
|
|
186
|
+
opacity: 0;
|
|
187
|
+
background-color: var(--bookish-highlight-color);
|
|
188
|
+
transition: opacity 0.2s;
|
|
189
|
+
}
|
|
190
|
+
</style>
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type Node from '../../models/chapter/Node';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
5
|
+
node: Node;
|
|
4
6
|
id: string;
|
|
7
|
+
label: string;
|
|
5
8
|
};
|
|
6
9
|
events: {
|
|
7
10
|
[evt: string]: CustomEvent<any>;
|
|
@@ -11,9 +14,9 @@ declare const __propDef: {
|
|
|
11
14
|
content: {};
|
|
12
15
|
};
|
|
13
16
|
};
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
+
export type MarginalProps = typeof __propDef.props;
|
|
18
|
+
export type MarginalEvents = typeof __propDef.events;
|
|
19
|
+
export type MarginalSlots = typeof __propDef.slots;
|
|
17
20
|
export default class Marginal extends SvelteComponentTyped<MarginalProps, MarginalEvents, MarginalSlots> {
|
|
18
21
|
}
|
|
19
22
|
export {};
|
|
@@ -1,15 +1,88 @@
|
|
|
1
|
+
<svelte:options immutable={true} />
|
|
2
|
+
|
|
1
3
|
<script>import Format from './Format.svelte';
|
|
2
|
-
import { getChapter } from
|
|
4
|
+
import { getChapter, getEdition } from '../page/Contexts';
|
|
3
5
|
export let node;
|
|
4
6
|
export let placeholder = undefined;
|
|
5
7
|
$: level = node.getLevel();
|
|
6
8
|
$: chapter = getChapter();
|
|
7
|
-
$:
|
|
8
|
-
$:
|
|
9
|
+
$: edition = getEdition();
|
|
10
|
+
$: id =
|
|
11
|
+
node.getLevel() === 0 ||
|
|
12
|
+
$chapter === undefined ||
|
|
13
|
+
$edition === undefined
|
|
14
|
+
? undefined
|
|
15
|
+
: 'header-' +
|
|
16
|
+
($chapter.chapter.getAST($edition)?.getHeaders().indexOf(node) ??
|
|
17
|
+
'');
|
|
18
|
+
$: classes =
|
|
19
|
+
node.getLevel() === 0
|
|
20
|
+
? undefined
|
|
21
|
+
: 'bookish-header' +
|
|
22
|
+
($chapter && $chapter.highlightedID === id
|
|
23
|
+
? ' bookish-content-highlight'
|
|
24
|
+
: '');
|
|
9
25
|
</script>
|
|
10
26
|
|
|
11
27
|
{#if level === 0}
|
|
12
|
-
<p data-nodeid={node.nodeID}
|
|
28
|
+
<p data-nodeid={node.nodeID} class:placeholder
|
|
29
|
+
><Format node={node.getFormat()} placeholder={placeholder ?? '¶'} /></p
|
|
30
|
+
>
|
|
13
31
|
{:else}
|
|
14
|
-
<svelte:element
|
|
15
|
-
{
|
|
32
|
+
<svelte:element
|
|
33
|
+
this={`h${level + 1}`}
|
|
34
|
+
class={classes}
|
|
35
|
+
{id}
|
|
36
|
+
data-nodeid={node.nodeID}
|
|
37
|
+
><Format node={node.getFormat()} /></svelte:element
|
|
38
|
+
>
|
|
39
|
+
{/if}
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
p {
|
|
43
|
+
font-family: var(--bookish-paragraph-font-family);
|
|
44
|
+
font-size: var(--bookish-paragraph-font-size);
|
|
45
|
+
color: var(--bookish-paragraph-color);
|
|
46
|
+
|
|
47
|
+
margin-top: var(--bookish-paragraph-spacing);
|
|
48
|
+
margin-bottom: var(--bookish-paragraph-spacing);
|
|
49
|
+
|
|
50
|
+
line-height: var(--bookish-paragraph-line-height);
|
|
51
|
+
|
|
52
|
+
/* Allow paragraphs to break on words to support small screens. */
|
|
53
|
+
word-break: break-word;
|
|
54
|
+
|
|
55
|
+
/* Empty paragraphs should have at least some height. */
|
|
56
|
+
min-height: var(--bookish-paragraph-line-height);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.placeholder {
|
|
60
|
+
color: var(--bookish-muted-color);
|
|
61
|
+
font-style: italic;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
h2,
|
|
65
|
+
h3,
|
|
66
|
+
h4,
|
|
67
|
+
h5,
|
|
68
|
+
h6 {
|
|
69
|
+
font-family: var(--bookish-header-font-family);
|
|
70
|
+
font-weight: var(--bookish-header-font-weight);
|
|
71
|
+
margin-top: var(--bookish-header-spacing);
|
|
72
|
+
margin-bottom: var(--bookish-header-spacing);
|
|
73
|
+
line-height: var(--bookish-header-line-height);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
h2 {
|
|
77
|
+
font-size: var(--bookish-header-1-font-size);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
h3 {
|
|
81
|
+
font-size: var(--bookish-header-2-font-size);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
h4 {
|
|
85
|
+
font-size: var(--bookish-header-3-font-size);
|
|
86
|
+
font-style: italic;
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type ParagraphNode from
|
|
2
|
+
import type ParagraphNode from '../../models/chapter/ParagraphNode';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
node: ParagraphNode;
|
|
@@ -10,9 +10,9 @@ declare const __propDef: {
|
|
|
10
10
|
};
|
|
11
11
|
slots: {};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
13
|
+
export type ParagraphProps = typeof __propDef.props;
|
|
14
|
+
export type ParagraphEvents = typeof __propDef.events;
|
|
15
|
+
export type ParagraphSlots = typeof __propDef.slots;
|
|
16
16
|
export default class Paragraph extends SvelteComponentTyped<ParagraphProps, ParagraphEvents, ParagraphSlots> {
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<svelte:options immutable={true} />
|
|
2
|
+
|
|
3
|
+
<script>export let position;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<div
|
|
7
|
+
class={position === '<'
|
|
8
|
+
? 'inset-left'
|
|
9
|
+
: position === '>'
|
|
10
|
+
? 'inset-right'
|
|
11
|
+
: ''}><slot /></div
|
|
12
|
+
>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
/* Desktop */
|
|
16
|
+
@media screen and (min-width: 1200px) {
|
|
17
|
+
.inset-left {
|
|
18
|
+
float: left;
|
|
19
|
+
clear: both;
|
|
20
|
+
width: 75%;
|
|
21
|
+
margin-left: -30% !important;
|
|
22
|
+
margin-right: 2em;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.inset-right {
|
|
26
|
+
float: right;
|
|
27
|
+
clear: both;
|
|
28
|
+
width: 75%;
|
|
29
|
+
margin-right: -30% !important;
|
|
30
|
+
margin-left: 2em;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type Position from '../../models/chapter/Position';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
position: Position;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type PositionedProps = typeof __propDef.props;
|
|
15
|
+
export type PositionedEvents = typeof __propDef.events;
|
|
16
|
+
export type PositionedSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Positioned extends SvelteComponentTyped<PositionedProps, PositionedEvents, PositionedSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svelte:options immutable={true} />
|
|
2
|
+
|
|
3
|
+
<span><slot /></span>
|
|
4
|
+
|
|
5
|
+
<style>
|
|
6
|
+
span {
|
|
7
|
+
display: inline-block;
|
|
8
|
+
background-color: var(--bookish-error-background-color);
|
|
9
|
+
color: var(--bookish-error-color);
|
|
10
|
+
border-radius: var(--bookish-roundedness);
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
padding: var(--bookish-inline-padding)
|
|
13
|
+
calc(2 * var(--bookish-inline-padding));
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} ProblemProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} ProblemEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} ProblemSlots */
|
|
4
|
+
export default class Problem extends SvelteComponentTyped<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {
|
|
9
|
+
default: {};
|
|
10
|
+
}> {
|
|
11
|
+
}
|
|
12
|
+
export type ProblemProps = typeof __propDef.props;
|
|
13
|
+
export type ProblemEvents = typeof __propDef.events;
|
|
14
|
+
export type ProblemSlots = typeof __propDef.slots;
|
|
15
|
+
import { SvelteComponentTyped } from "svelte";
|
|
16
|
+
declare const __propDef: {
|
|
17
|
+
props: {
|
|
18
|
+
[x: string]: never;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {
|
|
24
|
+
default: {};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -1,81 +1,128 @@
|
|
|
1
1
|
<script context="module">"use strict";
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
|
-
<script>import { afterUpdate, onMount } from
|
|
4
|
+
<script>import { afterUpdate, onMount } from 'svelte';
|
|
5
5
|
import Code from './Code.svelte';
|
|
6
6
|
export let node;
|
|
7
7
|
export let startCode;
|
|
8
8
|
// Start with whatever code was passed in.
|
|
9
9
|
let code = startCode;
|
|
10
10
|
// What is currently rendered to the console (not always program output).
|
|
11
|
-
let output =
|
|
11
|
+
let output = '';
|
|
12
12
|
// Whether the runtime is loaded. Initialized based on presence of global.
|
|
13
13
|
let loaded = skulptLoaded();
|
|
14
14
|
let ref = null;
|
|
15
15
|
onMount(() => {
|
|
16
16
|
// Dynamically load the script to minimize payload and reduce index complexity.
|
|
17
|
-
if (document.getElementById(
|
|
17
|
+
if (document.getElementById('skulpt') === null) {
|
|
18
18
|
let script = document.createElement('script');
|
|
19
19
|
script.type = 'text/javascript';
|
|
20
20
|
script.async = true;
|
|
21
21
|
script.id = 'skulpt';
|
|
22
|
-
script.onload = () => loaded = true;
|
|
23
|
-
script.src =
|
|
22
|
+
script.onload = () => (loaded = true);
|
|
23
|
+
script.src =
|
|
24
|
+
'https://cdn.jsdelivr.net/combine/npm/skulpt@1.2.0/dist/skulpt.min.js,npm/skulpt@1.2.0/dist/skulpt-stdlib.min.js';
|
|
24
25
|
document.getElementsByTagName('head')[0].appendChild(script);
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
// Always scroll to the bottom of the output.
|
|
28
29
|
afterUpdate(() => {
|
|
29
30
|
if (ref) {
|
|
30
|
-
let outputView = ref.querySelector(
|
|
31
|
+
let outputView = ref.querySelector('.bookish-python-output');
|
|
31
32
|
if (outputView)
|
|
32
33
|
outputView.scrollTop = outputView.scrollHeight;
|
|
33
34
|
}
|
|
34
35
|
});
|
|
35
36
|
function skulptLoaded() {
|
|
36
|
-
return window.hasOwnProperty(
|
|
37
|
+
return window.hasOwnProperty('Sk');
|
|
38
|
+
}
|
|
39
|
+
function reset() {
|
|
40
|
+
code = startCode;
|
|
41
|
+
}
|
|
42
|
+
function handleEdit(newCode) {
|
|
43
|
+
code = newCode;
|
|
37
44
|
}
|
|
38
|
-
function reset() { code = startCode; }
|
|
39
|
-
function handleEdit(newCode) { code = newCode; }
|
|
40
45
|
function handleOutput(out) {
|
|
41
46
|
// Update the state to re-render.
|
|
42
|
-
output
|
|
47
|
+
output += out;
|
|
43
48
|
}
|
|
44
49
|
function start() {
|
|
45
50
|
if (skulptLoaded()) {
|
|
46
51
|
// Communicate that executing is starting, wait a second, then execute the program.
|
|
47
52
|
// This is important in case the user wants to run it again; it provides confirmation that it was run again.
|
|
48
|
-
output =
|
|
53
|
+
output = 'Executing...';
|
|
49
54
|
setTimeout(() => execute(), 500);
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
function execute() {
|
|
53
58
|
// Reset the output, run the code, and update it's output.
|
|
54
|
-
output =
|
|
59
|
+
output = '';
|
|
55
60
|
if (Sk) {
|
|
56
61
|
Sk.configure({ output: handleOutput });
|
|
57
62
|
try {
|
|
58
63
|
if (Sk)
|
|
59
|
-
Sk.importMainWithBody(
|
|
64
|
+
Sk.importMainWithBody('<stdin>', false, code, true);
|
|
60
65
|
}
|
|
61
66
|
catch (error) {
|
|
62
67
|
handleOutput(error);
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
|
-
$: lines = output.split(
|
|
71
|
+
$: lines = output.split('\n');
|
|
67
72
|
</script>
|
|
68
73
|
|
|
69
74
|
<div class="bookish-python" bind:this={ref}>
|
|
70
|
-
<Code
|
|
71
|
-
|
|
75
|
+
<Code
|
|
76
|
+
inline={false}
|
|
77
|
+
language={'python'}
|
|
78
|
+
editable
|
|
79
|
+
edited={handleEdit}
|
|
80
|
+
nodeID={node.nodeID}>{code}</Code
|
|
81
|
+
>
|
|
72
82
|
<div class="bookish-python-controls">
|
|
73
|
-
<button disabled={startCode === code
|
|
74
|
-
|
|
83
|
+
<button disabled={startCode === code} on:click={reset}
|
|
84
|
+
>{'\u21BB'}</button
|
|
85
|
+
>
|
|
86
|
+
<button disabled={!loaded} on:click={start}>{'\u25B6\uFE0E'}</button>
|
|
75
87
|
<div class="bookish-python-output">
|
|
76
|
-
{#each lines as line, index
|
|
77
|
-
<span class="python-output-line"
|
|
88
|
+
{#each lines as line, index}
|
|
89
|
+
<span class="python-output-line"
|
|
90
|
+
>{line}{#if index < lines.length - 1}<br />{/if}</span
|
|
91
|
+
>
|
|
78
92
|
{/each}
|
|
79
93
|
</div>
|
|
80
94
|
</div>
|
|
81
|
-
</div>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<style>
|
|
98
|
+
.bookish-python-controls {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: row;
|
|
101
|
+
align-items: stretch;
|
|
102
|
+
width: 100%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.bookish-python button {
|
|
106
|
+
background: var(--bookish-block-background-color);
|
|
107
|
+
border: 1px solid var(--bookish-border-color-light);
|
|
108
|
+
width: 3em;
|
|
109
|
+
height: 3rem;
|
|
110
|
+
padding: 0;
|
|
111
|
+
display: inline-block;
|
|
112
|
+
vertical-align: top;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.bookish-python .bookish-python-output {
|
|
116
|
+
flex: 1;
|
|
117
|
+
border: 1px solid lightGray;
|
|
118
|
+
padding: 0.5rem;
|
|
119
|
+
height: 3rem;
|
|
120
|
+
overflow-y: scroll;
|
|
121
|
+
display: inline-block;
|
|
122
|
+
vertical-align: top;
|
|
123
|
+
color: var(--bookish-paragraph-color);
|
|
124
|
+
font-family: var(--bookish-code-font-family);
|
|
125
|
+
font-weight: var(--bookish-code-font-weight);
|
|
126
|
+
font-size: var(--bookish-block-font-size);
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type CodeNode from
|
|
2
|
+
import type CodeNode from '../../models/chapter/CodeNode';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
node: CodeNode;
|
|
@@ -10,9 +10,9 @@ declare const __propDef: {
|
|
|
10
10
|
};
|
|
11
11
|
slots: {};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
13
|
+
export type PythonProps = typeof __propDef.props;
|
|
14
|
+
export type PythonEvents = typeof __propDef.events;
|
|
15
|
+
export type PythonSlots = typeof __propDef.slots;
|
|
16
16
|
export default class Python extends SvelteComponentTyped<PythonProps, PythonEvents, PythonSlots> {
|
|
17
17
|
}
|
|
18
18
|
export {};
|