新增图标
This commit is contained in:
@@ -13,6 +13,10 @@ import { MindmapNavigator } from "./MindmapNavigator";
|
||||
import { MindmapMiniMap } from "./MindmapMiniMap";
|
||||
import { MindmapCount } from "./MindmapCount";
|
||||
import type { SidebarPanel } from "./mindmapSidebarConfig";
|
||||
import iconConfig from "./mindmapIconConfig";
|
||||
import { nodeIconList } from "simple-mind-map/src/svg/icons.js";
|
||||
// @ts-expect-error 第三方库缺少类型定义
|
||||
import { mergerIconList } from "simple-mind-map/src/utils/index.js";
|
||||
|
||||
type MindMapInstance = {
|
||||
execCommand: (...args: unknown[]) => void;
|
||||
@@ -121,6 +125,8 @@ const MindmapBlockView = ({
|
||||
const [painterMode, setPainterMode] = useState(false);
|
||||
const [showMiniMap, setShowMiniMap] = useState(false);
|
||||
const [activeSidebar, setActiveSidebar] = useState<SidebarPanel | null>(null);
|
||||
const [showNoteModal, setShowNoteModal] = useState(false);
|
||||
const [noteContent, setNoteContent] = useState("");
|
||||
|
||||
const getRootNode = useCallback((mm?: MindMapInstance | null) => {
|
||||
const instance = mm ?? mindmap;
|
||||
@@ -234,6 +240,11 @@ const MindmapBlockView = ({
|
||||
enableCtrlKeyNodeSelection: true,
|
||||
fit: true,
|
||||
useLeftKeySelectionRightKeyDrag: true,
|
||||
// 传入扩展图标表,和官方一致
|
||||
iconList: mergerIconList([
|
||||
...nodeIconList,
|
||||
...(iconConfig as unknown[]),
|
||||
]),
|
||||
}) as MindMapInstance;
|
||||
instance.setMode?.("edit");
|
||||
|
||||
@@ -355,7 +366,7 @@ const MindmapBlockView = ({
|
||||
};
|
||||
|
||||
const handleNote = () => {
|
||||
setActiveSidebar("note");
|
||||
setShowNoteModal(true);
|
||||
};
|
||||
|
||||
const handleTag = () => {
|
||||
@@ -369,6 +380,13 @@ const MindmapBlockView = ({
|
||||
setActiveSidebar("formula");
|
||||
};
|
||||
|
||||
const handleNoteConfirm = () => {
|
||||
const note = noteContent.trim();
|
||||
setShowNoteModal(false);
|
||||
if (!note) return;
|
||||
applyToActiveNodes(mindmap, (node) => mindmap?.execCommand("SET_NODE_NOTE", node, note));
|
||||
};
|
||||
|
||||
const handleAttachment = () => {
|
||||
const url = createSimplePrompt("附件链接(http/https)");
|
||||
if (!url) return;
|
||||
@@ -469,9 +487,44 @@ const MindmapBlockView = ({
|
||||
fileInputRef,
|
||||
};
|
||||
|
||||
const noteModal = showNoteModal ? (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4">
|
||||
<div className="w-full max-w-4xl rounded-xl bg-white shadow-2xl">
|
||||
<div className="flex items-center justify-between border-b px-4 py-3">
|
||||
<span className="text-lg font-semibold text-gray-800">备注</span>
|
||||
<button className="text-gray-400 hover:text-gray-600" onClick={() => setShowNoteModal(false)}>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<div className="px-4 py-3">
|
||||
<textarea
|
||||
className="h-64 w-full resize-none rounded-md border border-gray-200 p-3 text-sm focus:border-blue-400 focus:outline-none"
|
||||
placeholder="支持富文本/Markdown,内容将写入节点备注"
|
||||
value={noteContent}
|
||||
onChange={(e) => setNoteContent(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center justify-end gap-3 border-t px-4 py-3">
|
||||
<button
|
||||
className="rounded-md border border-gray-200 px-4 py-2 text-sm text-gray-600 hover:bg-gray-50"
|
||||
onClick={() => setShowNoteModal(false)}
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
className="rounded-md bg-blue-500 px-4 py-2 text-sm text-white hover:bg-blue-600"
|
||||
onClick={handleNoteConfirm}
|
||||
>
|
||||
确定
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null;
|
||||
|
||||
if (fullscreen) {
|
||||
return (
|
||||
<div className="relative h-screen w-screen overflow-hidden bg-white">
|
||||
<div className="relative h-screen w-screen overflow-hidden bg-white">
|
||||
<div className="fixed left-1/2 top-4 z-20 flex w-fit -translate-x-1/2 transform items-center justify-center gap-4">
|
||||
<MindmapToolbar {...toolbarProps} />
|
||||
</div>
|
||||
@@ -498,6 +551,7 @@ const MindmapBlockView = ({
|
||||
<MindmapCount mindmap={mindmap} />
|
||||
{/* @ts-expect-error mindmap type */}
|
||||
<MindmapMiniMap mindmap={mindmap} show={showMiniMap} />
|
||||
{noteModal}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -533,6 +587,7 @@ const MindmapBlockView = ({
|
||||
<MindmapCount mindmap={mindmap} />
|
||||
{/* @ts-expect-error mindmap type */}
|
||||
<MindmapMiniMap mindmap={mindmap} show={showMiniMap} />
|
||||
{noteModal}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user