|
@@ -1,5 +1,5 @@
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
-import { Divider, message, Result, Tag } from "antd";
|
|
|
|
|
|
|
+import { Divider, message, Result, Space, Tag } from "antd";
|
|
|
|
|
|
|
|
import { get, post } from "../../request";
|
|
import { get, post } from "../../request";
|
|
|
import store from "../../store";
|
|
import store from "../../store";
|
|
@@ -11,7 +11,6 @@ import { ITextbook, refresh } from "../../reducers/current-course";
|
|
|
import ExerciseList from "./ExerciseList";
|
|
import ExerciseList from "./ExerciseList";
|
|
|
import ExerciseAnswer from "../course/ExerciseAnswer";
|
|
import ExerciseAnswer from "../course/ExerciseAnswer";
|
|
|
import "./article.css";
|
|
import "./article.css";
|
|
|
-import CommentListCard from "../discussion/DiscussionListCard";
|
|
|
|
|
import TocTree from "./TocTree";
|
|
import TocTree from "./TocTree";
|
|
|
import PaliText from "../template/Wbw/PaliText";
|
|
import PaliText from "../template/Wbw/PaliText";
|
|
|
import ArticleSkeleton from "./ArticleSkeleton";
|
|
import ArticleSkeleton from "./ArticleSkeleton";
|
|
@@ -22,6 +21,7 @@ import {
|
|
|
IRecentRequest,
|
|
IRecentRequest,
|
|
|
IRecentResponse,
|
|
IRecentResponse,
|
|
|
} from "../../pages/studio/recent/list";
|
|
} from "../../pages/studio/recent/list";
|
|
|
|
|
+import { ITocPathNode } from "../corpus/TocPath";
|
|
|
|
|
|
|
|
export type ArticleMode = "read" | "edit" | "wbw";
|
|
export type ArticleMode = "read" | "edit" | "wbw";
|
|
|
export type ArticleType =
|
|
export type ArticleType =
|
|
@@ -59,7 +59,7 @@ interface IWidget {
|
|
|
book?: string | null;
|
|
book?: string | null;
|
|
|
para?: string | null;
|
|
para?: string | null;
|
|
|
channelId?: string | null;
|
|
channelId?: string | null;
|
|
|
- anthologyId?: string;
|
|
|
|
|
|
|
+ anthologyId?: string | null;
|
|
|
courseId?: string;
|
|
courseId?: string;
|
|
|
exerciseId?: string;
|
|
exerciseId?: string;
|
|
|
userName?: string;
|
|
userName?: string;
|
|
@@ -236,17 +236,19 @@ const ArticleWidget = ({
|
|
|
<TocTree
|
|
<TocTree
|
|
|
treeData={json.data.toc?.map((item) => {
|
|
treeData={json.data.toc?.map((item) => {
|
|
|
const strTitle = item.title ? item.title : item.pali_title;
|
|
const strTitle = item.title ? item.title : item.pali_title;
|
|
|
|
|
+ const key = item.key
|
|
|
|
|
+ ? item.key
|
|
|
|
|
+ : `${item.book}-${item.paragraph}`;
|
|
|
const progress = item.progress?.map((item, id) => (
|
|
const progress = item.progress?.map((item, id) => (
|
|
|
- <Tag key={id}>{Math.round(item * 100)}</Tag>
|
|
|
|
|
|
|
+ <Tag key={id}>{Math.round(item * 100) + "%"}</Tag>
|
|
|
));
|
|
));
|
|
|
-
|
|
|
|
|
return {
|
|
return {
|
|
|
- key: `${item.book}-${item.paragraph}`,
|
|
|
|
|
|
|
+ key: key,
|
|
|
title: (
|
|
title: (
|
|
|
- <>
|
|
|
|
|
|
|
+ <Space>
|
|
|
<PaliText text={strTitle} />
|
|
<PaliText text={strTitle} />
|
|
|
{progress}
|
|
{progress}
|
|
|
- </>
|
|
|
|
|
|
|
+ </Space>
|
|
|
),
|
|
),
|
|
|
level: item.level,
|
|
level: item.level,
|
|
|
};
|
|
};
|
|
@@ -377,6 +379,18 @@ const ArticleWidget = ({
|
|
|
getNextPara(articleData);
|
|
getNextPara(articleData);
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
|
|
+ onPathChange={(
|
|
|
|
|
+ node: ITocPathNode,
|
|
|
|
|
+ e: React.MouseEvent<HTMLSpanElement | HTMLAnchorElement, MouseEvent>
|
|
|
|
|
+ ) => {
|
|
|
|
|
+ if (typeof onArticleChange !== "undefined") {
|
|
|
|
|
+ const newArticle = node.key
|
|
|
|
|
+ ? node.key
|
|
|
|
|
+ : `${node.book}-${node.paragraph}`;
|
|
|
|
|
+ const target = e.ctrlKey || e.metaKey ? "_blank" : "self";
|
|
|
|
|
+ onArticleChange(newArticle, target);
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
|
|
|