mirror of
https://github.com/koodo-reader/koodo-reader.git
synced 2026-06-16 03:40:53 -04:00
feat: update text parser configuration and localization
- Added new localization entries for "Number parser" and its description in zh-CN.json. - Refactored dropdown list component to utilize KookitConfig for content regex configurations instead of the removed contentRegxConfig. - Updated ChapterSetting component to use KookitConfig.ContentRegxConfig for built-in parsers. - Adjusted common utility functions to integrate KookitConfig.ContentRegxConfig for text parsing.
This commit is contained in:
2
src/assets/lib/kookit-extra-browser.min.js
vendored
2
src/assets/lib/kookit-extra-browser.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -729,6 +729,8 @@
|
||||
"Reader menu will not be triggered by hovering but clicking on the area": "阅读器菜单不是进入特定区域就触发,而是需要点击相关区域才能触发",
|
||||
"Gesture and UI optimization for touch screen": "针对触控屏进行了UI和手势操作的优化",
|
||||
"The book that you read from last time will be open automatically when launching": "软件启动时,自动打开上次阅读的图书",
|
||||
"Number parser": "数字目录解析器",
|
||||
"Suitable for novels with number chapter titles, eg. 1, 2, 3": "适用于章节标题为数字的小说,如 1、2、一、二",
|
||||
"All the folded content will be expanded in the navigation panel": "自动展开图书的多级目录",
|
||||
"Reader window will be maximized to fit the screen when opening a book": "打开图书时,窗口自动最大化",
|
||||
"Please upgrade to Pro to unlock more daily free quota or wait until the quota resets. You can also use other TTS voices instead.": "请升级到专业版以解锁更多每日免费额度,或等待额度重置。您也可以使用其他 TTS 语音替代。",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import React from "react";
|
||||
import {
|
||||
contentRegxConfig,
|
||||
dropdownList,
|
||||
} from "../../../constants/dropdownList";
|
||||
import { dropdownList } from "../../../constants/dropdownList";
|
||||
import "./dropdownList.css";
|
||||
import { Trans } from "react-i18next";
|
||||
import { DropdownListProps, DropdownListState } from "./interface";
|
||||
import { ConfigService } from "../../../assets/lib/kookit-extra-browser.min";
|
||||
import {
|
||||
ConfigService,
|
||||
KookitConfig,
|
||||
} from "../../../assets/lib/kookit-extra-browser.min";
|
||||
import { loadFontData, vexComfirmAsync } from "../../../utils/common";
|
||||
import toast from "react-hot-toast";
|
||||
declare var window: any;
|
||||
@@ -65,7 +65,10 @@ class DropdownList extends React.Component<
|
||||
value: label,
|
||||
}));
|
||||
this.setState({
|
||||
txtParserOptions: [...contentRegxConfig, ...customParserOptions],
|
||||
txtParserOptions: [
|
||||
...KookitConfig.ContentRegxConfig,
|
||||
...customParserOptions,
|
||||
],
|
||||
});
|
||||
loadFontData().then((result) => {
|
||||
if (!result || result.length === 0) return;
|
||||
|
||||
@@ -338,23 +338,3 @@ export const titleSizeList = [
|
||||
{ label: "4", value: "4" },
|
||||
{ label: "5", value: "5" },
|
||||
];
|
||||
export const contentRegxConfig = [
|
||||
{
|
||||
label: "Default parser",
|
||||
value: "Default parser",
|
||||
subtitle: "Suitable for most txt files",
|
||||
regex: "",
|
||||
},
|
||||
{
|
||||
label: "Chinese novel parser",
|
||||
value: "Chinese novel parser",
|
||||
subtitle: "Suitable for most Chinese novels, eg. 第一章,第2回",
|
||||
regex: String.raw`^\s*(第[0-9一二三四五六七八九十百千万零]+[章回])\s*(.*?)$`,
|
||||
},
|
||||
{
|
||||
label: "English novel parser",
|
||||
value: "English novel parser",
|
||||
subtitle: "Suitable for most English novels, eg. Chapter 1, Part II",
|
||||
regex: String.raw`^(Chapter|Part|Book|CHAPTER|PART|BOOK)\b.*$`,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -2,8 +2,10 @@ import React from "react";
|
||||
import { SettingInfoProps, SettingInfoState, TxtParser } from "./interface";
|
||||
import { Trans } from "react-i18next";
|
||||
import toast from "react-hot-toast";
|
||||
import { ConfigService } from "../../../assets/lib/kookit-extra-browser.min";
|
||||
import { contentRegxConfig } from "../../../constants/dropdownList";
|
||||
import {
|
||||
ConfigService,
|
||||
KookitConfig,
|
||||
} from "../../../assets/lib/kookit-extra-browser.min";
|
||||
|
||||
class ChapterSetting extends React.Component<
|
||||
SettingInfoProps,
|
||||
@@ -195,7 +197,7 @@ class ChapterSetting extends React.Component<
|
||||
<Trans>Built-in parsers</Trans>
|
||||
</div>
|
||||
|
||||
{contentRegxConfig.map((parser) => (
|
||||
{KookitConfig.ContentRegxConfig.map((parser) => (
|
||||
<div
|
||||
className="setting-dialog-new-title"
|
||||
key={parser.label}
|
||||
|
||||
@@ -31,7 +31,6 @@ import { driveList } from "../constants/driveList";
|
||||
import { updateUserConfig } from "./request/user";
|
||||
import { languageCNMap, languageENMap } from "../constants/ttsList";
|
||||
import { BookHelper } from "../assets/lib/kookit.min";
|
||||
import { contentRegxConfig } from "../constants/dropdownList";
|
||||
declare var window: any;
|
||||
export const supportedFormats = [
|
||||
".epub",
|
||||
@@ -1139,7 +1138,7 @@ export const getParserRegex = (extension: string, bookKey?: string) => {
|
||||
}
|
||||
let txtParsers: any[] = [
|
||||
...Object.values(ConfigService.getAllObjectConfig("txtParsers")),
|
||||
...contentRegxConfig,
|
||||
...KookitConfig.ContentRegxConfig,
|
||||
];
|
||||
let txtParser = txtParsers.find(
|
||||
(parser) => parser.value === defaultTxtParser
|
||||
|
||||
Reference in New Issue
Block a user