Skip to content

Commit 3b71a3e

Browse files
committed
feat: enhance type definitions and documentation for Arrow and Summary interfaces
1 parent 2edcf9c commit 3b71a3e

File tree

4 files changed

+47
-14
lines changed

4 files changed

+47
-14
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/arrow.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,37 @@ import { createSvgGroup, editSvgText } from './utils/svg'
55
import type { CustomSvg, Topic } from './types/dom'
66
import type { MindElixirInstance, Uid } from './index'
77

8-
/**
9-
* FYI
10-
* p1: starting point
11-
* p2: control point of starting point
12-
* p3: control point of ending point
13-
* p4: ending point
14-
*/
15-
16-
export type Arrow = {
8+
export interface Arrow {
179
id: string
10+
/**
11+
* label of arrow
12+
*/
1813
label: string
14+
/**
15+
* id of start node
16+
*/
1917
from: Uid
18+
/**
19+
* id of end node
20+
*/
2021
to: Uid
22+
/**
23+
* offset of control point from start point
24+
*/
2125
delta1: {
2226
x: number
2327
y: number
2428
}
29+
/**
30+
* offset of control point from end point
31+
*/
2532
delta2: {
2633
x: number
2734
y: number
2835
}
36+
/**
37+
* whether the arrow is bidirectional
38+
*/
2939
bidirectional?: boolean
3040
}
3141
export type DivData = {
@@ -62,7 +72,7 @@ function calcCtrlP(mei: MindElixirInstance, tpc: Topic, delta: { x: number; y: n
6272
}
6373

6474
/**
65-
* calc starting and ending point using control point and div status
75+
* calc start and end point using control point and div status
6676
*/
6777
function calcP(data: DivData) {
6878
let x, y
@@ -103,6 +113,13 @@ const createText = function (string: string, x: number, y: number, color?: strin
103113
return text
104114
}
105115

116+
/**
117+
* FYI
118+
* p1: start point
119+
* p2: control point of start point
120+
* p3: control point of end point
121+
* p4: end point
122+
*/
106123
const drawArrow = function (mei: MindElixirInstance, from: Topic, to: Topic, obj: Arrow, isInitPaint?: boolean) {
107124
if (!from || !to) {
108125
return // not expand

src/i18n.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ type LangPack = {
1111
clickTips: string
1212
summary: string
1313
}
14+
15+
/**
16+
* @public
17+
*/
1418
export type Locale = 'cn' | 'zh_CN' | 'zh_TW' | 'en' | 'ru' | 'ja' | 'pt' | 'it' | 'es' | 'fr' | 'ko'
1519
const cn = {
1620
addChild: '插入子节点',

src/summary.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@ import { generateUUID, getOffsetLT, setAttributes } from './utils'
44
import { findEle } from './utils/dom'
55
import { editSvgText } from './utils/svg'
66

7-
export type Summary = {
7+
/**
8+
* @public
9+
*/
10+
export interface Summary {
811
id: string
912
text: string
13+
/**
14+
* parent node id of the summary
15+
*/
1016
parent: string
17+
/**
18+
* start index of the summary
19+
*/
1120
start: number
21+
/**
22+
* end index of the summary
23+
*/
1224
end: number
1325
}
1426

0 commit comments

Comments
 (0)