|
@@ -2,33 +2,61 @@ import { useNavigate, useParams, useSearchParams } from "react-router";
|
|
|
import TypeArticle from "../../../components/article/TypeArticle";
|
|
import TypeArticle from "../../../components/article/TypeArticle";
|
|
|
import SplitLayout from "../../../components/general/SplitLayout";
|
|
import SplitLayout from "../../../components/general/SplitLayout";
|
|
|
import type { ArticleMode } from "../../../api/Article";
|
|
import type { ArticleMode } from "../../../api/Article";
|
|
|
|
|
+import AnthologyTocTree from "../../../components/anthology/AnthologyTocTree";
|
|
|
|
|
|
|
|
const Widget = () => {
|
|
const Widget = () => {
|
|
|
- const { id } = useParams();
|
|
|
|
|
- const [searchParams, setSearchParams] = useSearchParams();
|
|
|
|
|
|
|
+ const { articleId, anthologyId } = useParams();
|
|
|
|
|
+ const [searchParams] = useSearchParams();
|
|
|
const navigate = useNavigate();
|
|
const navigate = useNavigate();
|
|
|
const mode = searchParams.get("mode") ?? "read";
|
|
const mode = searchParams.get("mode") ?? "read";
|
|
|
const channelId = searchParams.get("channel");
|
|
const channelId = searchParams.get("channel");
|
|
|
const anthology = searchParams.get("anthology");
|
|
const anthology = searchParams.get("anthology");
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <SplitLayout key="mode-a" sidebarTitle="table of content" sidebar={<></>}>
|
|
|
|
|
|
|
+ <SplitLayout
|
|
|
|
|
+ key="mode-a"
|
|
|
|
|
+ sidebarTitle="table of content"
|
|
|
|
|
+ sidebar={
|
|
|
|
|
+ anthologyId ? (
|
|
|
|
|
+ <AnthologyTocTree
|
|
|
|
|
+ anthologyId={anthologyId}
|
|
|
|
|
+ channels={channelId ? channelId.split("_") : undefined}
|
|
|
|
|
+ onClick={(anthology, article, target) => {
|
|
|
|
|
+ if (target && target === "_blank") {
|
|
|
|
|
+ window.open(
|
|
|
|
|
+ `${window.location.origin}${import.meta.env.BASE_URL}workspace/anthology/${anthology}/${article}`,
|
|
|
|
|
+ "_blank"
|
|
|
|
|
+ );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ navigate(`/workspace/anthology/${anthology}/${article}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <></>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ >
|
|
|
{({ expandButton }) => (
|
|
{({ expandButton }) => (
|
|
|
<TypeArticle
|
|
<TypeArticle
|
|
|
- articleId={id}
|
|
|
|
|
|
|
+ articleId={articleId}
|
|
|
mode={mode as ArticleMode}
|
|
mode={mode as ArticleMode}
|
|
|
- anthologyId={anthology}
|
|
|
|
|
|
|
+ anthologyId={anthologyId ?? anthology}
|
|
|
channelId={channelId}
|
|
channelId={channelId}
|
|
|
headerExtra={expandButton}
|
|
headerExtra={expandButton}
|
|
|
onAnthologySelect={(id) => {
|
|
onAnthologySelect={(id) => {
|
|
|
- setSearchParams((prev) => {
|
|
|
|
|
- const next = new URLSearchParams(prev);
|
|
|
|
|
- next.set("anthology", id);
|
|
|
|
|
- return next;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ navigate(`/workspace/anthology/${id}/${articleId}`);
|
|
|
}}
|
|
}}
|
|
|
onArticleChange={(type, id) => {
|
|
onArticleChange={(type, id) => {
|
|
|
- navigate(`/workspace/${type}/${id}`);
|
|
|
|
|
|
|
+ if (anthologyId) {
|
|
|
|
|
+ if (type === "article") {
|
|
|
|
|
+ navigate(`/workspace/anthology/${anthologyId}/${id}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ navigate(`/workspace/${type}/${id}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ navigate(`/workspace/${type}/${id}`);
|
|
|
|
|
+ }
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|