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,35 +1,40 @@
|
|
|
1
|
-
<script>import Header from
|
|
2
|
-
import Outline from
|
|
3
|
-
import Page from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
1
|
+
<script lang="ts">import Header from "./Header.svelte";
|
|
2
|
+
import Outline from "./Outline.svelte";
|
|
3
|
+
import Page from "./Page.svelte";
|
|
4
|
+
import {
|
|
5
|
+
BookishTheme,
|
|
6
|
+
CriticalTheme,
|
|
7
|
+
HumanTheme,
|
|
8
|
+
SeriousTheme,
|
|
9
|
+
SketchyTheme,
|
|
10
|
+
TechTheme
|
|
11
|
+
} from "../../models/book/Theme";
|
|
12
|
+
import ConfirmButton from "../editor/ConfirmButton.svelte";
|
|
13
|
+
import Instructions from "./Instructions.svelte";
|
|
14
|
+
import ThemeSetEditor from "./ThemeSetEditor.svelte";
|
|
15
|
+
import ThemeEditorPreview from "./ThemeEditorPreview.svelte";
|
|
16
|
+
import { getEdition, isEditionEditable } from "./Contexts";
|
|
17
|
+
import TextEditor from "../editor/TextEditor.svelte";
|
|
18
|
+
import Button from "../app/Button.svelte";
|
|
19
|
+
import Switch from "../editor/Switch.svelte";
|
|
20
|
+
import Link from "../app/Link.svelte";
|
|
21
|
+
import Rows from "./Rows.svelte";
|
|
15
22
|
const themes = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
Bookish: BookishTheme,
|
|
24
|
+
Serious: SeriousTheme,
|
|
25
|
+
Tech: TechTheme,
|
|
26
|
+
Human: HumanTheme,
|
|
27
|
+
Sketchy: SketchyTheme,
|
|
28
|
+
Critical: CriticalTheme
|
|
22
29
|
};
|
|
23
30
|
let editable = isEditionEditable();
|
|
24
31
|
let edition = getEdition();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
theme === null || Object.values(themes).includes(theme);
|
|
32
|
+
let theme = $derived($edition ? $edition.getTheme() : null);
|
|
33
|
+
let isDefault = $derived(theme === null || Object.values(themes).includes(theme));
|
|
28
34
|
function getEmptyGroup(group) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return empty;
|
|
35
|
+
const empty = {};
|
|
36
|
+
for (const key in Object.keys(group)) empty[key] = "";
|
|
37
|
+
return empty;
|
|
33
38
|
}
|
|
34
39
|
</script>
|
|
35
40
|
|
|
@@ -41,7 +46,9 @@ function getEmptyGroup(group) {
|
|
|
41
46
|
id="theme"
|
|
42
47
|
header="Theme"
|
|
43
48
|
>
|
|
44
|
-
|
|
49
|
+
{#snippet outline()}
|
|
50
|
+
<Outline previous={null} next={null} />
|
|
51
|
+
{/snippet}
|
|
45
52
|
</Header>
|
|
46
53
|
|
|
47
54
|
<Instructions {editable}>
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
events: {
|
|
5
|
-
[evt: string]: CustomEvent<any>;
|
|
6
|
-
};
|
|
7
|
-
slots: {};
|
|
8
|
-
exports?: {} | undefined;
|
|
9
|
-
bindings?: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
export type ThemeEditorProps = typeof __propDef.props;
|
|
12
|
-
export type ThemeEditorEvents = typeof __propDef.events;
|
|
13
|
-
export type ThemeEditorSlots = typeof __propDef.slots;
|
|
14
|
-
export default class ThemeEditor extends SvelteComponent<ThemeEditorProps, ThemeEditorEvents, ThemeEditorSlots> {
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
1
|
+
declare const ThemeEditor: import("svelte").Component<Record<string, never>, {}, "">;
|
|
2
|
+
type ThemeEditor = ReturnType<typeof ThemeEditor>;
|
|
3
|
+
export default ThemeEditor;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
<script>import ChapterBody from
|
|
2
|
-
import Parser from
|
|
3
|
-
import { getDarkMode } from
|
|
4
|
-
|
|
5
|
-
let position;
|
|
1
|
+
<script lang="ts">import ChapterBody from "../chapter/ChapterBody.svelte";
|
|
2
|
+
import Parser from "../../models/chapter/Parser";
|
|
3
|
+
import { getDarkMode } from "./Contexts";
|
|
4
|
+
let { theme } = $props();
|
|
5
|
+
let position = $state(0);
|
|
6
6
|
let darkMode = getDarkMode();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
? theme.dark?.backgroundColor
|
|
12
|
-
: theme.light?.backgroundColor;
|
|
13
|
-
$: preview = Parser.parseChapter(undefined, `# Header 1
|
|
7
|
+
let backgroundColor = $derived(theme === null ? null : $darkMode ? theme.dark?.backgroundColor : theme.light?.backgroundColor);
|
|
8
|
+
let preview = $derived(Parser.parseChapter(
|
|
9
|
+
void 0,
|
|
10
|
+
`# Header 1
|
|
14
11
|
## Header 2
|
|
15
12
|
### Header 3
|
|
16
13
|
|
|
@@ -18,7 +15,8 @@ $: preview = Parser.parseChapter(undefined, `# Header 1
|
|
|
18
15
|
|
|
19
16
|
* How does it look?
|
|
20
17
|
* Would you change anything?
|
|
21
|
-
`
|
|
18
|
+
`
|
|
19
|
+
));
|
|
22
20
|
</script>
|
|
23
21
|
|
|
24
22
|
<aside
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type Theme from '../../models/book/Theme';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
theme: Theme | null;
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
};
|
|
10
|
-
slots: {};
|
|
11
|
-
exports?: {} | undefined;
|
|
12
|
-
bindings?: string | undefined;
|
|
13
|
-
};
|
|
14
|
-
export type ThemeEditorPreviewProps = typeof __propDef.props;
|
|
15
|
-
export type ThemeEditorPreviewEvents = typeof __propDef.events;
|
|
16
|
-
export type ThemeEditorPreviewSlots = typeof __propDef.slots;
|
|
17
|
-
export default class ThemeEditorPreview extends SvelteComponent<ThemeEditorPreviewProps, ThemeEditorPreviewEvents, ThemeEditorPreviewSlots> {
|
|
2
|
+
interface Props {
|
|
3
|
+
theme: Theme | null;
|
|
18
4
|
}
|
|
19
|
-
|
|
5
|
+
declare const ThemeEditorPreview: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type ThemeEditorPreview = ReturnType<typeof ThemeEditorPreview>;
|
|
7
|
+
export default ThemeEditorPreview;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
<script>import PageHeader from
|
|
2
|
-
import Rows from
|
|
3
|
-
import ThemeVariableEditor from
|
|
4
|
-
|
|
5
|
-
export let group;
|
|
6
|
-
export let properties;
|
|
1
|
+
<script lang="ts">import PageHeader from "./PageHeader.svelte";
|
|
2
|
+
import Rows from "./Rows.svelte";
|
|
3
|
+
import ThemeVariableEditor from "./ThemeVariableEditor.svelte";
|
|
4
|
+
let { header, group, properties } = $props();
|
|
7
5
|
</script>
|
|
8
6
|
|
|
9
7
|
<PageHeader>{header}</PageHeader>
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
group: string;
|
|
6
|
-
properties: Record<string, string>;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type ThemeSetEditorProps = typeof __propDef.props;
|
|
16
|
-
export type ThemeSetEditorEvents = typeof __propDef.events;
|
|
17
|
-
export type ThemeSetEditorSlots = typeof __propDef.slots;
|
|
18
|
-
export default class ThemeSetEditor extends SvelteComponent<ThemeSetEditorProps, ThemeSetEditorEvents, ThemeSetEditorSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
header: string;
|
|
3
|
+
group: string;
|
|
4
|
+
properties: Record<string, string>;
|
|
19
5
|
}
|
|
20
|
-
|
|
6
|
+
declare const ThemeSetEditor: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type ThemeSetEditor = ReturnType<typeof ThemeSetEditor>;
|
|
8
|
+
export default ThemeSetEditor;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
<script>import TextEditor from
|
|
2
|
-
import { getEdition } from
|
|
1
|
+
<script lang="ts">import TextEditor from "../editor/TextEditor.svelte";
|
|
2
|
+
import { getEdition } from "./Contexts";
|
|
3
3
|
const placeholders = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
light: "CSS color",
|
|
5
|
+
dark: "CSS color",
|
|
6
|
+
fonts: "CSS font name",
|
|
7
|
+
sizes: "CSS font size",
|
|
8
|
+
weights: "CSS font weights",
|
|
9
|
+
spacing: "CSS length"
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
export let name;
|
|
13
|
-
export let value;
|
|
11
|
+
let { group, name, value } = $props();
|
|
14
12
|
let edition = getEdition();
|
|
15
13
|
</script>
|
|
16
14
|
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type ThemeVariableEditorProps = typeof __propDef.props;
|
|
16
|
-
export type ThemeVariableEditorEvents = typeof __propDef.events;
|
|
17
|
-
export type ThemeVariableEditorSlots = typeof __propDef.slots;
|
|
18
|
-
export default class ThemeVariableEditor extends SvelteComponent<ThemeVariableEditorProps, ThemeVariableEditorEvents, ThemeVariableEditorSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
group: string;
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
19
5
|
}
|
|
20
|
-
|
|
6
|
+
declare const ThemeVariableEditor: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type ThemeVariableEditor = ReturnType<typeof ThemeVariableEditor>;
|
|
8
|
+
export default ThemeVariableEditor;
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** @typedef {typeof __propDef.slots} TitleSlots */
|
|
4
|
-
export default class Title extends SvelteComponent<{
|
|
5
|
-
[x: string]: never;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {
|
|
9
|
-
default: {};
|
|
10
|
-
}> {
|
|
1
|
+
interface Props {
|
|
2
|
+
children?: import('svelte').Snippet;
|
|
11
3
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
import { SvelteComponent } from "svelte";
|
|
16
|
-
declare const __propDef: {
|
|
17
|
-
props: {
|
|
18
|
-
[x: string]: never;
|
|
19
|
-
};
|
|
20
|
-
events: {
|
|
21
|
-
[evt: string]: CustomEvent<any>;
|
|
22
|
-
};
|
|
23
|
-
slots: {
|
|
24
|
-
default: {};
|
|
25
|
-
};
|
|
26
|
-
exports?: undefined;
|
|
27
|
-
bindings?: undefined;
|
|
28
|
-
};
|
|
29
|
-
export {};
|
|
4
|
+
declare const Title: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type Title = ReturnType<typeof Title>;
|
|
6
|
+
export default Title;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
<script>import Header from
|
|
2
|
-
import Outline from
|
|
3
|
-
import Page from
|
|
4
|
-
import Instructions from
|
|
5
|
-
import ChapterIDs from
|
|
6
|
-
import { getEdition, isEditionEditable } from
|
|
1
|
+
<script lang="ts">import Header from "./Header.svelte";
|
|
2
|
+
import Outline from "./Outline.svelte";
|
|
3
|
+
import Page from "./Page.svelte";
|
|
4
|
+
import Instructions from "./Instructions.svelte";
|
|
5
|
+
import ChapterIDs from "../../models/book/ChapterID";
|
|
6
|
+
import { getEdition, isEditionEditable } from "./Contexts";
|
|
7
|
+
let { children } = $props();
|
|
7
8
|
let editable = isEditionEditable();
|
|
8
9
|
let edition = getEdition();
|
|
9
10
|
</script>
|
|
@@ -23,7 +24,9 @@ let edition = getEdition();
|
|
|
23
24
|
: undefined}
|
|
24
25
|
header={$edition.getHeader(ChapterIDs.UnknownID)}
|
|
25
26
|
>
|
|
26
|
-
|
|
27
|
+
{#snippet outline()}
|
|
28
|
+
<Outline previous={null} next={null} />
|
|
29
|
+
{/snippet}
|
|
27
30
|
</Header>
|
|
28
31
|
|
|
29
32
|
<Instructions {editable}>
|
|
@@ -31,6 +34,6 @@ let edition = getEdition();
|
|
|
31
34
|
doesn't exist. You can customize the image shown.
|
|
32
35
|
</Instructions>
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
{@render children?.()}
|
|
35
38
|
</Page>
|
|
36
39
|
{/if}
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
props: Record<string, never>;
|
|
4
|
-
events: {
|
|
5
|
-
[evt: string]: CustomEvent<any>;
|
|
6
|
-
};
|
|
7
|
-
slots: {
|
|
8
|
-
default: {};
|
|
9
|
-
};
|
|
10
|
-
exports?: {} | undefined;
|
|
11
|
-
bindings?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type UnknownProps = typeof __propDef.props;
|
|
14
|
-
export type UnknownEvents = typeof __propDef.events;
|
|
15
|
-
export type UnknownSlots = typeof __propDef.slots;
|
|
16
|
-
export default class Unknown extends SvelteComponent<UnknownProps, UnknownEvents, UnknownSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
children?: import('svelte').Snippet;
|
|
17
3
|
}
|
|
18
|
-
|
|
4
|
+
declare const Unknown: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type Unknown = ReturnType<typeof Unknown>;
|
|
6
|
+
export default Unknown;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a complete EPUB from a loaded edition, entirely in the browser.
|
|
3
|
+
*
|
|
4
|
+
* No server is involved: the whole book's text is already in memory by the time
|
|
5
|
+
* the table of contents renders, and images are fetched directly (Firebase's
|
|
6
|
+
* download URLs allow cross-origin reads, and compiled books serve theirs from
|
|
7
|
+
* the same origin).
|
|
8
|
+
*/
|
|
9
|
+
import type Edition from '../models/book/Edition';
|
|
10
|
+
import { type ImageSize } from './images';
|
|
11
|
+
import { chapterPath } from './xhtml';
|
|
12
|
+
export type BuildPhase = 'images' | 'chapters' | 'packaging';
|
|
13
|
+
export type BuildProgress = {
|
|
14
|
+
phase: BuildPhase;
|
|
15
|
+
done: number;
|
|
16
|
+
total: number;
|
|
17
|
+
};
|
|
18
|
+
export type BuildResult = {
|
|
19
|
+
blob: Blob;
|
|
20
|
+
filename: string;
|
|
21
|
+
/** Images that couldn't be included, so the reader knows what's missing. */
|
|
22
|
+
warnings: string[];
|
|
23
|
+
};
|
|
24
|
+
export type BuildOptions = {
|
|
25
|
+
/** The book's base path, for resolving local image URLs. */
|
|
26
|
+
base?: string;
|
|
27
|
+
size?: ImageSize;
|
|
28
|
+
onProgress?: (progress: BuildProgress) => void;
|
|
29
|
+
/** Fixed timestamp, so tests can compare output. */
|
|
30
|
+
modified?: Date;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A stable, unique identifier for this edition. EPUB requires one, and readers
|
|
34
|
+
* use it to recognize the same book across downloads.
|
|
35
|
+
*/
|
|
36
|
+
export declare function identifierFor(edition: Edition): string;
|
|
37
|
+
/** Build an EPUB for the given edition. */
|
|
38
|
+
export declare function buildEPUB(edition: Edition, options?: BuildOptions): Promise<BuildResult>;
|
|
39
|
+
export { chapterPath };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a complete EPUB from a loaded edition, entirely in the browser.
|
|
3
|
+
*
|
|
4
|
+
* No server is involved: the whole book's text is already in memory by the time
|
|
5
|
+
* the table of contents renders, and images are fetched directly (Firebase's
|
|
6
|
+
* download URLs allow cross-origin reads, and compiled books serve theirs from
|
|
7
|
+
* the same origin).
|
|
8
|
+
*/
|
|
9
|
+
import EmbedNode from '../models/chapter/EmbedNode';
|
|
10
|
+
import Parser from '../models/chapter/Parser';
|
|
11
|
+
import Zip from './zip';
|
|
12
|
+
import { DEFAULT_SIZE, mapWithLimit, prepareImage, resolveImageURL, } from './images';
|
|
13
|
+
import { CONTAINER, CONTENT_DIRECTORY, MIMETYPE, STYLESHEET, chapterDocument, coverDocument, glossaryDocument, includedChapters, navigationDocument, ncxDocument, packageDocument, referencesDocument, safeFilename, titleDocument, } from './package';
|
|
14
|
+
import { chapterPath } from './xhtml';
|
|
15
|
+
/** How many images to fetch at once. */
|
|
16
|
+
const IMAGE_CONCURRENCY = 4;
|
|
17
|
+
/**
|
|
18
|
+
* A stable, unique identifier for this edition. EPUB requires one, and readers
|
|
19
|
+
* use it to recognize the same book across downloads.
|
|
20
|
+
*/
|
|
21
|
+
export function identifierFor(edition) {
|
|
22
|
+
const book = edition.getBookRef()?.id;
|
|
23
|
+
const version = edition.getEditionRef()?.id ?? edition.getEditionNumber();
|
|
24
|
+
return book === undefined
|
|
25
|
+
? `urn:bookish:${safeFilename(edition.getTitle())}:${version}`
|
|
26
|
+
: `urn:bookish:${book}:${version}`;
|
|
27
|
+
}
|
|
28
|
+
/** Build an EPUB for the given edition. */
|
|
29
|
+
export async function buildEPUB(edition, options = {}) {
|
|
30
|
+
const { base = '', size = DEFAULT_SIZE, onProgress, modified = new Date(), } = options;
|
|
31
|
+
const warnings = [];
|
|
32
|
+
const chapters = includedChapters(edition);
|
|
33
|
+
// Collect every distinct image the book uses. getEmbeds walks the cover,
|
|
34
|
+
// each chapter's cover, chapter bodies, and the back matter covers.
|
|
35
|
+
const coverEmbed = parseCover(edition);
|
|
36
|
+
const embeds = new Map();
|
|
37
|
+
if (coverEmbed)
|
|
38
|
+
embeds.set(coverEmbed.getURL(), coverEmbed);
|
|
39
|
+
for (const { embed } of edition.getEmbeds())
|
|
40
|
+
// Videos are links in the package, not files, and an embed with no URL
|
|
41
|
+
// is an empty placeholder the author hasn't filled in yet.
|
|
42
|
+
if (!embed.isVideo() && embed.getURL().trim().length > 0)
|
|
43
|
+
if (!embeds.has(embed.getURL()))
|
|
44
|
+
embeds.set(embed.getURL(), embed);
|
|
45
|
+
const urls = [...embeds.keys()];
|
|
46
|
+
onProgress?.({ phase: 'images', done: 0, total: urls.length });
|
|
47
|
+
let fetched = 0;
|
|
48
|
+
const prepared = await mapWithLimit(urls, IMAGE_CONCURRENCY, async (url) => {
|
|
49
|
+
const image = await prepareImage(resolveImageURL(url, base), size);
|
|
50
|
+
onProgress?.({
|
|
51
|
+
phase: 'images',
|
|
52
|
+
done: ++fetched,
|
|
53
|
+
total: urls.length,
|
|
54
|
+
});
|
|
55
|
+
return { url, image };
|
|
56
|
+
});
|
|
57
|
+
// Map each embed URL to its path inside the package.
|
|
58
|
+
const images = [];
|
|
59
|
+
const imagePaths = new Map();
|
|
60
|
+
const coverURL = coverEmbed?.getURL();
|
|
61
|
+
for (const { url, image } of prepared) {
|
|
62
|
+
if (image === undefined) {
|
|
63
|
+
warnings.push(url);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const index = images.length;
|
|
67
|
+
const path = `images/${index}.${image.extension}`;
|
|
68
|
+
imagePaths.set(url, path);
|
|
69
|
+
images.push({
|
|
70
|
+
path,
|
|
71
|
+
id: `image-${index}`,
|
|
72
|
+
mediaType: image.mediaType,
|
|
73
|
+
bytes: image.bytes,
|
|
74
|
+
cover: url === coverURL,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const context = {
|
|
78
|
+
edition,
|
|
79
|
+
images: imagePaths,
|
|
80
|
+
chapters: new Set(chapters.map((chapter) => chapter.getID())),
|
|
81
|
+
};
|
|
82
|
+
// Front matter, chapters, then back matter, which is also the reading order.
|
|
83
|
+
onProgress?.({ phase: 'chapters', done: 0, total: chapters.length });
|
|
84
|
+
const documents = [];
|
|
85
|
+
const coverPath = coverURL ? imagePaths.get(coverURL) : undefined;
|
|
86
|
+
if (coverPath !== undefined)
|
|
87
|
+
documents.push(coverDocument(coverPath));
|
|
88
|
+
documents.push(titleDocument(edition, context));
|
|
89
|
+
let written = 0;
|
|
90
|
+
for (const chapter of chapters) {
|
|
91
|
+
const document = chapterDocument(edition, chapter, context);
|
|
92
|
+
if (document !== undefined)
|
|
93
|
+
documents.push(document);
|
|
94
|
+
onProgress?.({
|
|
95
|
+
phase: 'chapters',
|
|
96
|
+
done: ++written,
|
|
97
|
+
total: chapters.length,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const references = referencesDocument(edition, context);
|
|
101
|
+
if (references !== undefined)
|
|
102
|
+
documents.push(references);
|
|
103
|
+
const glossary = glossaryDocument(edition, context);
|
|
104
|
+
if (glossary !== undefined)
|
|
105
|
+
documents.push(glossary);
|
|
106
|
+
onProgress?.({ phase: 'packaging', done: 0, total: 1 });
|
|
107
|
+
const navigation = navigationDocument(documents);
|
|
108
|
+
const identifier = identifierFor(edition);
|
|
109
|
+
const zip = new Zip(modified);
|
|
110
|
+
// The mimetype must be first and uncompressed so readers can identify the
|
|
111
|
+
// file by reading a fixed range of bytes at its head.
|
|
112
|
+
zip.add('mimetype', MIMETYPE, true);
|
|
113
|
+
zip.add('META-INF/container.xml', CONTAINER);
|
|
114
|
+
const content = (path) => `${CONTENT_DIRECTORY}/${path}`;
|
|
115
|
+
zip.add(content('content.opf'), packageDocument(edition, identifier, documents, images, modified));
|
|
116
|
+
zip.add(content('toc.ncx'), ncxDocument(identifier, edition.getTitle(), documents));
|
|
117
|
+
zip.add(content(navigation.path), navigation.content);
|
|
118
|
+
zip.add(content('style.css'), STYLESHEET);
|
|
119
|
+
for (const document of documents)
|
|
120
|
+
zip.add(content(document.path), document.content);
|
|
121
|
+
// Images are already compressed; deflating them again costs time and saves
|
|
122
|
+
// nothing, so they are stored.
|
|
123
|
+
for (const image of images)
|
|
124
|
+
zip.add(content(image.path), image.bytes, true);
|
|
125
|
+
const blob = await zip.toBlob(MIMETYPE);
|
|
126
|
+
onProgress?.({ phase: 'packaging', done: 1, total: 1 });
|
|
127
|
+
return {
|
|
128
|
+
blob,
|
|
129
|
+
filename: `${safeFilename(edition.getTitle())}.epub`,
|
|
130
|
+
warnings,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/** The cover embed, if the edition has one. */
|
|
134
|
+
function parseCover(edition) {
|
|
135
|
+
const cover = edition.getImage('cover');
|
|
136
|
+
if (cover === null)
|
|
137
|
+
return undefined;
|
|
138
|
+
const node = Parser.parseEmbed(edition, cover);
|
|
139
|
+
return node instanceof EmbedNode && node.getURL().trim().length > 0
|
|
140
|
+
? node
|
|
141
|
+
: undefined;
|
|
142
|
+
}
|
|
143
|
+
export { chapterPath };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|