|
@@ -1,9 +1,12 @@
|
|
|
-import { Affix, Button, Space, Typography } from "antd";
|
|
|
|
|
|
|
+import { Button, Space, Typography } from "antd";
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
import { DoubleRightOutlined, DoubleLeftOutlined } from "@ant-design/icons";
|
|
import { DoubleRightOutlined, DoubleLeftOutlined } from "@ant-design/icons";
|
|
|
|
|
|
|
|
import { get } from "../../request";
|
|
import { get } from "../../request";
|
|
|
import { ArticleType } from "./Article";
|
|
import { ArticleType } from "./Article";
|
|
|
|
|
+import React from "react";
|
|
|
|
|
+import NavigateButton from "./NavigateButton";
|
|
|
|
|
+import { ITocPathNode } from "../corpus/TocPath";
|
|
|
|
|
|
|
|
const { Paragraph, Text } = Typography;
|
|
const { Paragraph, Text } = Typography;
|
|
|
|
|
|
|
@@ -38,9 +41,17 @@ interface INavResponse {
|
|
|
interface IWidget {
|
|
interface IWidget {
|
|
|
type?: ArticleType;
|
|
type?: ArticleType;
|
|
|
articleId?: string;
|
|
articleId?: string;
|
|
|
|
|
+ path?: ITocPathNode[];
|
|
|
onChange?: Function;
|
|
onChange?: Function;
|
|
|
|
|
+ onPathChange?: Function;
|
|
|
}
|
|
}
|
|
|
-const NavigateWidget = ({ type, articleId, onChange }: IWidget) => {
|
|
|
|
|
|
|
+const NavigateWidget = ({
|
|
|
|
|
+ type,
|
|
|
|
|
+ articleId,
|
|
|
|
|
+ path,
|
|
|
|
|
+ onChange,
|
|
|
|
|
+ onPathChange,
|
|
|
|
|
+}: IWidget) => {
|
|
|
const [prev, setPrev] = useState<INavButton>();
|
|
const [prev, setPrev] = useState<INavButton>();
|
|
|
const [next, setNext] = useState<INavButton>();
|
|
const [next, setNext] = useState<INavButton>();
|
|
|
|
|
|
|
@@ -56,51 +67,28 @@ const NavigateWidget = ({ type, articleId, onChange }: IWidget) => {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}, [articleId, type]);
|
|
}, [articleId, type]);
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
- <Affix offsetBottom={0}>
|
|
|
|
|
- <Paragraph
|
|
|
|
|
- style={{
|
|
|
|
|
- display: "flex",
|
|
|
|
|
- justifyContent: "space-between",
|
|
|
|
|
- backdropFilter: "blur(5px)",
|
|
|
|
|
- backgroundColor: "rgba(200,200,200,0.2)",
|
|
|
|
|
- padding: 4,
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- <Button
|
|
|
|
|
- disabled={typeof prev === "undefined"}
|
|
|
|
|
- size="middle"
|
|
|
|
|
- onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
|
|
|
- if (typeof onChange !== "undefined" && prev) {
|
|
|
|
|
- onChange(event, prev.id);
|
|
|
|
|
- }
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- <Space>
|
|
|
|
|
- <DoubleLeftOutlined />
|
|
|
|
|
- <EllipsisMiddle maxWidth={300} suffixCount={7}>
|
|
|
|
|
- {prev?.title}
|
|
|
|
|
- </EllipsisMiddle>
|
|
|
|
|
- </Space>
|
|
|
|
|
- </Button>
|
|
|
|
|
- <Button
|
|
|
|
|
- size="middle"
|
|
|
|
|
- disabled={typeof next === "undefined"}
|
|
|
|
|
- onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
|
|
|
- if (typeof onChange !== "undefined" && next) {
|
|
|
|
|
- onChange(event, next.id);
|
|
|
|
|
- }
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- <Space>
|
|
|
|
|
- <EllipsisMiddle maxWidth={300} suffixCount={7}>
|
|
|
|
|
- {next?.title}
|
|
|
|
|
- </EllipsisMiddle>
|
|
|
|
|
- <DoubleRightOutlined />
|
|
|
|
|
- </Space>
|
|
|
|
|
- </Button>
|
|
|
|
|
- </Paragraph>
|
|
|
|
|
- </Affix>
|
|
|
|
|
|
|
+ <NavigateButton
|
|
|
|
|
+ prevTitle={prev?.title}
|
|
|
|
|
+ nextTitle={next?.title}
|
|
|
|
|
+ path={path}
|
|
|
|
|
+ onPrev={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
|
|
|
+ if (typeof onChange !== "undefined" && prev) {
|
|
|
|
|
+ onChange(event, prev.id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ onNext={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
|
|
|
+ if (typeof onChange !== "undefined" && next) {
|
|
|
|
|
+ onChange(event, next.id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ onPathChange={(key: string) => {
|
|
|
|
|
+ if (typeof onPathChange !== "undefined") {
|
|
|
|
|
+ onPathChange(key);
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|