refactor: export getDefaultSettings for reader module use
- Export getDefaultSettings function for use in reader-navigation - Minor formatting improvements in settings-manager.ts - Add tabindex and ebook-content class to reader-content in template
This commit is contained in:
@@ -45,7 +45,7 @@ templ Reader(user User, metadata ReaderMetadata, progress ReadingProgress, bookm
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<main id="reader-content" class="w-full h-full">
|
<main id="reader-content" tabindex="0" class="ebook-content w-full h-full">
|
||||||
<!-- Content loaded by JavaScript based on media type -->
|
<!-- Content loaded by JavaScript based on media type -->
|
||||||
</main>
|
</main>
|
||||||
@DictionaryPopup()
|
@DictionaryPopup()
|
||||||
|
|||||||
@@ -15,24 +15,35 @@ export function init(context: ReaderContext): void {
|
|||||||
context.events.emit("settings:loaded", currentSettings);
|
context.events.emit("settings:loaded", currentSettings);
|
||||||
});
|
});
|
||||||
|
|
||||||
context.events.on("settings:save", async (detail: { settings: Partial<ReaderSettings> }) => {
|
context.events.on(
|
||||||
await saveSettings(detail.settings);
|
"settings:save",
|
||||||
currentSettings = await loadSettings();
|
async (detail: { settings: Partial<ReaderSettings> }) => {
|
||||||
context.events.emit("settings:changed", currentSettings);
|
await saveSettings(detail.settings);
|
||||||
});
|
currentSettings = await loadSettings();
|
||||||
|
context.events.emit("settings:changed", currentSettings);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
context.events.on("settings:get", (detail: { key?: keyof ReaderSettings }) => {
|
context.events.on(
|
||||||
if (currentSettings) {
|
"settings:get",
|
||||||
const value = detail.key ? currentSettings[detail.key] : currentSettings;
|
(detail: { key?: keyof ReaderSettings }) => {
|
||||||
context.events.emit("settings:current", { value });
|
if (currentSettings) {
|
||||||
}
|
const value = detail.key
|
||||||
});
|
? currentSettings[detail.key]
|
||||||
|
: currentSettings;
|
||||||
|
context.events.emit("settings:current", { value });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
context.events.on("settings:set", async (detail: { key: keyof ReaderSettings; value: any }) => {
|
context.events.on(
|
||||||
await saveSettings({ [detail.key]: detail.value });
|
"settings:set",
|
||||||
currentSettings = await loadSettings();
|
async (detail: { key: keyof ReaderSettings; value: any }) => {
|
||||||
context.events.emit("settings:changed", currentSettings);
|
await saveSettings({ [detail.key]: detail.value });
|
||||||
});
|
currentSettings = await loadSettings();
|
||||||
|
context.events.emit("settings:changed", currentSettings);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
context.events.on("settings:sync", async () => {
|
context.events.on("settings:sync", async () => {
|
||||||
await syncSettings();
|
await syncSettings();
|
||||||
@@ -93,7 +104,7 @@ async function syncSettings(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultSettings(): ReaderSettings {
|
export function getDefaultSettings(): ReaderSettings {
|
||||||
return {
|
return {
|
||||||
chrome_behavior: "auto-hide",
|
chrome_behavior: "auto-hide",
|
||||||
progress_mode: "pages",
|
progress_mode: "pages",
|
||||||
@@ -149,4 +160,4 @@ function getDefaultSettings(): ReaderSettings {
|
|||||||
mobile_nav_visible: true,
|
mobile_nav_visible: true,
|
||||||
},
|
},
|
||||||
} as ReaderSettings;
|
} as ReaderSettings;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user