bookish-press 0.7.4 → 0.9.2
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 +56 -9
- package/dist/components/Auth.svelte +29 -39
- package/dist/components/Auth.svelte.d.ts +5 -17
- package/dist/components/BookPreview.svelte +14 -20
- package/dist/components/BookPreview.svelte.d.ts +6 -18
- package/dist/components/Link.svelte +19 -30
- package/dist/components/Link.svelte.d.ts +7 -20
- package/dist/components/app/BookList.svelte +2 -3
- package/dist/components/app/BookList.svelte.d.ts +6 -18
- package/dist/components/app/Button.svelte +12 -8
- package/dist/components/app/Button.svelte.d.ts +10 -23
- package/dist/components/app/Feedback.svelte +4 -4
- package/dist/components/app/Feedback.svelte.d.ts +6 -19
- package/dist/components/app/Head.svelte +2 -2
- package/dist/components/app/Head.svelte.d.ts +6 -19
- package/dist/components/app/Large.svelte +4 -1
- package/dist/components/app/Large.svelte.d.ts +5 -28
- package/dist/components/app/Lead.svelte +4 -1
- package/dist/components/app/Lead.svelte.d.ts +5 -28
- package/dist/components/app/Link.svelte +12 -9
- package/dist/components/app/Link.svelte.d.ts +9 -22
- package/dist/components/app/Options.svelte +8 -6
- package/dist/components/app/Options.svelte.d.ts +8 -20
- package/dist/components/app/Paragraph.svelte +2 -2
- package/dist/components/app/Paragraph.svelte.d.ts +6 -19
- package/dist/components/app/Section.svelte +4 -1
- package/dist/components/app/Section.svelte.d.ts +5 -28
- package/dist/components/app/Table.svelte +4 -1
- package/dist/components/app/Table.svelte.d.ts +5 -28
- package/dist/components/app/TextInput.svelte +10 -8
- package/dist/components/app/TextInput.svelte.d.ts +12 -23
- package/dist/components/chapter/Atom.svelte +4 -7
- package/dist/components/chapter/Atom.svelte.d.ts +6 -19
- package/dist/components/chapter/Block.svelte +21 -23
- package/dist/components/chapter/Block.svelte.d.ts +5 -17
- package/dist/components/chapter/Callout.svelte +3 -5
- package/dist/components/chapter/Callout.svelte.d.ts +5 -17
- package/dist/components/chapter/CaptionedCode.svelte +12 -14
- package/dist/components/chapter/CaptionedCode.svelte.d.ts +5 -17
- package/dist/components/chapter/ChapterBody.svelte +14 -17
- package/dist/components/chapter/ChapterBody.svelte.d.ts +7 -19
- package/dist/components/chapter/ChapterBody.test.d.ts +1 -0
- package/dist/components/chapter/ChapterBody.test.js +85 -0
- package/dist/components/chapter/Citations.svelte +39 -45
- package/dist/components/chapter/Citations.svelte.d.ts +5 -17
- package/dist/components/chapter/Code.svelte +158 -155
- package/dist/components/chapter/Code.svelte.d.ts +10 -23
- package/dist/components/chapter/Comment.svelte +30 -23
- package/dist/components/chapter/Comment.svelte.d.ts +5 -17
- package/dist/components/chapter/Definition.svelte +36 -34
- package/dist/components/chapter/Definition.svelte.d.ts +5 -17
- package/dist/components/chapter/Embed.svelte +78 -72
- package/dist/components/chapter/Embed.svelte.d.ts +8 -20
- package/dist/components/chapter/ErrorMessage.svelte +2 -4
- package/dist/components/chapter/ErrorMessage.svelte.d.ts +5 -17
- package/dist/components/chapter/Figure.svelte +22 -29
- package/dist/components/chapter/Figure.svelte.d.ts +9 -22
- package/dist/components/chapter/Footnote.svelte +40 -32
- package/dist/components/chapter/Footnote.svelte.d.ts +5 -17
- package/dist/components/chapter/Format.svelte +26 -41
- package/dist/components/chapter/Format.svelte.d.ts +7 -18
- package/dist/components/chapter/InlineCode.svelte +7 -8
- package/dist/components/chapter/InlineCode.svelte.d.ts +5 -17
- package/dist/components/chapter/Label.svelte +5 -11
- package/dist/components/chapter/Label.svelte.d.ts +5 -17
- package/dist/components/chapter/LineBreak.svelte +1 -3
- package/dist/components/chapter/LineBreak.svelte.d.ts +5 -17
- package/dist/components/chapter/Link.svelte +17 -23
- package/dist/components/chapter/Link.svelte.d.ts +5 -17
- package/dist/components/chapter/List.svelte +9 -9
- package/dist/components/chapter/List.svelte.d.ts +6 -17
- package/dist/components/chapter/Marginal.svelte +59 -60
- package/dist/components/chapter/Marginal.svelte.d.ts +10 -22
- package/dist/components/chapter/Paragraph.svelte +8 -23
- package/dist/components/chapter/Paragraph.svelte.d.ts +6 -18
- package/dist/components/chapter/Positioned.svelte +2 -4
- package/dist/components/chapter/Positioned.svelte.d.ts +6 -19
- package/dist/components/chapter/Problem.svelte +3 -2
- package/dist/components/chapter/Problem.svelte.d.ts +5 -28
- package/dist/components/chapter/Python.svelte +45 -58
- package/dist/components/chapter/Python.svelte.d.ts +6 -18
- package/dist/components/chapter/Quote.svelte +5 -7
- package/dist/components/chapter/Quote.svelte.d.ts +5 -17
- package/dist/components/chapter/Rule.svelte +1 -3
- package/dist/components/chapter/Rule.svelte.d.ts +5 -17
- package/dist/components/chapter/Table.svelte +6 -8
- package/dist/components/chapter/Table.svelte.d.ts +5 -17
- package/dist/components/chapter/Text.svelte +54 -69
- package/dist/components/chapter/Text.svelte.d.ts +6 -18
- package/dist/components/controls/DarkToggle.svelte +7 -8
- package/dist/components/controls/DarkToggle.svelte.d.ts +6 -18
- package/dist/components/editor/BookishEditor.svelte +583 -761
- package/dist/components/editor/BookishEditor.svelte.d.ts +14 -26
- package/dist/components/editor/CalloutEditor.svelte +3 -3
- package/dist/components/editor/CalloutEditor.svelte.d.ts +5 -17
- package/dist/components/editor/CaptionedCodeEditor.svelte +5 -5
- package/dist/components/editor/CaptionedCodeEditor.svelte.d.ts +5 -17
- package/dist/components/editor/CaretView.svelte +23 -25
- package/dist/components/editor/CaretView.svelte.d.ts +15 -27
- package/dist/components/editor/CitationsEditor.svelte +25 -28
- package/dist/components/editor/CitationsEditor.svelte.d.ts +5 -17
- package/dist/components/editor/ConfirmButton.svelte +9 -6
- package/dist/components/editor/ConfirmButton.svelte.d.ts +8 -21
- package/dist/components/editor/DefinitionEditor.svelte +11 -15
- package/dist/components/editor/DefinitionEditor.svelte.d.ts +5 -17
- package/dist/components/editor/EmbedEditor.svelte +44 -45
- package/dist/components/editor/EmbedEditor.svelte.d.ts +5 -17
- package/dist/components/editor/Icon.svelte +1 -1
- package/dist/components/editor/Icon.svelte.d.ts +5 -17
- package/dist/components/editor/ImageChooser.svelte +15 -18
- package/dist/components/editor/ImageChooser.svelte.d.ts +6 -18
- package/dist/components/editor/ImageThumbnail.svelte +29 -24
- package/dist/components/editor/ImageThumbnail.svelte.d.ts +7 -19
- package/dist/components/editor/InlineCodeEditor.svelte +3 -3
- package/dist/components/editor/InlineCodeEditor.svelte.d.ts +5 -17
- package/dist/components/editor/LabelEditor.svelte +5 -6
- package/dist/components/editor/LabelEditor.svelte.d.ts +5 -17
- package/dist/components/editor/LanguageEditor.svelte +4 -5
- package/dist/components/editor/LanguageEditor.svelte.d.ts +6 -18
- package/dist/components/editor/LinkEditor.svelte +52 -68
- package/dist/components/editor/LinkEditor.svelte.d.ts +5 -17
- package/dist/components/editor/Note.svelte +4 -1
- package/dist/components/editor/Note.svelte.d.ts +5 -28
- package/dist/components/editor/Permissions.svelte +36 -34
- package/dist/components/editor/Permissions.svelte.d.ts +9 -21
- package/dist/components/editor/PositionEditor.svelte +6 -7
- package/dist/components/editor/PositionEditor.svelte.d.ts +6 -18
- package/dist/components/editor/QuoteEditor.svelte +3 -3
- package/dist/components/editor/QuoteEditor.svelte.d.ts +5 -17
- package/dist/components/editor/Switch.svelte +16 -11
- package/dist/components/editor/Switch.svelte.d.ts +9 -21
- package/dist/components/editor/TableEditor.svelte +3 -3
- package/dist/components/editor/TableEditor.svelte.d.ts +5 -17
- package/dist/components/editor/TextEditor.svelte +74 -87
- package/dist/components/editor/TextEditor.svelte.d.ts +13 -25
- package/dist/components/editor/Toggle.svelte +18 -21
- package/dist/components/editor/Toggle.svelte.d.ts +7 -20
- package/dist/components/editor/Toolbar.svelte +140 -145
- package/dist/components/editor/Toolbar.svelte.d.ts +5 -17
- package/dist/components/editor/ToolbarGroup.svelte +4 -4
- package/dist/components/editor/ToolbarGroup.svelte.d.ts +6 -19
- package/dist/components/editor/ToolbarSpacer.svelte +1 -1
- package/dist/components/editor/ToolbarSpacer.svelte.d.ts +22 -21
- package/dist/components/editor/URLEditor.svelte +3 -5
- package/dist/components/editor/URLEditor.svelte.d.ts +7 -19
- package/dist/components/page/Acknowledgements.svelte +14 -8
- package/dist/components/page/Acknowledgements.svelte.d.ts +3 -16
- package/dist/components/page/Analytics.svelte +2 -3
- package/dist/components/page/Analytics.svelte.d.ts +6 -17
- package/dist/components/page/Authors.svelte +29 -29
- package/dist/components/page/Authors.svelte.d.ts +11 -23
- package/dist/components/page/BookLoader.svelte +47 -43
- package/dist/components/page/BookLoader.svelte.d.ts +5 -17
- package/dist/components/page/BulkReferenceEditor.svelte +43 -26
- package/dist/components/page/BulkReferenceEditor.svelte.d.ts +3 -16
- package/dist/components/page/Chapter.svelte +224 -249
- package/dist/components/page/Chapter.svelte.d.ts +6 -18
- package/dist/components/page/ChapterContext.d.ts +3 -1
- package/dist/components/page/ChapterNumber.svelte +4 -1
- package/dist/components/page/ChapterNumber.svelte.d.ts +5 -28
- package/dist/components/page/ChapterTitle.svelte +4 -4
- package/dist/components/page/ChapterTitle.svelte.d.ts +6 -19
- package/dist/components/page/Contexts.js +2 -2
- package/dist/components/page/DefinitionView.svelte +51 -44
- package/dist/components/page/DefinitionView.svelte.d.ts +6 -18
- package/dist/components/page/Description.svelte +10 -4
- package/dist/components/page/Description.svelte.d.ts +16 -14
- package/dist/components/page/DownloadEPUB.svelte +234 -0
- package/dist/components/page/DownloadEPUB.svelte.d.ts +3 -0
- package/dist/components/page/EditableHeader.svelte +4 -6
- package/dist/components/page/EditableHeader.svelte.d.ts +7 -18
- package/dist/components/page/Edition.svelte +57 -71
- package/dist/components/page/Edition.svelte.d.ts +7 -20
- package/dist/components/page/EditionLoader.svelte +119 -82
- package/dist/components/page/EditionLoader.svelte.d.ts +6 -19
- package/dist/components/page/Editions.svelte +26 -31
- package/dist/components/page/Editions.svelte.d.ts +5 -17
- package/dist/components/page/Glossary.svelte +31 -35
- package/dist/components/page/Glossary.svelte.d.ts +3 -16
- package/dist/components/page/Header.svelte +43 -49
- package/dist/components/page/Header.svelte.d.ts +19 -30
- package/dist/components/page/Index.svelte +46 -46
- package/dist/components/page/Index.svelte.d.ts +3 -16
- package/dist/components/page/Instructions.svelte +2 -2
- package/dist/components/page/Instructions.svelte.d.ts +6 -19
- package/dist/components/page/License.svelte +13 -7
- package/dist/components/page/License.svelte.d.ts +16 -14
- package/dist/components/page/Loading.svelte +9 -9
- package/dist/components/page/Loading.svelte.d.ts +22 -21
- package/dist/components/page/Media.svelte +36 -27
- package/dist/components/page/Media.svelte.d.ts +3 -16
- package/dist/components/page/MediaPreview.svelte +22 -19
- package/dist/components/page/MediaPreview.svelte.d.ts +8 -21
- package/dist/components/page/Muted.svelte +4 -1
- package/dist/components/page/Muted.svelte.d.ts +5 -28
- package/dist/components/page/Outline.svelte +75 -97
- package/dist/components/page/Outline.svelte.d.ts +8 -20
- package/dist/components/page/Page.svelte +23 -33
- package/dist/components/page/Page.svelte.d.ts +7 -20
- package/dist/components/page/PageHeader.svelte +2 -2
- package/dist/components/page/PageHeader.svelte.d.ts +6 -19
- package/dist/components/page/PageParagraph.svelte +4 -1
- package/dist/components/page/PageParagraph.svelte.d.ts +5 -28
- package/dist/components/page/PossibleChapter.svelte +7 -7
- package/dist/components/page/PossibleChapter.svelte.d.ts +3 -16
- package/dist/components/page/PossibleReference.svelte +4 -5
- package/dist/components/page/PossibleReference.svelte.d.ts +6 -18
- package/dist/components/page/Print.svelte +11 -12
- package/dist/components/page/Print.svelte.d.ts +3 -16
- package/dist/components/page/Publish.svelte +47 -47
- package/dist/components/page/Publish.svelte.d.ts +3 -16
- package/dist/components/page/Reference.svelte +24 -35
- package/dist/components/page/Reference.svelte.d.ts +6 -18
- package/dist/components/page/References.svelte +21 -22
- package/dist/components/page/References.svelte.d.ts +3 -16
- package/dist/components/page/Rows.svelte +5 -2
- package/dist/components/page/Rows.svelte.d.ts +5 -28
- package/dist/components/page/Search.svelte +59 -61
- package/dist/components/page/Search.svelte.d.ts +3 -16
- package/dist/components/page/Status.svelte +2 -2
- package/dist/components/page/Status.svelte.d.ts +16 -14
- package/dist/components/page/SubdomainEditor.svelte +11 -11
- package/dist/components/page/SubdomainEditor.svelte.d.ts +16 -14
- package/dist/components/page/TableOfContents.svelte +157 -124
- package/dist/components/page/TableOfContents.svelte.d.ts +3 -16
- package/dist/components/page/TableOfContentsImage.svelte +6 -7
- package/dist/components/page/TableOfContentsImage.svelte.d.ts +6 -18
- package/dist/components/page/TableOfContentsRow.svelte +32 -32
- package/dist/components/page/TableOfContentsRow.svelte.d.ts +10 -22
- package/dist/components/page/ThemeEditor.svelte +35 -28
- package/dist/components/page/ThemeEditor.svelte.d.ts +3 -16
- package/dist/components/page/ThemeEditorPreview.svelte +11 -13
- package/dist/components/page/ThemeEditorPreview.svelte.d.ts +5 -17
- package/dist/components/page/ThemeSetEditor.svelte +4 -6
- package/dist/components/page/ThemeSetEditor.svelte.d.ts +7 -19
- package/dist/components/page/ThemeVariableEditor.svelte +9 -11
- package/dist/components/page/ThemeVariableEditor.svelte.d.ts +7 -19
- package/dist/components/page/Title.svelte +4 -1
- package/dist/components/page/Title.svelte.d.ts +5 -28
- package/dist/components/page/Unknown.svelte +11 -8
- package/dist/components/page/Unknown.svelte.d.ts +5 -17
- package/dist/epub/build.d.ts +39 -0
- package/dist/epub/build.js +143 -0
- package/dist/epub/build.test.d.ts +1 -0
- package/dist/epub/build.test.js +411 -0
- package/dist/epub/images.d.ts +79 -0
- package/dist/epub/images.js +260 -0
- package/dist/epub/images.test.d.ts +1 -0
- package/dist/epub/images.test.js +129 -0
- package/dist/epub/package.d.ts +75 -0
- package/dist/epub/package.js +392 -0
- package/dist/epub/stylesheet.test.d.ts +1 -0
- package/dist/epub/stylesheet.test.js +243 -0
- package/dist/epub/xhtml.d.ts +69 -0
- package/dist/epub/xhtml.js +367 -0
- package/dist/epub/xhtml.test.d.ts +1 -0
- package/dist/epub/xhtml.test.js +283 -0
- package/dist/epub/zip.d.ts +35 -0
- package/dist/epub/zip.js +202 -0
- package/dist/epub/zip.test.d.ts +1 -0
- package/dist/epub/zip.test.js +171 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/Firebase.js +18 -4
- package/dist/models/book/Book.js +2 -1
- package/dist/models/book/BookMedia.js +1 -2
- package/dist/models/book/Chapter.js +3 -2
- package/dist/models/book/ChapterID.d.ts +1 -1
- package/dist/models/book/Edition.d.ts +1 -1
- package/dist/models/book/Edition.js +6 -1
- package/dist/models/chapter/BlocksNode.js +3 -1
- package/dist/models/chapter/BlocksNode.test.js +5 -1
- package/dist/models/chapter/Node.test.js +2 -2
- package/dist/models/chapter/TextNode.js +8 -5
- package/dist/models/chapter/TextNode.test.js +8 -0
- package/package.json +36 -22
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
link?: string | undefined;
|
|
5
|
-
};
|
|
6
|
-
events: {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {
|
|
10
|
-
default: {};
|
|
11
|
-
};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type ChapterTitleProps = typeof __propDef.props;
|
|
16
|
-
export type ChapterTitleEvents = typeof __propDef.events;
|
|
17
|
-
export type ChapterTitleSlots = typeof __propDef.slots;
|
|
18
|
-
export default class ChapterTitle extends SvelteComponent<ChapterTitleProps, ChapterTitleEvents, ChapterTitleSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
link?: string | undefined;
|
|
3
|
+
children?: import('svelte').Snippet;
|
|
19
4
|
}
|
|
20
|
-
|
|
5
|
+
declare const ChapterTitle: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type ChapterTitle = ReturnType<typeof ChapterTitle>;
|
|
7
|
+
export default ChapterTitle;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// as the resulting value is coerced to Type even if it's not that value.
|
|
5
5
|
import { getContext } from 'svelte';
|
|
6
6
|
import { get } from 'svelte/store';
|
|
7
|
-
import { page } from '$app/
|
|
7
|
+
import { page } from '$app/state';
|
|
8
8
|
import { updateLock } from '../../models/CRUD';
|
|
9
9
|
export const DARK_MODE = Symbol('dark');
|
|
10
10
|
export function getDarkMode() {
|
|
@@ -47,7 +47,7 @@ export function setChapter(store, previous, revised) {
|
|
|
47
47
|
store.set(edition.withRevisedChapter(previous, revised));
|
|
48
48
|
}
|
|
49
49
|
function isRouteWrite() {
|
|
50
|
-
return
|
|
50
|
+
return page.route.id?.startsWith('/(app)/write') ?? false;
|
|
51
51
|
}
|
|
52
52
|
export function isChapterEditable() {
|
|
53
53
|
if (!isRouteWrite())
|
|
@@ -1,59 +1,66 @@
|
|
|
1
|
-
<script>import Parser from
|
|
2
|
-
import ConfirmButton from
|
|
3
|
-
import TextEditor from
|
|
4
|
-
import BookishEditor from
|
|
5
|
-
import Format from
|
|
6
|
-
import Note from
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
<script lang="ts">import Parser from "../../models/chapter/Parser";
|
|
2
|
+
import ConfirmButton from "../editor/ConfirmButton.svelte";
|
|
3
|
+
import TextEditor from "../editor/TextEditor.svelte";
|
|
4
|
+
import BookishEditor from "../editor/BookishEditor.svelte";
|
|
5
|
+
import Format from "../chapter/Format.svelte";
|
|
6
|
+
import Note from "../editor/Note.svelte";
|
|
7
|
+
import {
|
|
8
|
+
getUser,
|
|
9
|
+
getEdition,
|
|
10
|
+
getLeasee,
|
|
11
|
+
isChapterEditable,
|
|
12
|
+
lease,
|
|
13
|
+
isEditionEditable
|
|
14
|
+
} from "./Contexts";
|
|
15
|
+
import Button from "../app/Button.svelte";
|
|
16
|
+
let { id, definition } = $props();
|
|
12
17
|
let auth = getUser();
|
|
13
18
|
let edition = getEdition();
|
|
14
19
|
let editable = isEditionEditable();
|
|
15
|
-
// Focus after adding a new synonym.
|
|
16
20
|
let newSynonym = false;
|
|
17
|
-
let synonymsEditor = null;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
newSynonym = false;
|
|
21
|
+
let synonymsEditor = $state(null);
|
|
22
|
+
$effect(() => {
|
|
23
|
+
void definition;
|
|
24
|
+
if (newSynonym && synonymsEditor) {
|
|
25
|
+
const editors = synonymsEditor.querySelectorAll("input");
|
|
26
|
+
if (editors.length > 0) {
|
|
27
|
+
const last = editors[editors.length - 1];
|
|
28
|
+
if (last instanceof HTMLElement)
|
|
29
|
+
setTimeout(() => last.focus(), 0);
|
|
27
30
|
}
|
|
31
|
+
newSynonym = false;
|
|
32
|
+
}
|
|
28
33
|
});
|
|
29
34
|
function addSynonym() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if ($edition) {
|
|
36
|
+
edition.set(
|
|
37
|
+
$edition.withEditedDefinition(id, {
|
|
38
|
+
phrase: definition.phrase,
|
|
39
|
+
definition: definition.definition,
|
|
40
|
+
synonyms: [...definition.synonyms ?? [], ""]
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
newSynonym = true;
|
|
38
45
|
}
|
|
39
46
|
function removeSynonym(index) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...definition.synonyms.slice(index + 1),
|
|
46
|
-
]);
|
|
47
|
+
if (definition.synonyms && index >= 0 && index < definition.synonyms.length)
|
|
48
|
+
updateSynonyms([
|
|
49
|
+
...definition.synonyms.slice(0, index),
|
|
50
|
+
...definition.synonyms.slice(index + 1)
|
|
51
|
+
]);
|
|
47
52
|
}
|
|
48
53
|
function updateSynonyms(synonyms) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
if ($edition)
|
|
55
|
+
edition.set(
|
|
56
|
+
$edition.withEditedDefinition(id, {
|
|
57
|
+
phrase: definition.phrase,
|
|
58
|
+
definition: definition.definition,
|
|
59
|
+
synonyms
|
|
60
|
+
})
|
|
61
|
+
);
|
|
55
62
|
}
|
|
56
|
-
|
|
63
|
+
let syns = $derived(definition.synonyms || []);
|
|
57
64
|
</script>
|
|
58
65
|
|
|
59
66
|
{#if $edition}
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type Definition from '../../models/book/Definition';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
definition: Definition;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type DefinitionViewProps = typeof __propDef.props;
|
|
16
|
-
export type DefinitionViewEvents = typeof __propDef.events;
|
|
17
|
-
export type DefinitionViewSlots = typeof __propDef.slots;
|
|
18
|
-
export default class DefinitionView extends SvelteComponent<DefinitionViewProps, DefinitionViewEvents, DefinitionViewSlots> {
|
|
2
|
+
interface Props {
|
|
3
|
+
id: string;
|
|
4
|
+
definition: Definition;
|
|
19
5
|
}
|
|
20
|
-
|
|
6
|
+
declare const DefinitionView: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type DefinitionView = ReturnType<typeof DefinitionView>;
|
|
8
|
+
export default DefinitionView;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
<script>import Parser from
|
|
2
|
-
import ChapterBody from
|
|
3
|
-
import BookishEditor from
|
|
4
|
-
import {
|
|
1
|
+
<script lang="ts">import Parser from "../../models/chapter/Parser";
|
|
2
|
+
import ChapterBody from "../chapter/ChapterBody.svelte";
|
|
3
|
+
import BookishEditor from "../editor/BookishEditor.svelte";
|
|
4
|
+
import {
|
|
5
|
+
getUser,
|
|
6
|
+
getEdition,
|
|
7
|
+
getLeasee,
|
|
8
|
+
isEditionEditable,
|
|
9
|
+
lease
|
|
10
|
+
} from "./Contexts";
|
|
5
11
|
let auth = getUser();
|
|
6
12
|
let editable = isEditionEditable();
|
|
7
13
|
let edition = getEdition();
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
6
11
|
};
|
|
7
|
-
|
|
8
|
-
exports?: {} | undefined;
|
|
9
|
-
bindings?: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
export type DescriptionProps = typeof __propDef.props;
|
|
12
|
-
export type DescriptionEvents = typeof __propDef.events;
|
|
13
|
-
export type DescriptionSlots = typeof __propDef.slots;
|
|
14
|
-
export default class Description extends SvelteComponent<DescriptionProps, DescriptionEvents, DescriptionSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
15
13
|
}
|
|
16
|
-
|
|
14
|
+
declare const Description: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type Description = InstanceType<typeof Description>;
|
|
18
|
+
export default Description;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<script lang="ts">import { onDestroy } from "svelte";
|
|
2
|
+
import { getBase, getEdition } from "./Contexts";
|
|
3
|
+
import { buildEPUB } from "../../epub/build";
|
|
4
|
+
import { DEFAULT_SIZE, SIZES } from "../../epub/images";
|
|
5
|
+
let edition = getEdition();
|
|
6
|
+
let base = getBase();
|
|
7
|
+
let sizeID = $state(DEFAULT_SIZE.id);
|
|
8
|
+
let building = $state(false);
|
|
9
|
+
let progress = $state(void 0);
|
|
10
|
+
let error = $state(void 0);
|
|
11
|
+
let warnings = $state([]);
|
|
12
|
+
let url = $state(void 0);
|
|
13
|
+
let filename = $state("book.epub");
|
|
14
|
+
function release() {
|
|
15
|
+
if (url !== void 0) {
|
|
16
|
+
URL.revokeObjectURL(url);
|
|
17
|
+
url = void 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function chooseSize(id) {
|
|
21
|
+
sizeID = id;
|
|
22
|
+
release();
|
|
23
|
+
warnings = [];
|
|
24
|
+
error = void 0;
|
|
25
|
+
}
|
|
26
|
+
async function build() {
|
|
27
|
+
if ($edition === void 0 || building) return;
|
|
28
|
+
building = true;
|
|
29
|
+
release();
|
|
30
|
+
error = void 0;
|
|
31
|
+
warnings = [];
|
|
32
|
+
progress = { phase: "images", done: 0, total: 0 };
|
|
33
|
+
try {
|
|
34
|
+
const result = await buildEPUB($edition, {
|
|
35
|
+
base: $base ?? "",
|
|
36
|
+
size: SIZES[sizeID] ?? DEFAULT_SIZE,
|
|
37
|
+
onProgress: (update) => progress = update
|
|
38
|
+
});
|
|
39
|
+
url = URL.createObjectURL(result.blob);
|
|
40
|
+
filename = result.filename;
|
|
41
|
+
warnings = result.warnings;
|
|
42
|
+
} catch (problem) {
|
|
43
|
+
console.error(problem);
|
|
44
|
+
error = "Something went wrong building the e-book.";
|
|
45
|
+
} finally {
|
|
46
|
+
building = false;
|
|
47
|
+
progress = void 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let status = $derived.by(() => {
|
|
51
|
+
if (progress === void 0) return void 0;
|
|
52
|
+
if (progress.phase === "images")
|
|
53
|
+
return progress.total === 0 ? "Gathering images\u2026" : `Shrinking image ${progress.done} of ${progress.total}\u2026`;
|
|
54
|
+
if (progress.phase === "chapters")
|
|
55
|
+
return `Preparing chapter ${progress.done} of ${progress.total}\u2026`;
|
|
56
|
+
return "Packaging the book\u2026";
|
|
57
|
+
});
|
|
58
|
+
onDestroy(release);
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
{#if $edition}
|
|
62
|
+
<div class="epub">
|
|
63
|
+
<label>
|
|
64
|
+
Image size
|
|
65
|
+
<!-- The wrapper carries the disclosure arrow: turning off native
|
|
66
|
+
appearance to get the book's font also removes the browser's. -->
|
|
67
|
+
<span class="select">
|
|
68
|
+
<select
|
|
69
|
+
value={sizeID}
|
|
70
|
+
disabled={building}
|
|
71
|
+
onchange={(event) => chooseSize(event.currentTarget.value)}
|
|
72
|
+
>
|
|
73
|
+
{#each Object.values(SIZES) as size}
|
|
74
|
+
<option value={size.id}>{size.label}</option>
|
|
75
|
+
{/each}
|
|
76
|
+
</select>
|
|
77
|
+
</span>
|
|
78
|
+
</label>
|
|
79
|
+
<!-- A plain button rather than the app's, whose --app-* variables are
|
|
80
|
+
only defined in the (app) layout, so it renders unstyled here and
|
|
81
|
+
in books compiled by bookish-reader. -->
|
|
82
|
+
<button
|
|
83
|
+
type="button"
|
|
84
|
+
title="Build an EPUB of this book to read on an e-reader"
|
|
85
|
+
aria-label="Build an EPUB of this book to read on an e-reader"
|
|
86
|
+
disabled={building}
|
|
87
|
+
onclick={build}>↓ EPUB</button
|
|
88
|
+
>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
{#if error}
|
|
92
|
+
<p class="message error" role="alert">{error}</p>
|
|
93
|
+
{:else if status}
|
|
94
|
+
<p class="message" role="status" aria-live="polite">{status}</p>
|
|
95
|
+
{:else if url}
|
|
96
|
+
<!-- Rendered only once the blob exists, so this link is never present
|
|
97
|
+
in prerendered HTML for SvelteKit's crawler to follow. -->
|
|
98
|
+
<p class="ready">
|
|
99
|
+
<a href={url} download={filename}>Download {filename}</a>
|
|
100
|
+
</p>
|
|
101
|
+
{#if warnings.length > 0}
|
|
102
|
+
<p class="warnings">
|
|
103
|
+
{warnings.length}
|
|
104
|
+
{warnings.length === 1 ? 'image' : 'images'} couldn't be included,
|
|
105
|
+
usually because they're hosted somewhere that doesn't allow downloads.
|
|
106
|
+
Their captions are still in the book.
|
|
107
|
+
</p>
|
|
108
|
+
{/if}
|
|
109
|
+
{/if}
|
|
110
|
+
{/if}
|
|
111
|
+
|
|
112
|
+
<style>
|
|
113
|
+
/* Everything here is drawn with the book's own --bookish-* variables, which
|
|
114
|
+
are defined on the .bookish ancestor in Edition.svelte and so are in
|
|
115
|
+
scope in both the app and in books compiled by bookish-reader. The
|
|
116
|
+
--app-* chrome variables are not: they exist only in the (app) layout. */
|
|
117
|
+
|
|
118
|
+
.epub {
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-direction: row;
|
|
121
|
+
flex-wrap: wrap;
|
|
122
|
+
align-items: center;
|
|
123
|
+
gap: 0.5em;
|
|
124
|
+
margin-block: var(--bookish-paragraph-spacing);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
label {
|
|
128
|
+
display: inline-flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
gap: 0.5em;
|
|
131
|
+
font-family: var(--bookish-paragraph-font-family);
|
|
132
|
+
font-size: var(--bookish-small-font-size);
|
|
133
|
+
color: var(--bookish-muted-color);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.select {
|
|
137
|
+
position: relative;
|
|
138
|
+
display: inline-block;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* The disclosure arrow, in place of the native one. It inherits the text
|
|
142
|
+
color, so it follows the theme into dark mode. */
|
|
143
|
+
.select::after {
|
|
144
|
+
content: '▾';
|
|
145
|
+
position: absolute;
|
|
146
|
+
right: 0.6em;
|
|
147
|
+
top: 50%;
|
|
148
|
+
transform: translateY(-50%);
|
|
149
|
+
pointer-events: none;
|
|
150
|
+
font-size: 0.9em;
|
|
151
|
+
color: var(--bookish-paragraph-color);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* A <select> is a native menulist, and WebKit renders its face in the
|
|
155
|
+
system font whatever the cascade says until appearance is turned off. */
|
|
156
|
+
select {
|
|
157
|
+
appearance: none;
|
|
158
|
+
-webkit-appearance: none;
|
|
159
|
+
font-family: var(--bookish-paragraph-font-family);
|
|
160
|
+
font-size: var(--bookish-small-font-size);
|
|
161
|
+
font-weight: var(--bookish-paragraph-font-weight);
|
|
162
|
+
color: var(--bookish-paragraph-color);
|
|
163
|
+
background: var(--bookish-block-background-color);
|
|
164
|
+
border: 1px solid var(--bookish-border-color-light);
|
|
165
|
+
border-radius: var(--bookish-roundedness);
|
|
166
|
+
padding: var(--bookish-inline-padding);
|
|
167
|
+
padding-right: 2em;
|
|
168
|
+
max-width: 18em;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
button {
|
|
172
|
+
font-family: var(--bookish-paragraph-font-family);
|
|
173
|
+
font-size: var(--bookish-small-font-size);
|
|
174
|
+
font-weight: var(--bookish-bold-font-weight);
|
|
175
|
+
color: var(--bookish-link-color);
|
|
176
|
+
background: var(--bookish-block-background-color);
|
|
177
|
+
border: 1px solid var(--bookish-border-color-light);
|
|
178
|
+
border-radius: var(--bookish-roundedness);
|
|
179
|
+
padding: var(--bookish-inline-padding)
|
|
180
|
+
calc(var(--bookish-inline-padding) * 3);
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
button:hover:not(:disabled) {
|
|
185
|
+
border-color: var(--bookish-highlight-color);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* focus-visible, so a mouse click doesn't leave the ring behind while
|
|
189
|
+
keyboard users still get one. */
|
|
190
|
+
select:focus-visible,
|
|
191
|
+
button:focus-visible {
|
|
192
|
+
outline: none;
|
|
193
|
+
border-color: var(--bookish-highlight-color);
|
|
194
|
+
box-shadow: 0 0 0 2px var(--bookish-highlight-color);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
select:disabled,
|
|
198
|
+
button:disabled {
|
|
199
|
+
opacity: 0.5;
|
|
200
|
+
cursor: auto;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.message,
|
|
204
|
+
.ready,
|
|
205
|
+
.warnings {
|
|
206
|
+
font-family: var(--bookish-paragraph-font-family);
|
|
207
|
+
line-height: var(--bookish-paragraph-line-height);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.message {
|
|
211
|
+
color: var(--bookish-muted-color);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.error {
|
|
215
|
+
color: var(--bookish-error-color);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Matches a book link, from components/Link.svelte. */
|
|
219
|
+
.ready a {
|
|
220
|
+
color: var(--bookish-link-color);
|
|
221
|
+
font-weight: var(--bookish-link-font-weight);
|
|
222
|
+
text-decoration: none;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.ready a:hover {
|
|
226
|
+
text-decoration: underline;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.warnings {
|
|
230
|
+
font-size: var(--bookish-small-font-size);
|
|
231
|
+
font-style: italic;
|
|
232
|
+
color: var(--bookish-muted-color);
|
|
233
|
+
}
|
|
234
|
+
</style>
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
<script>import TextEditor from
|
|
2
|
-
import { getEdition, isEditionEditable } from
|
|
3
|
-
import PageHeader from
|
|
4
|
-
|
|
5
|
-
/** ARIA label */
|
|
6
|
-
export let label;
|
|
1
|
+
<script lang="ts">import TextEditor from "../editor/TextEditor.svelte";
|
|
2
|
+
import { getEdition, isEditionEditable } from "./Contexts";
|
|
3
|
+
import PageHeader from "./PageHeader.svelte";
|
|
4
|
+
let { id, label } = $props();
|
|
7
5
|
let edition = getEdition();
|
|
8
6
|
let editable = isEditionEditable();
|
|
9
7
|
</script>
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { TOCHeaderKey } from '../../models/book/ChapterID';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type EditableHeaderProps = typeof __propDef.props;
|
|
16
|
-
export type EditableHeaderEvents = typeof __propDef.events;
|
|
17
|
-
export type EditableHeaderSlots = typeof __propDef.slots;
|
|
18
|
-
export default class EditableHeader extends SvelteComponent<EditableHeaderProps, EditableHeaderEvents, EditableHeaderSlots> {
|
|
2
|
+
interface Props {
|
|
3
|
+
id: TOCHeaderKey;
|
|
4
|
+
/** ARIA label */
|
|
5
|
+
label: string;
|
|
19
6
|
}
|
|
20
|
-
|
|
7
|
+
declare const EditableHeader: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type EditableHeader = ReturnType<typeof EditableHeader>;
|
|
9
|
+
export default EditableHeader;
|