bookish-press 0.4.46 → 0.4.47
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/.env.example +8 -0
- package/.firebaserc +8 -0
- package/.prettierignore +8 -0
- package/.prettierrc.json +5 -0
- package/_update-notifier-last-checked +0 -0
- package/firebase.json +46 -0
- package/firestore.indexes.json +4 -0
- package/firestore.rules +59 -0
- package/functions/.eslintrc.js +28 -0
- package/functions/package-lock.json +12595 -0
- package/functions/package.json +43 -0
- package/functions/src/index.ts +345 -0
- package/functions/tsconfig.dev.json +3 -0
- package/functions/tsconfig.json +15 -0
- package/package.json +53 -270
- package/scripts/claims.cjs +99 -0
- package/src/app.d.ts +9 -0
- package/src/app.html +24 -0
- package/src/lib/components/Auth.svelte +65 -0
- package/{components/Authentication.d.ts → src/lib/components/Authentication.ts} +2 -0
- package/{components → src/lib/components}/BookPreview.svelte +27 -22
- package/{components → src/lib/components}/External.svelte +2 -1
- package/src/lib/components/Link.svelte +58 -0
- package/{components → src/lib/components}/app/BookList.svelte +6 -3
- package/{components → src/lib/components}/app/Button.svelte +5 -4
- package/{components → src/lib/components}/app/Feedback.svelte +11 -7
- package/{components → src/lib/components}/app/Head.svelte +2 -1
- package/{components → src/lib/components}/app/Large.svelte +0 -0
- package/{components → src/lib/components}/app/Lead.svelte +0 -0
- package/{components → src/lib/components}/app/Link.svelte +4 -3
- package/{components → src/lib/components}/app/Options.svelte +5 -4
- package/{components → src/lib/components}/app/Paragraph.svelte +2 -1
- package/{components → src/lib/components}/app/Section.svelte +0 -0
- package/{components → src/lib/components}/app/Table.svelte +0 -0
- package/{components → src/lib/components}/app/TextInput.svelte +12 -9
- package/{components → src/lib/components}/chapter/Atom.svelte +18 -12
- package/src/lib/components/chapter/Block.svelte +42 -0
- package/{components → src/lib/components}/chapter/Callout.svelte +6 -3
- package/{components → src/lib/components}/chapter/CaptionedCode.svelte +21 -13
- package/{components → src/lib/components}/chapter/ChapterBody.svelte +13 -9
- package/{components → src/lib/components}/chapter/Citations.svelte +34 -33
- package/{components → src/lib/components}/chapter/Code.svelte +63 -59
- package/{components → src/lib/components}/chapter/Comment.svelte +30 -18
- package/{components → src/lib/components}/chapter/Definition.svelte +23 -17
- package/{components → src/lib/components}/chapter/Embed.svelte +97 -77
- package/src/lib/components/chapter/ErrorMessage.svelte +12 -0
- package/{components → src/lib/components}/chapter/ExtendedPrism.js +0 -0
- package/{components → src/lib/components}/chapter/Figure.svelte +34 -26
- package/{components → src/lib/components}/chapter/Footnote.svelte +32 -20
- package/{components → src/lib/components}/chapter/Format.svelte +39 -34
- package/{components → src/lib/components}/chapter/InlineCode.svelte +9 -5
- package/{components → src/lib/components}/chapter/Label.svelte +23 -14
- package/{components → src/lib/components}/chapter/Link.svelte +27 -21
- package/{components → src/lib/components}/chapter/List.svelte +5 -3
- package/{components → src/lib/components}/chapter/Marginal.svelte +54 -41
- package/{components → src/lib/components}/chapter/Paragraph.svelte +25 -20
- package/{components → src/lib/components}/chapter/Positioned.svelte +4 -1
- package/{components → src/lib/components}/chapter/Problem.svelte +0 -0
- package/src/lib/components/chapter/Python.svelte +144 -0
- package/{components → src/lib/components}/chapter/Quote.svelte +9 -5
- package/{components → src/lib/components}/chapter/Rule.svelte +4 -1
- package/{components → src/lib/components}/chapter/Table.svelte +11 -7
- package/src/lib/components/chapter/Text.svelte +109 -0
- package/src/lib/components/editor/BookishEditor.svelte +1101 -0
- package/src/lib/components/editor/CalloutEditor.svelte +14 -0
- package/{components → src/lib/components}/editor/CaptionedCodeEditor.svelte +10 -6
- package/src/lib/components/editor/CaretContext.ts +55 -0
- package/{components/editor/CaretState.d.ts → src/lib/components/editor/CaretState.ts} +6 -7
- package/{components/editor/CaretUtilities.d.ts → src/lib/components/editor/CaretUtilities.ts} +1 -0
- package/{components → src/lib/components}/editor/CaretView.svelte +25 -20
- package/src/lib/components/editor/CitationsEditor.svelte +64 -0
- package/{components/editor/Clipboard.d.ts → src/lib/components/editor/Clipboard.ts} +2 -1
- package/{components/editor/Command.d.ts → src/lib/components/editor/Command.ts} +8 -2
- package/{components/editor/Commands.js → src/lib/components/editor/Commands.ts} +730 -315
- package/src/lib/components/editor/ConfirmButton.svelte +51 -0
- package/src/lib/components/editor/DefinitionEditor.svelte +44 -0
- package/src/lib/components/editor/EmbedEditor.svelte +152 -0
- package/{components → src/lib/components}/editor/Icon.svelte +2 -1
- package/{components → src/lib/components}/editor/ImageChooser.svelte +24 -19
- package/src/lib/components/editor/InlineCodeEditor.svelte +16 -0
- package/{components → src/lib/components}/editor/LabelEditor.svelte +14 -9
- package/{components → src/lib/components}/editor/LanguageEditor.svelte +8 -5
- package/src/lib/components/editor/LinkEditor.svelte +110 -0
- package/{components → src/lib/components}/editor/Note.svelte +0 -0
- package/{components → src/lib/components}/editor/Permissions.svelte +43 -36
- package/src/lib/components/editor/PositionEditor.svelte +21 -0
- package/src/lib/components/editor/QuoteEditor.svelte +14 -0
- package/{components → src/lib/components}/editor/Switch.svelte +14 -11
- package/src/lib/components/editor/TableEditor.svelte +14 -0
- package/{components → src/lib/components}/editor/TextEditor.svelte +101 -89
- package/src/lib/components/editor/Toggle.svelte +47 -0
- package/src/lib/components/editor/Toolbar.svelte +297 -0
- package/{components → src/lib/components}/editor/ToolbarGroup.svelte +5 -3
- package/{components → src/lib/components}/editor/ToolbarSpacer.svelte +0 -0
- package/src/lib/components/editor/URLEditor.svelte +15 -0
- package/{components/editor/UndoState.d.ts → src/lib/components/editor/UndoState.ts} +3 -2
- package/{components → src/lib/components}/editor/icons/annotate.svg +0 -0
- package/{components → src/lib/components}/editor/icons/block.svg +0 -0
- package/{components → src/lib/components}/editor/icons/bold.svg +0 -0
- package/{components → src/lib/components}/editor/icons/bullets.svg +0 -0
- package/{components → src/lib/components}/editor/icons/callout.svg +0 -0
- package/{components → src/lib/components}/editor/icons/citation.svg +0 -0
- package/{components → src/lib/components}/editor/icons/clear.svg +0 -0
- package/{components → src/lib/components}/editor/icons/clipboard.svg +0 -0
- package/{components → src/lib/components}/editor/icons/code.svg +0 -0
- package/{components → src/lib/components}/editor/icons/columnafter.svg +0 -0
- package/{components → src/lib/components}/editor/icons/columnbefore.svg +0 -0
- package/{components → src/lib/components}/editor/icons/comment.svg +0 -0
- package/{components → src/lib/components}/editor/icons/copy.svg +0 -0
- package/{components → src/lib/components}/editor/icons/cut.svg +0 -0
- package/{components → src/lib/components}/editor/icons/define.svg +0 -0
- package/{components → src/lib/components}/editor/icons/deletecolumn.svg +0 -0
- package/{components → src/lib/components}/editor/icons/deleterow.svg +0 -0
- package/{components → src/lib/components}/editor/icons/footnote.svg +0 -0
- package/{components → src/lib/components}/editor/icons/header1.svg +0 -0
- package/{components → src/lib/components}/editor/icons/header2.svg +0 -0
- package/{components → src/lib/components}/editor/icons/header3.svg +0 -0
- package/{components → src/lib/components}/editor/icons/home.svg +0 -0
- package/{components → src/lib/components}/editor/icons/indent.svg +0 -0
- package/{components → src/lib/components}/editor/icons/italic.svg +0 -0
- package/{components → src/lib/components}/editor/icons/label.svg +0 -0
- package/{components → src/lib/components}/editor/icons/left.svg +0 -0
- package/{components → src/lib/components}/editor/icons/level.svg +0 -0
- package/{components → src/lib/components}/editor/icons/link.svg +0 -0
- package/{components → src/lib/components}/editor/icons/list.svg +0 -0
- package/{components → src/lib/components}/editor/icons/media.svg +0 -0
- package/{components → src/lib/components}/editor/icons/middle.svg +0 -0
- package/{components → src/lib/components}/editor/icons/numbers.svg +0 -0
- package/{components → src/lib/components}/editor/icons/paragraph.svg +0 -0
- package/{components → src/lib/components}/editor/icons/paste.svg +0 -0
- package/{components → src/lib/components}/editor/icons/quote.svg +0 -0
- package/{components → src/lib/components}/editor/icons/redo.svg +0 -0
- package/{components → src/lib/components}/editor/icons/right.svg +0 -0
- package/{components → src/lib/components}/editor/icons/rowabove.svg +0 -0
- package/{components → src/lib/components}/editor/icons/rowbelow.svg +0 -0
- package/{components → src/lib/components}/editor/icons/rule.svg +0 -0
- package/{components → src/lib/components}/editor/icons/sub.svg +0 -0
- package/{components → src/lib/components}/editor/icons/super.svg +0 -0
- package/{components → src/lib/components}/editor/icons/table.svg +0 -0
- package/{components → src/lib/components}/editor/icons/text.svg +0 -0
- package/{components → src/lib/components}/editor/icons/time.svg +0 -0
- package/{components → src/lib/components}/editor/icons/undo.svg +0 -0
- package/{components → src/lib/components}/editor/icons/unindent.svg +0 -0
- package/{components → src/lib/components}/editor/icons/unlink.svg +0 -0
- package/{components → src/lib/components}/page/Acknowledgements.svelte +19 -10
- package/src/lib/components/page/Authors.svelte +92 -0
- package/src/lib/components/page/BookLoader.svelte +77 -0
- package/src/lib/components/page/BulkReferenceEditor.svelte +86 -0
- package/src/lib/components/page/Chapter.svelte +449 -0
- package/src/lib/components/page/ChapterContext.ts +13 -0
- package/{components → src/lib/components}/page/ChapterNumber.svelte +0 -0
- package/{components → src/lib/components}/page/ChapterTitle.svelte +4 -2
- package/src/lib/components/page/Contexts.ts +176 -0
- package/{components → src/lib/components}/page/DefinitionView.svelte +52 -37
- package/{components → src/lib/components}/page/Description.svelte +15 -7
- package/src/lib/components/page/Edition.svelte +189 -0
- package/src/lib/components/page/EditionLoader.svelte +123 -0
- package/{components → src/lib/components}/page/Editions.svelte +22 -18
- package/{components → src/lib/components}/page/Glossary.svelte +33 -28
- package/{components → src/lib/components}/page/Header.svelte +59 -52
- package/{components → src/lib/components}/page/Index.svelte +48 -41
- package/{components → src/lib/components}/page/Instructions.svelte +2 -1
- package/{components → src/lib/components}/page/License.svelte +17 -9
- package/{components → src/lib/components}/page/Loading.svelte +0 -0
- package/{components → src/lib/components}/page/Media.svelte +44 -27
- package/{components → src/lib/components}/page/MediaPreview.svelte +3 -2
- package/{components → src/lib/components}/page/Muted.svelte +0 -0
- package/{components → src/lib/components}/page/Outline.svelte +140 -110
- package/src/lib/components/page/Page.svelte +94 -0
- package/{components → src/lib/components}/page/PageHeader.svelte +2 -1
- package/{components → src/lib/components}/page/PageParagraph.svelte +0 -0
- package/src/lib/components/page/PossibleChapter.svelte +16 -0
- package/src/lib/components/page/PossibleReference.svelte +14 -0
- package/{components → src/lib/components}/page/Print.svelte +5 -3
- package/{components → src/lib/components}/page/Publish.svelte +59 -52
- package/{components → src/lib/components}/page/Reference.svelte +39 -30
- package/{components → src/lib/components}/page/References.svelte +18 -14
- package/{components → src/lib/components}/page/Rows.svelte +0 -0
- package/src/lib/components/page/Search.svelte +153 -0
- package/{components → src/lib/components}/page/Status.svelte +5 -3
- package/{components → src/lib/components}/page/SubdomainEditor.svelte +16 -13
- package/{components → src/lib/components}/page/TableOfContents.svelte +79 -68
- package/src/lib/components/page/TableOfContentsImage.svelte +22 -0
- package/{components → src/lib/components}/page/TableOfContentsRow.svelte +34 -24
- package/{components → src/lib/components}/page/ThemeEditor.svelte +44 -33
- package/{components → src/lib/components}/page/ThemeEditorPreview.svelte +21 -12
- package/src/lib/components/page/ThemeSetEditor.svelte +21 -0
- package/{components → src/lib/components}/page/ThemeVariableEditor.svelte +18 -14
- package/{components → src/lib/components}/page/Title.svelte +0 -0
- package/{components → src/lib/components}/page/Unknown.svelte +10 -8
- package/{components/page/margins.js → src/lib/components/page/margins.ts} +79 -46
- package/{index.js → src/lib/index.js} +0 -0
- package/src/lib/models/CRUD.ts +469 -0
- package/{models/Firebase.js → src/lib/models/Firebase.ts} +26 -16
- package/src/lib/models/book/Book.ts +283 -0
- package/src/lib/models/book/BookMedia.ts +182 -0
- package/src/lib/models/book/BookSaveStatus.ts +8 -0
- package/src/lib/models/book/Chapter.ts +462 -0
- package/{models/book/ChapterID.js → src/lib/models/book/ChapterID.ts} +1 -0
- package/src/lib/models/book/Definition.ts +2 -0
- package/src/lib/models/book/Edition.ts +1216 -0
- package/src/lib/models/book/Reference.ts +171 -0
- package/{models/book/Schema.js → src/lib/models/book/Schema.ts} +1 -0
- package/{models/book/Theme.js → src/lib/models/book/Theme.ts} +110 -6
- package/{models/book/ThemeColors.d.ts → src/lib/models/book/ThemeColors.ts} +6 -0
- package/{models/book/Words.js → src/lib/models/book/Words.ts} +1 -0
- package/{models/chapter/AtomNode.js → src/lib/models/chapter/AtomNode.ts} +30 -10
- package/{models/chapter/BlockNode.js → src/lib/models/chapter/BlockNode.ts} +80 -47
- package/src/lib/models/chapter/BlocksNode.test.ts +867 -0
- package/{models/chapter/BlocksNode.js → src/lib/models/chapter/BlocksNode.ts} +571 -359
- package/{models/chapter/Bookkeeping.d.ts → src/lib/models/chapter/Bookkeeping.ts} +0 -0
- package/src/lib/models/chapter/CalloutNode.ts +79 -0
- package/{models/chapter/Caret.js → src/lib/models/chapter/Caret.ts} +50 -26
- package/src/lib/models/chapter/ChapterNode.ts +169 -0
- package/{models/chapter/CitationsNode.js → src/lib/models/chapter/CitationsNode.ts} +17 -10
- package/{models/chapter/CodeNode.js → src/lib/models/chapter/CodeNode.ts} +125 -62
- package/src/lib/models/chapter/CommentNode.ts +61 -0
- package/{models/chapter/DefinitionNode.js → src/lib/models/chapter/DefinitionNode.ts} +14 -8
- package/src/lib/models/chapter/Edit.ts +6 -0
- package/src/lib/models/chapter/EmbedNode.ts +257 -0
- package/{models/chapter/ErrorNode.js → src/lib/models/chapter/ErrorNode.ts} +15 -8
- package/src/lib/models/chapter/FootnoteNode.ts +59 -0
- package/src/lib/models/chapter/FormatNode.test.ts +137 -0
- package/{models/chapter/FormatNode.js → src/lib/models/chapter/FormatNode.ts} +443 -262
- package/{models/chapter/InlineCodeNode.js → src/lib/models/chapter/InlineCodeNode.ts} +17 -9
- package/{models/chapter/LabelNode.js → src/lib/models/chapter/LabelNode.ts} +26 -10
- package/{models/chapter/LinkNode.js → src/lib/models/chapter/LinkNode.ts} +12 -7
- package/{models/chapter/ListNode.test.js → src/lib/models/chapter/ListNode.test.ts} +57 -20
- package/{models/chapter/ListNode.js → src/lib/models/chapter/ListNode.ts} +277 -200
- package/src/lib/models/chapter/MetadataNode.ts +44 -0
- package/{models → src/lib/models}/chapter/Node.test.js +0 -0
- package/{models/chapter/Node.js → src/lib/models/chapter/Node.ts} +155 -71
- package/src/lib/models/chapter/ParagraphNode.test.ts +54 -0
- package/{models/chapter/ParagraphNode.js → src/lib/models/chapter/ParagraphNode.ts} +95 -58
- package/{models/chapter/Parser.test.js → src/lib/models/chapter/Parser.test.ts} +7 -0
- package/{models/chapter/Parser.js → src/lib/models/chapter/Parser.ts} +369 -184
- package/{models/chapter/Position.d.ts → src/lib/models/chapter/Position.ts} +0 -0
- package/src/lib/models/chapter/QuoteNode.ts +135 -0
- package/{models/chapter/RootNode.d.ts → src/lib/models/chapter/RootNode.ts} +2 -0
- package/{models/chapter/RuleNode.js → src/lib/models/chapter/RuleNode.ts} +9 -6
- package/{models/chapter/TableNode.test.js → src/lib/models/chapter/TableNode.test.ts} +27 -10
- package/{models/chapter/TableNode.js → src/lib/models/chapter/TableNode.ts} +141 -82
- package/{models/chapter/TextNode.test.js → src/lib/models/chapter/TextNode.test.ts} +2 -0
- package/{models/chapter/TextNode.js → src/lib/models/chapter/TextNode.ts} +117 -65
- package/{util/getSubdomain.js → src/lib/util/getSubdomain.ts} +14 -8
- package/{util/isMobile.js → src/lib/util/isMobile.ts} +1 -0
- package/{util/mineReference.js → src/lib/util/mineReference.ts} +45 -25
- package/{util/scrollToEyeLevel.js → src/lib/util/scrollToEyeLevel.ts} +4 -2
- package/src/params/edition.ts +3 -0
- package/src/routes/+error.svelte +12 -0
- package/src/routes/+layout.svelte +241 -0
- package/src/routes/+page.svelte +43 -0
- package/src/routes/Footer.svelte +0 -0
- package/src/routes/Header.svelte +112 -0
- package/src/routes/[bookid]/+layout.svelte +5 -0
- package/src/routes/[bookid]/[[editionid=edition]]/+error.svelte +14 -0
- package/src/routes/[bookid]/[[editionid=edition]]/+layout.svelte +7 -0
- package/src/routes/[bookid]/[[editionid=edition]]/+page.svelte +5 -0
- package/src/routes/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +5 -0
- package/src/routes/[bookid]/[[editionid=edition]]/glossary/+page.svelte +5 -0
- package/src/routes/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +5 -0
- package/src/routes/[bookid]/[[editionid=edition]]/media/+page.svelte +5 -0
- package/src/routes/[bookid]/[[editionid=edition]]/print/+page.svelte +5 -0
- package/src/routes/[bookid]/[[editionid=edition]]/references/+page.svelte +5 -0
- package/src/routes/[bookid]/[[editionid=edition]]/search/+page.svelte +5 -0
- package/src/routes/[bookid]/editions/+page.svelte +20 -0
- package/src/routes/about/+page.svelte +102 -0
- package/src/routes/confirm/+page.svelte +62 -0
- package/src/routes/email/+page.svelte +99 -0
- package/src/routes/login/+page.svelte +66 -0
- package/src/routes/read/+page.svelte +38 -0
- package/src/routes/write/+error.svelte +10 -0
- package/src/routes/write/+layout.svelte +11 -0
- package/src/routes/write/+page.svelte +114 -0
- package/src/routes/write/[bookid]/+layout.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/+layout.svelte +7 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/glossary/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/media/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/print/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/references/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/search/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/theme/+page.svelte +5 -0
- package/src/routes/write/[bookid]/[[editionid=edition]]/unknown/+page.svelte +5 -0
- package/src/routes/write/[bookid]/editions/+page.svelte +20 -0
- package/src/vite-env.d.ts +1 -0
- package/static/icons/favicon.png +0 -0
- package/static/icons/icon.png +0 -0
- package/static/icons/ios-icon.png +0 -0
- package/storage.rules +9 -0
- package/svelte.config.js +19 -0
- package/tsconfig.json +18 -0
- package/tsconfig.node.json +9 -0
- package/vite.config.ts +8 -0
- package/vite.reader.config.ts +32 -0
- package/components/Auth.svelte +0 -55
- package/components/Auth.svelte.d.ts +0 -16
- package/components/Authentication.js +0 -1
- package/components/BookPreview.svelte.d.ts +0 -18
- package/components/External.svelte.d.ts +0 -18
- package/components/Link.svelte +0 -51
- package/components/Link.svelte.d.ts +0 -18
- package/components/app/BookList.svelte.d.ts +0 -18
- package/components/app/Button.svelte.d.ts +0 -22
- package/components/app/Feedback.svelte.d.ts +0 -18
- package/components/app/Head.svelte.d.ts +0 -18
- package/components/app/Large.svelte.d.ts +0 -27
- package/components/app/Lead.svelte.d.ts +0 -27
- package/components/app/Link.svelte.d.ts +0 -20
- package/components/app/Options.svelte.d.ts +0 -19
- package/components/app/Paragraph.svelte.d.ts +0 -18
- package/components/app/Section.svelte.d.ts +0 -27
- package/components/app/Table.svelte.d.ts +0 -27
- package/components/app/TextInput.svelte.d.ts +0 -22
- package/components/chapter/Atom.svelte.d.ts +0 -19
- package/components/chapter/Block.svelte +0 -37
- package/components/chapter/Block.svelte.d.ts +0 -17
- package/components/chapter/Callout.svelte.d.ts +0 -17
- package/components/chapter/CaptionedCode.svelte.d.ts +0 -17
- package/components/chapter/ChapterBody.svelte.d.ts +0 -19
- package/components/chapter/Citations.svelte.d.ts +0 -17
- package/components/chapter/Code.svelte.d.ts +0 -22
- package/components/chapter/Comment.svelte.d.ts +0 -17
- package/components/chapter/Definition.svelte.d.ts +0 -17
- package/components/chapter/Embed.svelte.d.ts +0 -20
- package/components/chapter/ErrorMessage.svelte +0 -9
- package/components/chapter/ErrorMessage.svelte.d.ts +0 -17
- package/components/chapter/ExtendedPrism.d.ts +0 -2
- package/components/chapter/Figure.svelte.d.ts +0 -24
- package/components/chapter/Footnote.svelte.d.ts +0 -19
- package/components/chapter/Format.svelte.d.ts +0 -19
- package/components/chapter/InlineCode.svelte.d.ts +0 -17
- package/components/chapter/Label.svelte.d.ts +0 -17
- package/components/chapter/Link.svelte.d.ts +0 -17
- package/components/chapter/List.svelte.d.ts +0 -17
- package/components/chapter/Marginal.svelte.d.ts +0 -22
- package/components/chapter/Paragraph.svelte.d.ts +0 -18
- package/components/chapter/Positioned.svelte.d.ts +0 -19
- package/components/chapter/Problem.svelte.d.ts +0 -27
- package/components/chapter/Python.svelte +0 -128
- package/components/chapter/Python.svelte.d.ts +0 -18
- package/components/chapter/Quote.svelte.d.ts +0 -17
- package/components/chapter/Rule.svelte.d.ts +0 -17
- package/components/chapter/Table.svelte.d.ts +0 -17
- package/components/chapter/Text.svelte +0 -87
- package/components/chapter/Text.svelte.d.ts +0 -18
- package/components/editor/BookishEditor.svelte +0 -884
- package/components/editor/BookishEditor.svelte.d.ts +0 -25
- package/components/editor/CalloutEditor.svelte +0 -10
- package/components/editor/CalloutEditor.svelte.d.ts +0 -17
- package/components/editor/CaptionedCodeEditor.svelte.d.ts +0 -17
- package/components/editor/CaretContext.d.ts +0 -50
- package/components/editor/CaretContext.js +0 -1
- package/components/editor/CaretState.js +0 -1
- package/components/editor/CaretUtilities.js +0 -1
- package/components/editor/CaretView.svelte.d.ts +0 -25
- package/components/editor/CitationsEditor.svelte +0 -53
- package/components/editor/CitationsEditor.svelte.d.ts +0 -17
- package/components/editor/Clipboard.js +0 -1
- package/components/editor/Command.js +0 -1
- package/components/editor/Commands.d.ts +0 -3
- package/components/editor/ConfirmButton.svelte +0 -49
- package/components/editor/ConfirmButton.svelte.d.ts +0 -19
- package/components/editor/DefinitionEditor.svelte +0 -36
- package/components/editor/DefinitionEditor.svelte.d.ts +0 -17
- package/components/editor/EmbedEditor.svelte +0 -137
- package/components/editor/EmbedEditor.svelte.d.ts +0 -17
- package/components/editor/Icon.svelte.d.ts +0 -16
- package/components/editor/ImageChooser.svelte.d.ts +0 -18
- package/components/editor/InlineCodeEditor.svelte +0 -12
- package/components/editor/InlineCodeEditor.svelte.d.ts +0 -17
- package/components/editor/LabelEditor.svelte.d.ts +0 -17
- package/components/editor/LanguageEditor.svelte.d.ts +0 -17
- package/components/editor/LinkEditor.svelte +0 -100
- package/components/editor/LinkEditor.svelte.d.ts +0 -17
- package/components/editor/Note.svelte.d.ts +0 -27
- package/components/editor/Permissions.svelte.d.ts +0 -20
- package/components/editor/PositionEditor.svelte +0 -17
- package/components/editor/PositionEditor.svelte.d.ts +0 -18
- package/components/editor/QuoteEditor.svelte +0 -10
- package/components/editor/QuoteEditor.svelte.d.ts +0 -17
- package/components/editor/Switch.svelte.d.ts +0 -20
- package/components/editor/TableEditor.svelte +0 -10
- package/components/editor/TableEditor.svelte.d.ts +0 -17
- package/components/editor/TextEditor.svelte.d.ts +0 -24
- package/components/editor/Toggle.svelte +0 -41
- package/components/editor/Toggle.svelte.d.ts +0 -19
- package/components/editor/Toolbar.svelte +0 -249
- package/components/editor/Toolbar.svelte.d.ts +0 -17
- package/components/editor/ToolbarGroup.svelte.d.ts +0 -18
- package/components/editor/ToolbarSpacer.svelte.d.ts +0 -23
- package/components/editor/URLEditor.svelte +0 -13
- package/components/editor/URLEditor.svelte.d.ts +0 -18
- package/components/editor/UndoState.js +0 -1
- package/components/page/Acknowledgements.svelte.d.ts +0 -14
- package/components/page/Authors.svelte +0 -85
- package/components/page/Authors.svelte.d.ts +0 -21
- package/components/page/BookLoader.svelte +0 -59
- package/components/page/BookLoader.svelte.d.ts +0 -16
- package/components/page/BulkReferenceEditor.svelte +0 -63
- package/components/page/BulkReferenceEditor.svelte.d.ts +0 -14
- package/components/page/Chapter.svelte +0 -392
- package/components/page/Chapter.svelte.d.ts +0 -18
- package/components/page/ChapterContext.d.ts +0 -10
- package/components/page/ChapterContext.js +0 -1
- package/components/page/ChapterNumber.svelte.d.ts +0 -27
- package/components/page/ChapterTitle.svelte.d.ts +0 -18
- package/components/page/Contexts.d.ts +0 -47
- package/components/page/Contexts.js +0 -133
- package/components/page/DefinitionView.svelte.d.ts +0 -18
- package/components/page/Description.svelte.d.ts +0 -14
- package/components/page/Edition.svelte +0 -161
- package/components/page/Edition.svelte.d.ts +0 -20
- package/components/page/EditionLoader.svelte +0 -99
- package/components/page/EditionLoader.svelte.d.ts +0 -18
- package/components/page/Editions.svelte.d.ts +0 -14
- package/components/page/Glossary.svelte.d.ts +0 -14
- package/components/page/Header.svelte.d.ts +0 -29
- package/components/page/Index.svelte.d.ts +0 -14
- package/components/page/Instructions.svelte.d.ts +0 -18
- package/components/page/License.svelte.d.ts +0 -14
- package/components/page/Loading.svelte.d.ts +0 -23
- package/components/page/Media.svelte.d.ts +0 -14
- package/components/page/MediaPreview.svelte.d.ts +0 -19
- package/components/page/Muted.svelte.d.ts +0 -27
- package/components/page/Outline.svelte.d.ts +0 -19
- package/components/page/Page.svelte +0 -84
- package/components/page/Page.svelte.d.ts +0 -19
- package/components/page/PageHeader.svelte.d.ts +0 -18
- package/components/page/PageParagraph.svelte.d.ts +0 -27
- package/components/page/PossibleChapter.svelte +0 -14
- package/components/page/PossibleChapter.svelte.d.ts +0 -14
- package/components/page/PossibleReference.svelte +0 -11
- package/components/page/PossibleReference.svelte.d.ts +0 -18
- package/components/page/Print.svelte.d.ts +0 -14
- package/components/page/Publish.svelte.d.ts +0 -14
- package/components/page/Reference.svelte.d.ts +0 -17
- package/components/page/References.svelte.d.ts +0 -14
- package/components/page/Rows.svelte.d.ts +0 -27
- package/components/page/Search.svelte +0 -133
- package/components/page/Search.svelte.d.ts +0 -14
- package/components/page/Status.svelte.d.ts +0 -14
- package/components/page/SubdomainEditor.svelte.d.ts +0 -14
- package/components/page/TableOfContents.svelte.d.ts +0 -14
- package/components/page/TableOfContentsImage.svelte +0 -18
- package/components/page/TableOfContentsImage.svelte.d.ts +0 -16
- package/components/page/TableOfContentsRow.svelte.d.ts +0 -24
- package/components/page/ThemeEditor.svelte.d.ts +0 -14
- package/components/page/ThemeEditorPreview.svelte.d.ts +0 -17
- package/components/page/ThemeSetEditor.svelte +0 -19
- package/components/page/ThemeSetEditor.svelte.d.ts +0 -18
- package/components/page/ThemeVariableEditor.svelte.d.ts +0 -18
- package/components/page/Title.svelte.d.ts +0 -27
- package/components/page/Unknown.svelte.d.ts +0 -16
- package/components/page/margins.d.ts +0 -2
- package/index.d.ts +0 -15
- package/models/CRUD.d.ts +0 -27
- package/models/CRUD.js +0 -262
- package/models/Firebase.d.ts +0 -5
- package/models/book/Book.d.ts +0 -61
- package/models/book/Book.js +0 -135
- package/models/book/BookMedia.d.ts +0 -23
- package/models/book/BookMedia.js +0 -108
- package/models/book/BookSaveStatus.d.ts +0 -7
- package/models/book/BookSaveStatus.js +0 -8
- package/models/book/Chapter.d.ts +0 -81
- package/models/book/Chapter.js +0 -212
- package/models/book/ChapterID.d.ts +0 -10
- package/models/book/Definition.d.ts +0 -6
- package/models/book/Definition.js +0 -1
- package/models/book/Edition.d.ts +0 -139
- package/models/book/Edition.js +0 -620
- package/models/book/Reference.d.ts +0 -24
- package/models/book/Reference.js +0 -78
- package/models/book/Schema.d.ts +0 -174
- package/models/book/Theme.d.ts +0 -113
- package/models/book/ThemeColors.js +0 -1
- package/models/book/Words.d.ts +0 -2
- package/models/chapter/AtomNode.d.ts +0 -18
- package/models/chapter/BlockNode.d.ts +0 -20
- package/models/chapter/BlocksNode.d.ts +0 -50
- package/models/chapter/BlocksNode.test.d.ts +0 -1
- package/models/chapter/BlocksNode.test.js +0 -568
- package/models/chapter/Bookkeeping.js +0 -1
- package/models/chapter/CalloutNode.d.ts +0 -17
- package/models/chapter/CalloutNode.js +0 -58
- package/models/chapter/Caret.d.ts +0 -23
- package/models/chapter/ChapterNode.d.ts +0 -34
- package/models/chapter/ChapterNode.js +0 -117
- package/models/chapter/CitationsNode.d.ts +0 -16
- package/models/chapter/CodeNode.d.ts +0 -35
- package/models/chapter/CommentNode.d.ts +0 -18
- package/models/chapter/CommentNode.js +0 -48
- package/models/chapter/DefinitionNode.d.ts +0 -12
- package/models/chapter/Edit.d.ts +0 -7
- package/models/chapter/Edit.js +0 -1
- package/models/chapter/EmbedNode.d.ts +0 -45
- package/models/chapter/EmbedNode.js +0 -168
- package/models/chapter/ErrorNode.d.ts +0 -17
- package/models/chapter/FootnoteNode.d.ts +0 -18
- package/models/chapter/FootnoteNode.js +0 -47
- package/models/chapter/FormatNode.d.ts +0 -60
- package/models/chapter/FormatNode.test.d.ts +0 -1
- package/models/chapter/FormatNode.test.js +0 -96
- package/models/chapter/InlineCodeNode.d.ts +0 -12
- package/models/chapter/LabelNode.d.ts +0 -17
- package/models/chapter/LinkNode.d.ts +0 -12
- package/models/chapter/ListNode.d.ts +0 -51
- package/models/chapter/ListNode.test.d.ts +0 -1
- package/models/chapter/MetadataNode.d.ts +0 -17
- package/models/chapter/MetadataNode.js +0 -32
- package/models/chapter/Node.d.ts +0 -38
- package/models/chapter/Node.test.d.ts +0 -1
- package/models/chapter/ParagraphNode.d.ts +0 -33
- package/models/chapter/ParagraphNode.test.d.ts +0 -1
- package/models/chapter/ParagraphNode.test.js +0 -30
- package/models/chapter/Parser.d.ts +0 -75
- package/models/chapter/Parser.test.d.ts +0 -1
- package/models/chapter/Position.js +0 -1
- package/models/chapter/QuoteNode.d.ts +0 -25
- package/models/chapter/QuoteNode.js +0 -99
- package/models/chapter/RootNode.js +0 -1
- package/models/chapter/RuleNode.d.ts +0 -15
- package/models/chapter/TableNode.d.ts +0 -37
- package/models/chapter/TableNode.test.d.ts +0 -1
- package/models/chapter/TextNode.d.ts +0 -36
- package/models/chapter/TextNode.test.d.ts +0 -1
- package/util/getSubdomain.d.ts +0 -3
- package/util/isMobile.d.ts +0 -2
- package/util/mineReference.d.ts +0 -4
- package/util/scrollToEyeLevel.d.ts +0 -2
|
@@ -1,98 +1,110 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export let
|
|
15
|
-
let
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
field.blur();
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
enum Status {
|
|
3
|
+
Viewing,
|
|
4
|
+
Editing,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export let text: string;
|
|
8
|
+
export let label: string;
|
|
9
|
+
export let placeholder: string;
|
|
10
|
+
export let valid: (text: string) => string | undefined;
|
|
11
|
+
export let save: (
|
|
12
|
+
text: string
|
|
13
|
+
) => Promise<void> | undefined | void | string;
|
|
14
|
+
export let saveOnExit: boolean = false;
|
|
15
|
+
export let width: number | undefined = undefined;
|
|
16
|
+
export let clip: boolean = false;
|
|
17
|
+
export let move:
|
|
18
|
+
| ((el: HTMLElement, direction: -1 | 1) => void)
|
|
19
|
+
| undefined = undefined;
|
|
20
|
+
|
|
21
|
+
let status = Status.Viewing;
|
|
22
|
+
let field: HTMLInputElement | null = null;
|
|
23
|
+
let sizer: HTMLSpanElement | null = null;
|
|
24
|
+
|
|
25
|
+
$: error = valid(text);
|
|
26
|
+
|
|
27
|
+
// Grow the sizer when text or status changes.
|
|
28
|
+
$: {
|
|
29
|
+
if (sizer) {
|
|
30
|
+
// Set the invisible sizer to the text to set the container's width.
|
|
31
|
+
// The browser strips trailing spaces, causing jitter after a space, so we replace
|
|
32
|
+
// them with non-breaking spaces.
|
|
33
|
+
const sizedText = showPlaceholder()
|
|
34
|
+
? placeholder
|
|
35
|
+
: text.replace(/\s/g, '\u00a0');
|
|
36
|
+
// Clip the text to prevent this editor from getting too long when editing or when asked to.. If it goes past one line,
|
|
37
|
+
// the measurements and layout are way off.
|
|
38
|
+
const trimmedText =
|
|
39
|
+
width !== undefined &&
|
|
40
|
+
(clip === true || status === Status.Editing)
|
|
41
|
+
? sizedText.substring(0, width) + '…'
|
|
42
|
+
: sizedText;
|
|
43
|
+
sizer.innerHTML = trimmedText;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
// When
|
|
49
|
-
$: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
function startEditing() {
|
|
57
|
-
status = Status.Editing;
|
|
58
|
-
}
|
|
59
|
-
function stopEditing() {
|
|
60
|
-
status = Status.Viewing;
|
|
61
|
-
if (saveOnExit)
|
|
62
|
-
saveText(text);
|
|
63
|
-
}
|
|
64
|
-
function edit() {
|
|
65
|
-
if (field) {
|
|
66
|
-
text = field.value;
|
|
67
|
-
if (saveOnExit === false)
|
|
68
|
-
saveText(text);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function saveText(newText) {
|
|
72
|
-
if (validate(newText) === undefined) {
|
|
73
|
-
const revisedText = save(newText);
|
|
74
|
-
if (typeof revisedText === 'string') {
|
|
75
|
-
text = revisedText;
|
|
46
|
+
|
|
47
|
+
// When status changes, focus or blur.
|
|
48
|
+
$: {
|
|
49
|
+
if (field) {
|
|
50
|
+
if (status === Status.Editing) {
|
|
51
|
+
field.focus();
|
|
52
|
+
} else {
|
|
53
|
+
field.blur();
|
|
54
|
+
}
|
|
76
55
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
function
|
|
85
|
-
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// When text changes, save, unless we only save on exit.
|
|
59
|
+
$: {
|
|
60
|
+
if (!saveOnExit) saveText(text);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function showPlaceholder() {
|
|
64
|
+
return text === '';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function startEditing() {
|
|
68
|
+
status = Status.Editing;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function stopEditing() {
|
|
86
72
|
status = Status.Viewing;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
if (saveOnExit) saveText(text);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function edit() {
|
|
77
|
+
if (field) {
|
|
78
|
+
text = field.value;
|
|
79
|
+
if (saveOnExit === false) saveText(text);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function saveText(newText: string) {
|
|
84
|
+
if (validate(newText) === undefined) {
|
|
85
|
+
const revisedText = save(newText);
|
|
86
|
+
if (typeof revisedText === 'string') {
|
|
87
|
+
text = revisedText;
|
|
88
|
+
}
|
|
89
|
+
if (revisedText instanceof Promise)
|
|
90
|
+
revisedText.catch((err: Error) => (error = err.message));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function validate(value: string): string | undefined {
|
|
95
|
+
return valid(value);
|
|
90
96
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
|
|
98
|
+
function handleKeyPress(event: KeyboardEvent) {
|
|
99
|
+
if (event.key === 'Enter') status = Status.Viewing;
|
|
100
|
+
else if (event.key === 'ArrowUp' && move && field) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
move(field, -1);
|
|
103
|
+
} else if (event.key === 'ArrowDown' && move && field) {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
move(field, 1);
|
|
106
|
+
}
|
|
94
107
|
}
|
|
95
|
-
}
|
|
96
108
|
</script>
|
|
97
109
|
|
|
98
110
|
<span
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
enum Status {
|
|
3
|
+
Viewing,
|
|
4
|
+
Saving,
|
|
5
|
+
Error,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export let on: boolean;
|
|
9
|
+
export let save: (set: boolean) => Promise<void> | void;
|
|
10
|
+
|
|
11
|
+
let saving = Status.Viewing;
|
|
12
|
+
|
|
13
|
+
function toggle() {
|
|
14
|
+
saving = Status.Saving;
|
|
15
|
+
|
|
16
|
+
const promise = save(!on);
|
|
17
|
+
|
|
18
|
+
if (promise === undefined) {
|
|
19
|
+
saving = Status.Viewing;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
promise
|
|
24
|
+
.then(() => (saving = Status.Viewing))
|
|
25
|
+
.catch(() => (saving = Status.Error));
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div
|
|
30
|
+
class={`bookish-app-interactive ${
|
|
31
|
+
saving === Status.Saving ? ' bookish-text-editor-saving' : ''
|
|
32
|
+
} ${saving === Status.Error ? ' bookish-text-editor-error' : ''}`}
|
|
33
|
+
tabIndex="0"
|
|
34
|
+
role="switch"
|
|
35
|
+
aria-checked={on}
|
|
36
|
+
on:keydown={(event) =>
|
|
37
|
+
event.key === 'Enter' || event.key === 'Space' ? toggle() : undefined}
|
|
38
|
+
on:click={toggle}
|
|
39
|
+
>
|
|
40
|
+
<slot />
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
.bookish-app-interactive {
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import commands from './Commands';
|
|
3
|
+
import type Command from './Command';
|
|
4
|
+
|
|
5
|
+
import TextNode from '$lib/models/chapter/TextNode';
|
|
6
|
+
import AtomNode from '$lib/models/chapter/AtomNode';
|
|
7
|
+
|
|
8
|
+
import LinkNode from '$lib/models/chapter/LinkNode';
|
|
9
|
+
import LabelNode from '$lib/models/chapter/LabelNode';
|
|
10
|
+
import InlineCodeNode from '$lib/models/chapter/InlineCodeNode';
|
|
11
|
+
import CitationsNode from '$lib/models/chapter/CitationsNode';
|
|
12
|
+
import DefinitionNode from '$lib/models/chapter/DefinitionNode';
|
|
13
|
+
import CodeNode from '$lib/models/chapter/CodeNode';
|
|
14
|
+
import CalloutNode from '$lib/models/chapter/CalloutNode';
|
|
15
|
+
import EmbedNode from '$lib/models/chapter/EmbedNode';
|
|
16
|
+
import QuoteNode from '$lib/models/chapter/QuoteNode';
|
|
17
|
+
import type MetadataNode from '$lib/models/chapter/MetadataNode';
|
|
18
|
+
|
|
19
|
+
import LabelEditor from '$lib/components/editor/LabelEditor.svelte';
|
|
20
|
+
import InlineCodeEditor from '$lib/components/editor/InlineCodeEditor.svelte';
|
|
21
|
+
import CitationsEditor from '$lib/components/editor/CitationsEditor.svelte';
|
|
22
|
+
import LinkEditor from '$lib/components/editor/LinkEditor.svelte';
|
|
23
|
+
import DefinitionEditor from '$lib/components/editor/DefinitionEditor.svelte';
|
|
24
|
+
import CaptionedCodeEditor from '$lib/components/editor/CaptionedCodeEditor.svelte';
|
|
25
|
+
import CalloutEditor from '$lib/components/editor/CalloutEditor.svelte';
|
|
26
|
+
import QuoteEditor from '$lib/components/editor/QuoteEditor.svelte';
|
|
27
|
+
import EmbedEditor from '$lib/components/editor/EmbedEditor.svelte';
|
|
28
|
+
import TableEditor from '$lib/components/editor/TableEditor.svelte';
|
|
29
|
+
import ToolbarGroup from './ToolbarGroup.svelte';
|
|
30
|
+
import Icon from './Icon.svelte';
|
|
31
|
+
import Button from '../app/Button.svelte';
|
|
32
|
+
|
|
33
|
+
import AnnotateIcon from './icons/annotate.svg?raw';
|
|
34
|
+
import BlockIcon from './icons/block.svg?raw';
|
|
35
|
+
import ClipboardIcon from './icons/clipboard.svg?raw';
|
|
36
|
+
import LevelIcon from './icons/level.svg?raw';
|
|
37
|
+
import ListIcon from './icons/list.svg?raw';
|
|
38
|
+
import TextIcon from './icons/text.svg?raw';
|
|
39
|
+
import TimeIcon from './icons/time.svg?raw';
|
|
40
|
+
import TableIcon from './icons/table.svg?raw';
|
|
41
|
+
import LinkIcon from './icons/link.svg?raw';
|
|
42
|
+
|
|
43
|
+
import LabelIcon from './icons/label.svg?raw';
|
|
44
|
+
import CitationIcon from './icons/citation.svg?raw';
|
|
45
|
+
import DefineIcon from './icons/define.svg?raw';
|
|
46
|
+
import CodeIcon from './icons/code.svg?raw';
|
|
47
|
+
import CalloutIcon from './icons/callout.svg?raw';
|
|
48
|
+
import QuoteIcon from './icons/quote.svg?raw';
|
|
49
|
+
import MediaIcon from './icons/media.svg?raw';
|
|
50
|
+
import TableNode from '../../models/chapter/TableNode';
|
|
51
|
+
import { slide } from 'svelte/transition';
|
|
52
|
+
import type CaretState from './CaretState';
|
|
53
|
+
|
|
54
|
+
const keyLabels: { [key: string]: string } = {
|
|
55
|
+
Digit0: '0',
|
|
56
|
+
Digit1: '1',
|
|
57
|
+
Digit2: '2',
|
|
58
|
+
Digit3: '3',
|
|
59
|
+
ArrowDown: '↓',
|
|
60
|
+
ArrowUp: '↑',
|
|
61
|
+
ArrowLeft: '←',
|
|
62
|
+
ArrowRight: '→',
|
|
63
|
+
Backspace: '\u232B',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const categoryOrder: { [key: string]: number } = {
|
|
67
|
+
navigation: 1,
|
|
68
|
+
selection: 2,
|
|
69
|
+
text: 3,
|
|
70
|
+
clipboard: 4,
|
|
71
|
+
annotation: 5,
|
|
72
|
+
paragraph: 6,
|
|
73
|
+
level: 7,
|
|
74
|
+
list: 8,
|
|
75
|
+
table: 9,
|
|
76
|
+
block: 10,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const categoryIcons: { [key: string]: string } = {
|
|
80
|
+
text: TextIcon,
|
|
81
|
+
clipboard: ClipboardIcon,
|
|
82
|
+
annotation: AnnotateIcon,
|
|
83
|
+
level: LevelIcon,
|
|
84
|
+
block: BlockIcon,
|
|
85
|
+
list: ListIcon,
|
|
86
|
+
table: TableIcon,
|
|
87
|
+
history: TimeIcon,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export let caret: CaretState;
|
|
91
|
+
|
|
92
|
+
$: context = caret.context;
|
|
93
|
+
$: chapter = context?.root;
|
|
94
|
+
|
|
95
|
+
let element: HTMLElement | null = null;
|
|
96
|
+
let categories: string[] | undefined = undefined;
|
|
97
|
+
let commandsByCategory: { [key: string]: Command[] } = {};
|
|
98
|
+
let metaNode: MetadataNode<any> | AtomNode<any> | undefined = undefined;
|
|
99
|
+
let calloutNode: CalloutNode | undefined = undefined;
|
|
100
|
+
let quoteNode: QuoteNode | undefined = undefined;
|
|
101
|
+
let embedNode: EmbedNode | undefined = undefined;
|
|
102
|
+
let tableNode: TableNode | undefined = undefined;
|
|
103
|
+
|
|
104
|
+
function getShortcutDescription(command: Command) {
|
|
105
|
+
const macOS = navigator.userAgent.indexOf('Mac') >= 0;
|
|
106
|
+
const controlSymbol = macOS ? '\u2318' : 'Ctrl+';
|
|
107
|
+
const altSymbol = macOS ? '\u2325' : 'Alt+';
|
|
108
|
+
const key = command.key
|
|
109
|
+
? Array.isArray(command.key)
|
|
110
|
+
? command.key.join('/')
|
|
111
|
+
: command.key
|
|
112
|
+
: command.code
|
|
113
|
+
? command.code
|
|
114
|
+
: 'any';
|
|
115
|
+
const keyLabel = (
|
|
116
|
+
typeof key === 'string'
|
|
117
|
+
? key in keyLabels
|
|
118
|
+
? keyLabels[key]
|
|
119
|
+
: key
|
|
120
|
+
: '—'
|
|
121
|
+
).toLocaleUpperCase();
|
|
122
|
+
return `${command.control ? controlSymbol : ''}${
|
|
123
|
+
command.alt ? altSymbol : ''
|
|
124
|
+
}${command.shift ? '\u21E7' : ''}${keyLabel}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Update the above when the dependencies below change.
|
|
128
|
+
$: {
|
|
129
|
+
if (context !== undefined && chapter) {
|
|
130
|
+
// Filter the commands by those interactive with a mouse and active.
|
|
131
|
+
const visible = commands.filter(
|
|
132
|
+
(command) =>
|
|
133
|
+
command.visible === true ||
|
|
134
|
+
(context &&
|
|
135
|
+
command.visible instanceof Function &&
|
|
136
|
+
command.visible(context))
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// Extract the active categories and sort them
|
|
140
|
+
categories = Array.from(
|
|
141
|
+
new Set(commands.map((command) => command.category))
|
|
142
|
+
).sort((a, b) =>
|
|
143
|
+
a in categoryOrder && b in categoryOrder
|
|
144
|
+
? categoryOrder[a] - categoryOrder[b]
|
|
145
|
+
: 0
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// Make a list for each category of commands
|
|
149
|
+
commandsByCategory = {};
|
|
150
|
+
categories.forEach((cat) => {
|
|
151
|
+
if (commandsByCategory)
|
|
152
|
+
commandsByCategory[cat] = visible.filter(
|
|
153
|
+
(command) => command.category === cat
|
|
154
|
+
);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const caretNode = context.start.node;
|
|
158
|
+
|
|
159
|
+
metaNode =
|
|
160
|
+
caretNode instanceof AtomNode
|
|
161
|
+
? caretNode
|
|
162
|
+
: caretNode instanceof TextNode
|
|
163
|
+
? (caretNode.getParent(chapter) as MetadataNode<any>)
|
|
164
|
+
: undefined;
|
|
165
|
+
|
|
166
|
+
calloutNode = caretNode.getClosestParentMatching(
|
|
167
|
+
chapter,
|
|
168
|
+
(p) => p instanceof CalloutNode
|
|
169
|
+
) as CalloutNode;
|
|
170
|
+
quoteNode = caretNode.getClosestParentMatching(
|
|
171
|
+
chapter,
|
|
172
|
+
(p) => p instanceof QuoteNode
|
|
173
|
+
) as QuoteNode;
|
|
174
|
+
embedNode =
|
|
175
|
+
caretNode instanceof EmbedNode
|
|
176
|
+
? caretNode
|
|
177
|
+
: (caretNode.getClosestParentMatching(
|
|
178
|
+
chapter,
|
|
179
|
+
(p) => p instanceof EmbedNode
|
|
180
|
+
) as EmbedNode);
|
|
181
|
+
tableNode = caretNode.getClosestParentMatching(
|
|
182
|
+
chapter,
|
|
183
|
+
(p) => p instanceof TableNode
|
|
184
|
+
) as TableNode;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function handleKeyPress(event: KeyboardEvent) {
|
|
189
|
+
// Return focus to the editor if someone presses an unhandled enter
|
|
190
|
+
if ((event.key === 'Escape' || event.key === 'Enter') && element) {
|
|
191
|
+
const editor = element.closest('.bookish-editor');
|
|
192
|
+
if (editor instanceof HTMLElement) {
|
|
193
|
+
event.stopPropagation();
|
|
194
|
+
editor.focus();
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
</script>
|
|
200
|
+
|
|
201
|
+
{#if chapter}
|
|
202
|
+
<section
|
|
203
|
+
class="bookish-editor-toolbar"
|
|
204
|
+
bind:this={element}
|
|
205
|
+
on:keypress={handleKeyPress}
|
|
206
|
+
on:keydown={handleKeyPress}
|
|
207
|
+
on:mousedown|stopPropagation={() => element?.focus()}
|
|
208
|
+
tabIndex="0"
|
|
209
|
+
transition:slide={{ duration: 200 }}
|
|
210
|
+
>
|
|
211
|
+
{#if context && categories}
|
|
212
|
+
{#each categories as cat}
|
|
213
|
+
{#if commandsByCategory[cat].length > 0}
|
|
214
|
+
<ToolbarGroup
|
|
215
|
+
icon={cat in categoryIcons
|
|
216
|
+
? categoryIcons[cat]
|
|
217
|
+
: cat.charAt(0).toUpperCase() + cat.slice(1)}
|
|
218
|
+
>
|
|
219
|
+
{#each commandsByCategory[cat] as command}
|
|
220
|
+
<Button
|
|
221
|
+
disabled={command.active === false ||
|
|
222
|
+
(command.active instanceof Function &&
|
|
223
|
+
command.active.call(
|
|
224
|
+
undefined,
|
|
225
|
+
context
|
|
226
|
+
) === false)}
|
|
227
|
+
tooltip={command.description +
|
|
228
|
+
' ' +
|
|
229
|
+
getShortcutDescription(command)}
|
|
230
|
+
tabIndex="0"
|
|
231
|
+
command={() =>
|
|
232
|
+
caret?.executor.call(
|
|
233
|
+
undefined,
|
|
234
|
+
command,
|
|
235
|
+
''
|
|
236
|
+
)}
|
|
237
|
+
>
|
|
238
|
+
<Icon icon={command.icon} />
|
|
239
|
+
</Button>
|
|
240
|
+
{/each}
|
|
241
|
+
{#if cat === 'table' && tableNode}
|
|
242
|
+
<TableEditor table={tableNode} />
|
|
243
|
+
{/if}
|
|
244
|
+
</ToolbarGroup>
|
|
245
|
+
{/if}
|
|
246
|
+
{/each}
|
|
247
|
+
{/if}
|
|
248
|
+
{#if metaNode instanceof LinkNode}<ToolbarGroup icon={LinkIcon}
|
|
249
|
+
><LinkEditor link={metaNode} /></ToolbarGroup
|
|
250
|
+
>
|
|
251
|
+
{:else if metaNode instanceof LabelNode}<ToolbarGroup icon={LabelIcon}
|
|
252
|
+
><LabelEditor label={metaNode} /></ToolbarGroup
|
|
253
|
+
>
|
|
254
|
+
{:else if metaNode instanceof InlineCodeNode}<ToolbarGroup
|
|
255
|
+
icon={CodeIcon}
|
|
256
|
+
><InlineCodeEditor code={metaNode} /></ToolbarGroup
|
|
257
|
+
>
|
|
258
|
+
{:else if metaNode instanceof CitationsNode}<ToolbarGroup
|
|
259
|
+
icon={CitationIcon}
|
|
260
|
+
><CitationsEditor citations={metaNode} /></ToolbarGroup
|
|
261
|
+
>
|
|
262
|
+
{:else if metaNode instanceof DefinitionNode}<ToolbarGroup
|
|
263
|
+
icon={DefineIcon}
|
|
264
|
+
><DefinitionEditor definition={metaNode} /></ToolbarGroup
|
|
265
|
+
>
|
|
266
|
+
{:else if metaNode instanceof CodeNode && context}<ToolbarGroup
|
|
267
|
+
icon={CodeIcon}
|
|
268
|
+
><CaptionedCodeEditor code={metaNode} /></ToolbarGroup
|
|
269
|
+
>
|
|
270
|
+
{:else if calloutNode}<ToolbarGroup icon={CalloutIcon}
|
|
271
|
+
><CalloutEditor callout={calloutNode} /></ToolbarGroup
|
|
272
|
+
>
|
|
273
|
+
{:else if quoteNode}<ToolbarGroup icon={QuoteIcon}
|
|
274
|
+
><QuoteEditor quote={quoteNode} /></ToolbarGroup
|
|
275
|
+
>
|
|
276
|
+
{:else if embedNode}<ToolbarGroup icon={MediaIcon}
|
|
277
|
+
><EmbedEditor embed={embedNode} /></ToolbarGroup
|
|
278
|
+
>
|
|
279
|
+
{/if}
|
|
280
|
+
</section>
|
|
281
|
+
{/if}
|
|
282
|
+
|
|
283
|
+
<style>
|
|
284
|
+
.bookish-editor-toolbar {
|
|
285
|
+
display: flex;
|
|
286
|
+
flex-direction: row;
|
|
287
|
+
flex-wrap: wrap;
|
|
288
|
+
align-items: baseline;
|
|
289
|
+
background: var(--bookish-background-color);
|
|
290
|
+
font-family: var(--app-font);
|
|
291
|
+
font-size: var(--app-chrome-font-size);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.bookish-editor-toolbar:focus {
|
|
295
|
+
outline: 2px solid var(--app-interactive-color);
|
|
296
|
+
}
|
|
297
|
+
</style>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import ToolbarIcon from './Icon.svelte';
|
|
3
|
+
import ToolbarSpacer from './ToolbarSpacer.svelte';
|
|
4
|
+
|
|
5
|
+
export let icon: string;
|
|
4
6
|
</script>
|
|
5
7
|
|
|
6
8
|
<div class="toolbar-group">
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import TextEditor from './TextEditor.svelte';
|
|
3
|
+
|
|
4
|
+
export let url: string;
|
|
5
|
+
export let validator: (text: string) => undefined | string;
|
|
6
|
+
export let edit: (newURL: string) => string | undefined;
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<TextEditor
|
|
10
|
+
placeholder="url"
|
|
11
|
+
text={url}
|
|
12
|
+
label="URL editor"
|
|
13
|
+
valid={(url) => validator(url)}
|
|
14
|
+
save={(url) => edit(url)}
|
|
15
|
+
/>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { IndexRange } from '
|
|
2
|
-
import type Command from '
|
|
1
|
+
import type { IndexRange } from '$lib/models/chapter/Caret';
|
|
2
|
+
import type Command from '$lib/components/editor/Command';
|
|
3
|
+
|
|
3
4
|
type UndoState = {
|
|
4
5
|
command: Command | undefined;
|
|
5
6
|
bookdown: string;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|