bookish-press 0.4.0 → 0.4.16
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 +19 -14
- package/components/Auth.svelte.d.ts +4 -4
- package/components/Authentication.d.ts +2 -2
- package/components/BookPreview.svelte +77 -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 +45 -0
- package/components/app/Feedback.svelte.d.ts +18 -0
- package/components/app/Head.svelte +12 -0
- package/components/app/Head.svelte.d.ts +27 -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 +19 -0
- package/components/app/Paragraph.svelte.d.ts +18 -0
- package/components/app/Table.svelte +32 -0
- package/components/app/Table.svelte.d.ts +27 -0
- package/components/app/TextInput.svelte +37 -0
- package/components/app/TextInput.svelte.d.ts +22 -0
- package/components/app/Writing.svelte +13 -0
- package/components/app/Writing.svelte.d.ts +27 -0
- package/components/chapter/Atom.svelte +20 -6
- package/components/chapter/Atom.svelte.d.ts +3 -3
- package/components/chapter/Block.svelte +23 -20
- 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 +66 -23
- package/components/chapter/CaptionedCode.svelte.d.ts +4 -4
- package/components/chapter/ChapterBody.svelte +61 -9
- package/components/chapter/ChapterBody.svelte.d.ts +4 -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 +38 -16
- 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 +154 -66
- package/components/chapter/Embed.svelte.d.ts +5 -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 +60 -37
- package/components/chapter/Format.svelte.d.ts +4 -4
- package/components/chapter/InlineCode.svelte +15 -5
- package/components/chapter/InlineCode.svelte.d.ts +4 -4
- package/components/chapter/Label.svelte +37 -8
- package/components/chapter/Label.svelte.d.ts +4 -4
- package/components/chapter/Link.svelte +23 -18
- 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 +74 -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 +343 -237
- package/components/editor/BookishEditor.svelte.d.ts +5 -5
- 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 +80 -0
- package/components/editor/CaretView.svelte.d.ts +24 -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 +3 -3
- package/components/editor/Note.svelte.d.ts +6 -2
- 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 +192 -144
- package/components/editor/Toolbar.svelte.d.ts +5 -8
- package/components/editor/ToolbarGroup.svelte +18 -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 +31 -22
- package/components/page/Acknowledgements.svelte.d.ts +4 -4
- package/components/page/Authors.svelte +34 -14
- package/components/page/Authors.svelte.d.ts +6 -6
- package/components/page/BulkReferenceEditor.svelte +53 -22
- package/components/page/BulkReferenceEditor.svelte.d.ts +4 -4
- package/components/page/Chapter.svelte +196 -141
- 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 +31 -20
- package/components/page/Contexts.js +47 -17
- package/components/page/DefinitionView.svelte +115 -86
- package/components/page/DefinitionView.svelte.d.ts +3 -3
- package/components/page/Description.svelte +27 -18
- package/components/page/Description.svelte.d.ts +4 -4
- package/components/page/Edition.svelte +127 -74
- package/components/page/Edition.svelte.d.ts +4 -4
- package/components/page/Editions.svelte +144 -0
- package/components/page/Editions.svelte.d.ts +14 -0
- package/components/page/Glossary.svelte +57 -48
- package/components/page/Glossary.svelte.d.ts +4 -4
- package/components/page/Header.svelte +129 -44
- package/components/page/Header.svelte.d.ts +6 -6
- package/components/page/Index.svelte +114 -80
- package/components/page/Index.svelte.d.ts +4 -4
- package/components/page/Instructions.svelte +18 -16
- package/components/page/Instructions.svelte.d.ts +4 -4
- package/components/page/License.svelte +29 -21
- 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 +77 -51
- 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/Reference.svelte +256 -113
- package/components/page/Reference.svelte.d.ts +5 -5
- package/components/page/References.svelte +39 -47
- 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 +86 -63
- package/components/page/Search.svelte.d.ts +4 -4
- package/components/page/Status.svelte +43 -35
- package/components/page/Status.svelte.d.ts +4 -9
- package/components/page/SubdomainEditor.svelte +40 -27
- package/components/page/SubdomainEditor.svelte.d.ts +4 -4
- package/components/page/TableOfContents.svelte +225 -190
- 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 +96 -33
- package/components/page/TableOfContentsRow.svelte.d.ts +4 -4
- package/components/page/ThemeEditor.svelte +174 -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 +25 -21
- package/components/page/Unknown.svelte.d.ts +4 -4
- package/components/page/margins.js +50 -33
- package/index.d.ts +14 -0
- package/index.js +14 -0
- package/models/CRUD.d.ts +17 -0
- package/models/CRUD.js +194 -0
- package/models/Firebase.js +17 -15
- package/models/book/Book.d.ts +24 -28
- package/models/book/Book.js +120 -113
- 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 +46 -39
- package/models/book/Chapter.js +180 -198
- package/models/book/ChapterID.js +7 -7
- package/models/book/Definition.d.ts +1 -1
- package/models/book/Edition.d.ts +62 -60
- package/models/book/Edition.js +385 -303
- package/models/book/Reference.d.ts +24 -0
- package/models/book/Reference.js +78 -0
- package/models/book/Schema.d.ts +169 -0
- package/models/book/Schema.js +114 -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 +25 -25
- package/models/chapter/Parser.js +201 -189
- 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/models/loadEdition.d.ts +1 -1
- package/models/loadEdition.js +10 -6
- package/package.json +104 -25
- 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
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
<script>import URLEditor from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
<script>import URLEditor from './URLEditor.svelte';
|
|
2
|
+
import { getChapter, getEdition } from '../page/Contexts';
|
|
3
|
+
import Icon from './Icon.svelte';
|
|
4
|
+
import Button from '../app/Button.svelte';
|
|
5
|
+
import UnlinkIcon from './icons/unlink.svg?raw';
|
|
6
|
+
import Options from '../app/Options.svelte';
|
|
7
|
+
import { getCaret } from '../page/Contexts';
|
|
4
8
|
export let link;
|
|
5
9
|
let caret = getCaret();
|
|
6
10
|
let edition = getEdition();
|
|
@@ -9,67 +13,88 @@ $: url = link.getMeta();
|
|
|
9
13
|
function saveEdit(value) {
|
|
10
14
|
$caret?.edit(link, link.withMeta(value));
|
|
11
15
|
}
|
|
12
|
-
function handleChapterChange(e) {
|
|
13
|
-
const target = e.target;
|
|
14
|
-
saveEdit(target.value);
|
|
15
|
-
}
|
|
16
16
|
function isValidURL(url) {
|
|
17
17
|
// Is it a valid URL?
|
|
18
18
|
try {
|
|
19
19
|
let test = new URL(url);
|
|
20
|
-
if (test.protocol ===
|
|
20
|
+
if (test.protocol === 'http:' || test.protocol === 'https:')
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
catch (_) { }
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function validate(urlOrChapter) {
|
|
27
27
|
if (urlOrChapter.length === 0)
|
|
28
|
-
return "
|
|
28
|
+
return "link URL can't be empty";
|
|
29
|
+
if ($edition === undefined)
|
|
30
|
+
return;
|
|
29
31
|
if (isValidURL(urlOrChapter))
|
|
30
32
|
return;
|
|
31
33
|
// If not, is it a valid chapterID?
|
|
32
34
|
if ($edition.hasChapter(urlOrChapter))
|
|
33
35
|
return;
|
|
34
36
|
// If not, is it a valid chapterID:label?
|
|
35
|
-
const [chapterID, labelID] = urlOrChapter.split(
|
|
37
|
+
const [chapterID, labelID] = urlOrChapter.split(':');
|
|
36
38
|
if (chapterID === undefined || labelID === undefined)
|
|
37
39
|
return;
|
|
38
40
|
// The chapter ID is optional; if it's missing, it refers to this chapter.
|
|
39
|
-
const correspondingChapter = chapterID ===
|
|
41
|
+
const correspondingChapter = chapterID === '' && $chapter
|
|
42
|
+
? $chapter.chapter.getAST($edition)
|
|
43
|
+
: $edition?.getChapter(chapterID)?.getAST($edition);
|
|
40
44
|
if (correspondingChapter === undefined)
|
|
41
|
-
return
|
|
45
|
+
return 'Not a valid URL or chapter.';
|
|
42
46
|
if (!correspondingChapter.hasLabel(labelID))
|
|
43
|
-
return
|
|
47
|
+
return 'Not a valid chapter label.';
|
|
48
|
+
}
|
|
49
|
+
let options = [];
|
|
50
|
+
$: {
|
|
51
|
+
options = [];
|
|
52
|
+
// Add an empty option.
|
|
53
|
+
options.push(['External link', url.startsWith('http') ? url : '']);
|
|
54
|
+
// Add an option for each chapter and it's labels.
|
|
55
|
+
if ($edition) {
|
|
56
|
+
for (const chap of $edition?.getChapters() ?? []) {
|
|
57
|
+
options.push([`Chapter: ${chap.getTitle()}`, chap.getID()]);
|
|
58
|
+
for (const label of chap.getAST($edition)?.getLabels() ?? [])
|
|
59
|
+
options.push([
|
|
60
|
+
chap.getTitle() + ': ' + label.getMeta(),
|
|
61
|
+
`${chap.getID()}:${label.getMeta()}`,
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
44
65
|
}
|
|
45
66
|
</script>
|
|
46
67
|
|
|
47
68
|
<span>
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if($caret?.context?.format) {
|
|
52
|
-
const newFormat = $caret.context.format.withSegmentReplaced(
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
<Button
|
|
70
|
+
tooltip="remove link"
|
|
71
|
+
command={() => {
|
|
72
|
+
if ($caret?.context?.format) {
|
|
73
|
+
const newFormat = $caret.context.format.withSegmentReplaced(
|
|
74
|
+
link,
|
|
75
|
+
link.getText()
|
|
76
|
+
);
|
|
77
|
+
if (newFormat) $caret.edit($caret.context.format, newFormat);
|
|
55
78
|
}
|
|
56
79
|
}}
|
|
57
80
|
>
|
|
58
|
-
<
|
|
59
|
-
</
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
<Icon icon={UnlinkIcon} />
|
|
82
|
+
</Button>
|
|
83
|
+
<Options
|
|
84
|
+
{options}
|
|
85
|
+
changed={(value) => {
|
|
86
|
+
saveEdit(value);
|
|
87
|
+
url = value;
|
|
88
|
+
}}
|
|
89
|
+
value={url}
|
|
90
|
+
label="link type"
|
|
91
|
+
/>
|
|
92
|
+
<URLEditor
|
|
93
|
+
{url}
|
|
94
|
+
validator={validate}
|
|
95
|
+
edit={(url) => {
|
|
96
|
+
saveEdit(url);
|
|
97
|
+
return undefined;
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
</span>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type LinkNode from
|
|
2
|
+
import type LinkNode from '../../models/chapter/LinkNode';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
link: LinkNode;
|
|
@@ -9,9 +9,9 @@ declare const __propDef: {
|
|
|
9
9
|
};
|
|
10
10
|
slots: {};
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export type LinkEditorProps = typeof __propDef.props;
|
|
13
|
+
export type LinkEditorEvents = typeof __propDef.events;
|
|
14
|
+
export type LinkEditorSlots = typeof __propDef.slots;
|
|
15
15
|
export default class LinkEditor extends SvelteComponentTyped<LinkEditorProps, LinkEditorEvents, LinkEditorSlots> {
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** @typedef {typeof __propDef.props} NoteProps */
|
|
2
2
|
/** @typedef {typeof __propDef.events} NoteEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} NoteSlots */
|
|
4
|
-
export default class Note extends SvelteComponentTyped<{
|
|
4
|
+
export default class Note extends SvelteComponentTyped<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
5
7
|
[evt: string]: CustomEvent<any>;
|
|
6
8
|
}, {
|
|
7
9
|
default: {};
|
|
@@ -12,7 +14,9 @@ export type NoteEvents = typeof __propDef.events;
|
|
|
12
14
|
export type NoteSlots = typeof __propDef.slots;
|
|
13
15
|
import { SvelteComponentTyped } from "svelte";
|
|
14
16
|
declare const __propDef: {
|
|
15
|
-
props: {
|
|
17
|
+
props: {
|
|
18
|
+
[x: string]: never;
|
|
19
|
+
};
|
|
16
20
|
events: {
|
|
17
21
|
[evt: string]: CustomEvent<any>;
|
|
18
22
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
<script>import Switch from
|
|
1
|
+
<script>import Switch from './Switch.svelte';
|
|
2
|
+
import LeftIcon from './icons/left.svg?raw';
|
|
3
|
+
import MiddleIcon from './icons/middle.svg?raw';
|
|
4
|
+
import RightIcon from './icons/right.svg?raw';
|
|
2
5
|
export let value;
|
|
3
6
|
export let edit;
|
|
4
7
|
function editAsString(newValue) {
|
|
@@ -7,8 +10,8 @@ function editAsString(newValue) {
|
|
|
7
10
|
</script>
|
|
8
11
|
|
|
9
12
|
<Switch
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
edit={editAsString}
|
|
14
|
-
/>
|
|
13
|
+
options={['<', '|', '>']}
|
|
14
|
+
icons={{ '<': LeftIcon, '|': MiddleIcon, '>': RightIcon }}
|
|
15
|
+
{value}
|
|
16
|
+
edit={editAsString}
|
|
17
|
+
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type Position from
|
|
2
|
+
import type Position from '../../models/chapter/Position';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
value: string;
|
|
@@ -10,9 +10,9 @@ declare const __propDef: {
|
|
|
10
10
|
};
|
|
11
11
|
slots: {};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
13
|
+
export type PositionEditorProps = typeof __propDef.props;
|
|
14
|
+
export type PositionEditorEvents = typeof __propDef.events;
|
|
15
|
+
export type PositionEditorSlots = typeof __propDef.slots;
|
|
16
16
|
export default class PositionEditor extends SvelteComponentTyped<PositionEditorProps, PositionEditorEvents, PositionEditorSlots> {
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
<script>import
|
|
1
|
+
<script>import { getCaret } from '../page/Contexts';
|
|
2
|
+
import PositionEditor from './PositionEditor.svelte';
|
|
2
3
|
export let quote;
|
|
4
|
+
let caret = getCaret();
|
|
3
5
|
</script>
|
|
4
6
|
|
|
5
|
-
<PositionEditor
|
|
7
|
+
<PositionEditor
|
|
8
|
+
value={quote.getPosition()}
|
|
9
|
+
edit={(position) => $caret?.edit(quote, quote.withPosition(position))}
|
|
10
|
+
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type QuoteNode from
|
|
2
|
+
import type QuoteNode from '../../models/chapter/QuoteNode';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
quote: QuoteNode;
|
|
@@ -9,9 +9,9 @@ declare const __propDef: {
|
|
|
9
9
|
};
|
|
10
10
|
slots: {};
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export type QuoteEditorProps = typeof __propDef.props;
|
|
13
|
+
export type QuoteEditorEvents = typeof __propDef.events;
|
|
14
|
+
export type QuoteEditorSlots = typeof __propDef.slots;
|
|
15
15
|
export default class QuoteEditor extends SvelteComponentTyped<QuoteEditorProps, QuoteEditorEvents, QuoteEditorSlots> {
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script>import Icon from './Icon.svelte';
|
|
2
|
+
export let options;
|
|
3
|
+
export let icons = undefined;
|
|
2
4
|
export let value;
|
|
3
|
-
export let position;
|
|
4
5
|
export let enabled = undefined;
|
|
5
6
|
export let edit;
|
|
6
7
|
function handleClick(event) {
|
|
@@ -11,46 +12,72 @@ function handleClick(event) {
|
|
|
11
12
|
}
|
|
12
13
|
</script>
|
|
13
14
|
|
|
14
|
-
<span class=
|
|
15
|
-
{#each options as option
|
|
16
|
-
<button
|
|
17
|
-
class={`
|
|
18
|
-
data-value={option}
|
|
15
|
+
<span class="switch">
|
|
16
|
+
{#each options as option}
|
|
17
|
+
<button
|
|
18
|
+
class={`option ${value === option ? 'selected' : ''}`}
|
|
19
|
+
data-value={option}
|
|
19
20
|
disabled={enabled === false}
|
|
20
|
-
on:click|stopPropagation={handleClick}
|
|
21
|
+
on:click|stopPropagation={handleClick}
|
|
22
|
+
>
|
|
23
|
+
{#if icons && option in icons}
|
|
24
|
+
<Icon icon={icons[option]} />
|
|
25
|
+
{:else}
|
|
21
26
|
{option}
|
|
27
|
+
{/if}
|
|
22
28
|
</button>
|
|
23
29
|
{/each}
|
|
24
30
|
</span>
|
|
25
31
|
|
|
26
32
|
<style>
|
|
27
|
-
|
|
28
|
-
font-family: var(--
|
|
29
|
-
font-size: var(--
|
|
33
|
+
button {
|
|
34
|
+
font-family: var(--app-font);
|
|
35
|
+
font-size: var(--app-chrome-font-size);
|
|
36
|
+
color: var(--app-font-color);
|
|
37
|
+
background-color: var(--app-chrome-background);
|
|
38
|
+
padding: var(--app-chrome-padding);
|
|
39
|
+
border: none;
|
|
40
|
+
border-radius: 0;
|
|
30
41
|
}
|
|
31
42
|
|
|
32
|
-
.
|
|
33
|
-
display: inline-block;
|
|
34
|
-
background-color: var(--bookish-app-chrome-background);
|
|
43
|
+
button:hover:enabled:not(.selected) {
|
|
35
44
|
cursor: pointer;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
background-color: var(--app-interactive-color);
|
|
46
|
+
color: var(--app-font-color-inverted);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
button.selected {
|
|
50
|
+
background-color: var(--app-border-color);
|
|
51
|
+
color: var(--app-font-color-inverted);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
button:disabled {
|
|
55
|
+
opacity: 0.3;
|
|
56
|
+
cursor: auto;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.switch {
|
|
60
|
+
font-family: var(--app-font);
|
|
61
|
+
font-size: var(--app-chrome-font-size);
|
|
62
|
+
white-space: nowrap;
|
|
39
63
|
}
|
|
40
64
|
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
.option {
|
|
66
|
+
display: inline-block;
|
|
67
|
+
background-color: var(--app-chrome-background);
|
|
68
|
+
padding-left: var(--app-chrome-padding);
|
|
69
|
+
padding-right: var(--app-chrome-padding);
|
|
45
70
|
}
|
|
46
71
|
|
|
47
|
-
.
|
|
48
|
-
border-top-
|
|
49
|
-
border-bottom-
|
|
50
|
-
margin-
|
|
72
|
+
.option:first-child {
|
|
73
|
+
border-top-left-radius: var(--app-chrome-roundedness);
|
|
74
|
+
border-bottom-left-radius: var(--app-chrome-roundedness);
|
|
75
|
+
margin-left: var(--app-chrome-padding);
|
|
51
76
|
}
|
|
52
77
|
|
|
53
|
-
.
|
|
54
|
-
|
|
78
|
+
.option:last-child {
|
|
79
|
+
border-top-right-radius: var(--app-chrome-roundedness);
|
|
80
|
+
border-bottom-right-radius: var(--app-chrome-roundedness);
|
|
81
|
+
margin-right: var(--app-chrome-padding);
|
|
55
82
|
}
|
|
56
|
-
</style>
|
|
83
|
+
</style>
|
|
@@ -2,8 +2,8 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
options: string[];
|
|
5
|
+
icons?: Record<string, string> | undefined;
|
|
5
6
|
value: string;
|
|
6
|
-
position: string;
|
|
7
7
|
enabled?: boolean | undefined;
|
|
8
8
|
edit: (newValue: string) => void;
|
|
9
9
|
};
|
|
@@ -12,9 +12,9 @@ declare const __propDef: {
|
|
|
12
12
|
};
|
|
13
13
|
slots: {};
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
15
|
+
export type SwitchProps = typeof __propDef.props;
|
|
16
|
+
export type SwitchEvents = typeof __propDef.events;
|
|
17
|
+
export type SwitchSlots = typeof __propDef.slots;
|
|
18
18
|
export default class Switch extends SvelteComponentTyped<SwitchProps, SwitchEvents, SwitchSlots> {
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script>import { getCaret } from '../page/Contexts';
|
|
2
|
+
import PositionEditor from './PositionEditor.svelte';
|
|
3
|
+
export let table;
|
|
4
|
+
let caret = getCaret();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<PositionEditor
|
|
8
|
+
value={table.getPosition()}
|
|
9
|
+
edit={(position) => $caret?.edit(table, table.withPosition(position))}
|
|
10
|
+
/>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type TableNode from '../../models/chapter/TableNode';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
table: TableNode;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type TableEditorProps = typeof __propDef.props;
|
|
13
|
+
export type TableEditorEvents = typeof __propDef.events;
|
|
14
|
+
export type TableEditorSlots = typeof __propDef.slots;
|
|
15
|
+
export default class TableEditor extends SvelteComponentTyped<TableEditorProps, TableEditorEvents, TableEditorSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|