|
|
@@ -1,5 +1,13 @@
|
|
|
import { useEffect, useState, type JSX } from "react";
|
|
|
-import { App, Button, Modal, Popover, Skeleton, Typography } from "antd";
|
|
|
+import {
|
|
|
+ App,
|
|
|
+ Button,
|
|
|
+ Modal,
|
|
|
+ Popover,
|
|
|
+ Skeleton,
|
|
|
+ Typography,
|
|
|
+ theme,
|
|
|
+} from "antd";
|
|
|
import { EditOutlined, ReloadOutlined } from "@ant-design/icons";
|
|
|
import { Link } from "react-router";
|
|
|
import { useIntl } from "react-intl";
|
|
|
@@ -39,15 +47,41 @@ interface INissayaCardModal {
|
|
|
trigger?: JSX.Element | string;
|
|
|
}
|
|
|
|
|
|
-export const NissayaCardPop = ({ text, trigger }: INissayaCardModal) => (
|
|
|
- <Popover
|
|
|
- style={{ width: 700 }}
|
|
|
- content={<NissayaCardWidget text={text} cache hideEditButton />}
|
|
|
- placement="bottom"
|
|
|
- >
|
|
|
- <Typography.Link>{trigger}</Typography.Link>
|
|
|
- </Popover>
|
|
|
-);
|
|
|
+export const NissayaCardPop = ({ text, trigger }: INissayaCardModal) => {
|
|
|
+ const intl = useIntl();
|
|
|
+ const { token } = theme.useToken();
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Popover
|
|
|
+ style={{ width: 700 }}
|
|
|
+ title={
|
|
|
+ <div style={{ textAlign: "right" }}>
|
|
|
+ <Link to={`/workspace/nissaya/ending/${text}`} target="_blank">
|
|
|
+ {intl.formatMessage(
|
|
|
+ { id: "buttons.open.in.new.tab" },
|
|
|
+ { item: "" }
|
|
|
+ )}
|
|
|
+ </Link>
|
|
|
+ </div>
|
|
|
+ }
|
|
|
+ content={<NissayaCardWidget text={text} cache hideEditButton />}
|
|
|
+ placement="bottom"
|
|
|
+ // 垂直方向始终贴在锚点下方:不翻转、不平移回视口,宁可超出可视范围也不遮挡锚点;
|
|
|
+ // 横向仍自动适应窗口。autoAdjustOverflow 做不到——antd 在 shiftY 关闭时会
|
|
|
+ // 强制打开 adjustY——所以自己给出 bottom 的对齐规则,offset 同 antd 默认算法
|
|
|
+ builtinPlacements={{
|
|
|
+ bottom: {
|
|
|
+ points: ["tc", "bc"],
|
|
|
+ offset: [0, token.sizePopupArrow / 2 + token.marginXXS],
|
|
|
+ overflow: { adjustX: true, shiftX: true },
|
|
|
+ htmlRegion: "visibleFirst",
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Typography.Link>{trigger}</Typography.Link>
|
|
|
+ </Popover>
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
export const NissayaCardModal = ({ text, trigger }: INissayaCardModal) => {
|
|
|
const [open, setOpen] = useState(false);
|
|
|
@@ -84,7 +118,6 @@ const NissayaCardWidget = ({
|
|
|
cache = false,
|
|
|
hideEditButton = false,
|
|
|
}: IWidgetProps) => {
|
|
|
- const intl = useIntl();
|
|
|
// antd v6: use App.useApp() instead of static message/notification
|
|
|
const { message } = App.useApp();
|
|
|
|
|
|
@@ -171,19 +204,7 @@ const NissayaCardWidget = ({
|
|
|
)}
|
|
|
</Title>
|
|
|
|
|
|
- <div>
|
|
|
- <Link to={`/nissaya/ending/${term?.word}`} target="_blank">
|
|
|
- {intl.formatMessage(
|
|
|
- { id: "buttons.open.in.new.tab" },
|
|
|
- { item: "" }
|
|
|
- )}
|
|
|
- </Link>
|
|
|
- <Button
|
|
|
- type="link"
|
|
|
- icon={<ReloadOutlined />}
|
|
|
- onClick={handleReload}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ <Button type="link" icon={<ReloadOutlined />} onClick={handleReload} />
|
|
|
</div>
|
|
|
|
|
|
<Paragraph>{term?.meaning}</Paragraph>
|