@xiangfa/mindmap 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +74 -6
- package/README.zh-CN.md +74 -6
- package/dist/components/MindMapAIInput.d.ts +13 -0
- package/dist/components/icons.d.ts +4 -0
- package/dist/esm/MindMap2.js +289 -275
- package/dist/esm/components/MindMapAIInput.js +209 -0
- package/dist/esm/components/icons.js +78 -1
- package/dist/esm/hooks/useNodeEdit.js +1 -1
- package/dist/esm/hooks/usePanZoom.js +3 -1
- package/dist/esm/plugins/tags.js +8 -8
- package/dist/esm/style.css +1 -1
- package/dist/esm/utils/i18n.js +6 -0
- package/dist/esm/utils/markdown.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/mindmap.umd.cjs +76 -14
- package/dist/plugins/tags.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/utils/i18n.d.ts +3 -0
- package/package.json +2 -1
- package/dist/esm/logo.svg +0 -9
- package/dist/logo.svg +0 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright [2026] [U14App Team]
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -2,26 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
# Open MindMap
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@xiangfa/mindmap)
|
|
6
|
+
[](https://www.npmjs.com/package/@xiangfa/mindmap)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://react.dev)
|
|
9
|
+
|
|
5
10
|
A beautiful, interactive mind map component for React.
|
|
6
11
|
|
|
7
12
|
**Natively supports AI stream output** with Markdown list syntax and **iOS-style UI**.
|
|
8
13
|
|
|
9
14
|
Zero dependencies. SVG-based. Keyboard-first. Dark mode ready.
|
|
10
15
|
|
|
11
|
-
[](https://www.npmjs.com/package/@xiangfa/mindmap)
|
|
12
|
-
[](https://www.npmjs.com/package/@xiangfa/mindmap)
|
|
13
|
-
[](https://bundlephobia.com/package/@xiangfa/mindmap)
|
|
14
|
-
[](https://github.com/u14app/mindmap/blob/main/LICENSE)
|
|
15
|
-
|
|
16
16
|
English | [中文](README.zh-CN.md)
|
|
17
17
|
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+

|
|
23
|
+
|
|
22
24
|
## Features
|
|
23
25
|
|
|
24
26
|
- **AI stream ready** — natively supports AI streaming output; feed a markdown list in, get a real-time mind map out
|
|
27
|
+
- **Built-in AI generation** — connect any OpenAI-compatible API to generate mind maps from natural language; supports text, image, and PDF attachments
|
|
25
28
|
- **Pure SVG rendering** — no canvas, no external layout engines, razor-sharp at any zoom level
|
|
26
29
|
- **iOS-style UI** — frosted glass controls, rounded corners, smooth animations, clean and polished design
|
|
27
30
|
- **Plugin system** — 7 built-in plugins for extended syntax (dotted lines, folding, multi-line, tags, cross-links, LaTeX, frontmatter); fully extensible
|
|
@@ -237,6 +240,48 @@ function App() {
|
|
|
237
240
|
}
|
|
238
241
|
```
|
|
239
242
|
|
|
243
|
+
### AI Generation
|
|
244
|
+
|
|
245
|
+
Add a built-in AI input bar to generate mind maps from natural language. Connects to any OpenAI-compatible API with streaming support:
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
<MindMap
|
|
249
|
+
ai={{
|
|
250
|
+
apiUrl: "https://api.openai.com/v1/chat/completions",
|
|
251
|
+
apiKey: "sk-...",
|
|
252
|
+
model: "gpt-5",
|
|
253
|
+
}}
|
|
254
|
+
/>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Enable file attachments (text, image, PDF):
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
<MindMap
|
|
261
|
+
ai={{
|
|
262
|
+
apiUrl: "https://api.openai.com/v1/chat/completions",
|
|
263
|
+
apiKey: "sk-...",
|
|
264
|
+
model: "gpt-5",
|
|
265
|
+
attachments: ["text", "image", "pdf"],
|
|
266
|
+
}}
|
|
267
|
+
/>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Customize the system prompt:
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
<MindMap
|
|
274
|
+
ai={{
|
|
275
|
+
apiUrl: "https://api.openai.com/v1/chat/completions",
|
|
276
|
+
apiKey: "sk-...",
|
|
277
|
+
model: "gpt-5",
|
|
278
|
+
systemPrompt: "Generate a mind map about the given topic...",
|
|
279
|
+
}}
|
|
280
|
+
/>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
> **Security Note:** The API key is sent from the browser. For production, use a proxy endpoint to keep your key server-side.
|
|
284
|
+
|
|
240
285
|
### Listening for Changes
|
|
241
286
|
|
|
242
287
|
```tsx
|
|
@@ -405,6 +450,7 @@ Render mathematical formulas (requires [KaTeX](https://katex.org/)):
|
|
|
405
450
|
| `messages` | `Partial<MindMapMessages>` | - | Override any UI text string |
|
|
406
451
|
| `readonly` | `boolean` | `false` | Display-only mode (no editing, no creating) |
|
|
407
452
|
| `toolbar` | `boolean \| ToolbarConfig` | `true` | Show/hide zoom controls |
|
|
453
|
+
| `ai` | `MindMapAIConfig` | - | AI generation configuration (API endpoint, key, model, attachments) |
|
|
408
454
|
| `plugins` | `MindMapPlugin[]` | `allPlugins` | Plugins to enable for extended syntax |
|
|
409
455
|
| `onDataChange` | `(data: MindMapData[]) => void` | - | Called when the tree is modified by user interaction |
|
|
410
456
|
|
|
@@ -416,6 +462,28 @@ interface ToolbarConfig {
|
|
|
416
462
|
}
|
|
417
463
|
```
|
|
418
464
|
|
|
465
|
+
### MindMapAIConfig
|
|
466
|
+
|
|
467
|
+
```ts
|
|
468
|
+
type AIAttachmentType = "text" | "image" | "pdf";
|
|
469
|
+
|
|
470
|
+
interface MindMapAIConfig {
|
|
471
|
+
apiUrl: string; // OpenAI-compatible API endpoint
|
|
472
|
+
apiKey: string; // API key (Bearer token)
|
|
473
|
+
model: string; // Model name (e.g., "gpt-5")
|
|
474
|
+
systemPrompt?: string; // Custom system prompt (has a built-in default)
|
|
475
|
+
attachments?: AIAttachmentType[]; // Allowed attachment types (default: [])
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
| Field | Type | Required | Description |
|
|
480
|
+
| -------------- | -------------------- | -------- | ---------------------------------------------------------------------------------------- |
|
|
481
|
+
| `apiUrl` | `string` | Yes | OpenAI-compatible chat completions endpoint |
|
|
482
|
+
| `apiKey` | `string` | Yes | API key sent as `Bearer` token |
|
|
483
|
+
| `model` | `string` | Yes | Model identifier (e.g., `gpt-5`, `deepseek-chat`) |
|
|
484
|
+
| `systemPrompt` | `string` | No | Override the built-in mind map generation prompt |
|
|
485
|
+
| `attachments` | `AIAttachmentType[]` | No | Enable file uploads: `"text"` (text/\*), `"image"` (image/\*), `"pdf"` (application/pdf) |
|
|
486
|
+
|
|
419
487
|
### Ref Methods
|
|
420
488
|
|
|
421
489
|
| Method | Returns | Description |
|
|
@@ -531,4 +599,4 @@ Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md)
|
|
|
531
599
|
|
|
532
600
|
## License
|
|
533
601
|
|
|
534
|
-
[
|
|
602
|
+
[Apache-2.0](LICENSE)
|
package/README.zh-CN.md
CHANGED
|
@@ -2,26 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
# Open MindMap
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@xiangfa/mindmap)
|
|
6
|
+
[](https://www.npmjs.com/package/@xiangfa/mindmap)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://react.dev)
|
|
9
|
+
|
|
5
10
|
一个精美的 React 交互式思维导图组件。
|
|
6
11
|
|
|
7
12
|
**原生支持 AI 流式输出**,使用 Markdown 列表语法,搭配 **iOS 风格 UI**。
|
|
8
13
|
|
|
9
14
|
零依赖。基于 SVG。键盘优先。支持暗色模式。
|
|
10
15
|
|
|
11
|
-
[](https://www.npmjs.com/package/@xiangfa/mindmap)
|
|
12
|
-
[](https://www.npmjs.com/package/@xiangfa/mindmap)
|
|
13
|
-
[](https://bundlephobia.com/package/@xiangfa/mindmap)
|
|
14
|
-
[](https://github.com/u14app/mindmap/blob/main/LICENSE)
|
|
15
|
-
|
|
16
16
|
[English](README.md) | 中文
|
|
17
17
|
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+

|
|
23
|
+
|
|
22
24
|
## 特性
|
|
23
25
|
|
|
24
26
|
- **AI 流式输出** — 原生支持 AI 流式输出;输入 Markdown 列表,实时生成思维导图
|
|
27
|
+
- **内置 AI 生成** — 连接任意 OpenAI 兼容 API,通过自然语言生成思维导图;支持文本、图片和 PDF 附件上传
|
|
25
28
|
- **纯 SVG 渲染** — 无 Canvas、无外部布局引擎,任意缩放级别下都清晰锐利
|
|
26
29
|
- **iOS 风格 UI** — 毛玻璃控件、圆角设计、流畅动画,简洁精致
|
|
27
30
|
- **插件系统** — 7 个内置插件扩展语法(虚线、折叠、多行、标签、跨链接、LaTeX、frontmatter);完全可扩展
|
|
@@ -237,6 +240,48 @@ function App() {
|
|
|
237
240
|
}
|
|
238
241
|
```
|
|
239
242
|
|
|
243
|
+
### AI 生成
|
|
244
|
+
|
|
245
|
+
添加内置 AI 输入栏,通过自然语言生成思维导图。支持连接任意 OpenAI 兼容 API 并流式输出:
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
<MindMap
|
|
249
|
+
ai={{
|
|
250
|
+
apiUrl: "https://api.openai.com/v1/chat/completions",
|
|
251
|
+
apiKey: "sk-...",
|
|
252
|
+
model: "gpt-5",
|
|
253
|
+
}}
|
|
254
|
+
/>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
启用附件上传(文本、图片、PDF):
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
<MindMap
|
|
261
|
+
ai={{
|
|
262
|
+
apiUrl: "https://api.openai.com/v1/chat/completions",
|
|
263
|
+
apiKey: "sk-...",
|
|
264
|
+
model: "gpt-5",
|
|
265
|
+
attachments: ["text", "image", "pdf"],
|
|
266
|
+
}}
|
|
267
|
+
/>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
自定义系统提示词:
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
<MindMap
|
|
274
|
+
ai={{
|
|
275
|
+
apiUrl: "https://api.openai.com/v1/chat/completions",
|
|
276
|
+
apiKey: "sk-...",
|
|
277
|
+
model: "gpt-5",
|
|
278
|
+
systemPrompt: "根据给定的主题生成思维导图...",
|
|
279
|
+
}}
|
|
280
|
+
/>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
> **安全提示:** API 密钥会从浏览器发送。生产环境中建议使用代理端点来保护密钥安全。
|
|
284
|
+
|
|
240
285
|
### 监听变更
|
|
241
286
|
|
|
242
287
|
```tsx
|
|
@@ -405,6 +450,7 @@ theme: dark
|
|
|
405
450
|
| `messages` | `Partial<MindMapMessages>` | - | 覆盖任意 UI 文本字符串 |
|
|
406
451
|
| `readonly` | `boolean` | `false` | 仅显示模式(不可编辑、不可创建) |
|
|
407
452
|
| `toolbar` | `boolean \| ToolbarConfig` | `true` | 显示/隐藏缩放控件 |
|
|
453
|
+
| `ai` | `MindMapAIConfig` | - | AI 生成配置(API 地址、密钥、模型、附件类型) |
|
|
408
454
|
| `plugins` | `MindMapPlugin[]` | `allPlugins` | 启用的扩展语法插件 |
|
|
409
455
|
| `onDataChange` | `(data: MindMapData[]) => void` | - | 用户交互修改树时调用 |
|
|
410
456
|
|
|
@@ -416,6 +462,28 @@ interface ToolbarConfig {
|
|
|
416
462
|
}
|
|
417
463
|
```
|
|
418
464
|
|
|
465
|
+
### MindMapAIConfig
|
|
466
|
+
|
|
467
|
+
```ts
|
|
468
|
+
type AIAttachmentType = "text" | "image" | "pdf";
|
|
469
|
+
|
|
470
|
+
interface MindMapAIConfig {
|
|
471
|
+
apiUrl: string; // OpenAI 兼容 API 端点
|
|
472
|
+
apiKey: string; // API 密钥(Bearer token)
|
|
473
|
+
model: string; // 模型名称(如 "gpt-5")
|
|
474
|
+
systemPrompt?: string; // 自定义系统提示词(内置默认值)
|
|
475
|
+
attachments?: AIAttachmentType[]; // 允许的附件类型(默认:[])
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
| 字段 | 类型 | 必填 | 说明 |
|
|
480
|
+
| -------------- | -------------------- | ---- | ------------------------------------------------------------------------------------ |
|
|
481
|
+
| `apiUrl` | `string` | 是 | OpenAI 兼容的 chat completions 端点 |
|
|
482
|
+
| `apiKey` | `string` | 是 | API 密钥,作为 `Bearer` token 发送 |
|
|
483
|
+
| `model` | `string` | 是 | 模型标识符(如 `gpt-5`、`deepseek-chat`) |
|
|
484
|
+
| `systemPrompt` | `string` | 否 | 覆盖内置的思维导图生成提示词 |
|
|
485
|
+
| `attachments` | `AIAttachmentType[]` | 否 | 启用文件上传:`"text"`(text/\*)、`"image"`(image/\*)、`"pdf"`(application/pdf) |
|
|
486
|
+
|
|
419
487
|
### Ref 方法
|
|
420
488
|
|
|
421
489
|
| 方法 | 返回值 | 说明 |
|
|
@@ -531,4 +599,4 @@ pnpm lint # 运行代码检查
|
|
|
531
599
|
|
|
532
600
|
## 许可证
|
|
533
601
|
|
|
534
|
-
[
|
|
602
|
+
[Apache-2.0](LICENSE)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MindMapAIConfig } from "../types";
|
|
2
|
+
import type { ThemeColors } from "../utils/theme";
|
|
3
|
+
import type { MindMapMessages } from "../utils/i18n";
|
|
4
|
+
export interface MindMapAIInputProps {
|
|
5
|
+
config: MindMapAIConfig;
|
|
6
|
+
theme: ThemeColors;
|
|
7
|
+
messages: MindMapMessages;
|
|
8
|
+
currentMarkdown?: string;
|
|
9
|
+
onMarkdownStream: (markdown: string) => void;
|
|
10
|
+
onComplete: () => void;
|
|
11
|
+
onError: (error: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function MindMapAIInput({ config, theme, messages, currentMarkdown, onMarkdownStream, onComplete, onError, }: MindMapAIInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,4 +5,8 @@ interface IconProps {
|
|
|
5
5
|
export declare function IconPlus({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export declare function IconMinus({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare function IconClose({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function IconLightning({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function IconPaperclip({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function IconStop({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function IconLoaderCircle({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
8
12
|
export {};
|