Add exSTATic support
This commit is contained in:
@@ -12,7 +12,8 @@ import type { Page } from "$lib/types";
|
||||
export function countChars(line: string) {
|
||||
const isNotJapaneseRegex = /[^0-9A-Z○◯々-〇〻ぁ-ゖゝ-ゞァ-ヺー0-9A-Zヲ-ン\p{Radical}\p{Unified_Ideograph}]+/gimu
|
||||
const cleaned = line.replace(isNotJapaneseRegex, '')
|
||||
return cleaned.length;
|
||||
|
||||
return Array.from(cleaned).length;
|
||||
}
|
||||
|
||||
export function getCharCount(pages: Page[], currentPage?: number) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { page } from "$app/stores";
|
||||
import { get } from "svelte/store";
|
||||
import { showSnackbar } from "./snackbar";
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
export function clamp(num: number, min: number, max: number) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
@@ -30,4 +31,19 @@ export function toClipboard() {
|
||||
'pip3 install git+https://github.com/kha-white/mokuro.git@web-reader'
|
||||
);
|
||||
showSnackbar('Copied to clipboard');
|
||||
}
|
||||
|
||||
type ExtaticPayload = {
|
||||
title: string;
|
||||
volumeName: string;
|
||||
currentCharCount: number;
|
||||
currentPageNum: number;
|
||||
}
|
||||
|
||||
type ExtaticEvent = 'mokuro-reader:page.change' | 'mokuro-reader:reader.closed'
|
||||
|
||||
export function fireExstaticEvent(event: ExtaticEvent, payload: ExtaticPayload) {
|
||||
if (browser) {
|
||||
document.dispatchEvent(new CustomEvent(event, { detail: payload }))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user