flow-mindmap 0.2.0 → 0.2.2
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/README.md +337 -337
- package/dist/components/MindMap.vue.d.ts +9 -1
- package/dist/components/NodeContextMenu.vue.d.ts +21 -0
- package/dist/components/NotePanel.vue.d.ts +14 -0
- package/dist/composables/useAutosize.d.ts +21 -0
- package/dist/composables/useMarkdown.d.ts +6 -0
- package/dist/composables/useRichContent.d.ts +29 -0
- package/dist/core/layout.d.ts +23 -0
- package/dist/flow-mindmap.js +7896 -1523
- package/dist/flow-mindmap.umd.cjs +22 -16
- package/dist/style.css +10 -1
- package/dist/types.d.ts +20 -0
- package/package.json +8 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MindMapNode, MindMapTheme, MindMapSettings, NodeStyle } from '../types';
|
|
1
|
+
import type { MindMapNode, MindMapTheme, MindMapSettings, NodeStyle, MindMapImage } from '../types';
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
data: MindMapNode;
|
|
4
4
|
readonly?: boolean;
|
|
@@ -54,6 +54,14 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {
|
|
|
54
54
|
removeNodeLink: (nodeId: string) => void;
|
|
55
55
|
applyNodeNote: (nodeId: string, text: string) => void;
|
|
56
56
|
removeNodeNote: (nodeId: string) => void;
|
|
57
|
+
applyNodeImageByUrl: (nodeId: string, url: string) => void;
|
|
58
|
+
applyNodeImage: (nodeId: string, image: MindMapImage) => void;
|
|
59
|
+
removeNodeImage: (nodeId: string) => void;
|
|
60
|
+
applyNodeRichContent: (nodeId: string, content: {
|
|
61
|
+
kind: "code" | "table";
|
|
62
|
+
raw: string;
|
|
63
|
+
lang?: string;
|
|
64
|
+
} | null) => void;
|
|
57
65
|
undo: () => void;
|
|
58
66
|
redo: () => void;
|
|
59
67
|
canUndo: () => boolean;
|
|
@@ -17,6 +17,13 @@ type __VLS_Props = {
|
|
|
17
17
|
/** Whether the node already has a note. Same role as
|
|
18
18
|
* hasLink for the note action. */
|
|
19
19
|
hasNote?: boolean;
|
|
20
|
+
/** Whether the node already has a code block in its
|
|
21
|
+
* richContent. Drives the code-block action's label and
|
|
22
|
+
* whether a "移除代码块" sub-action shows. */
|
|
23
|
+
hasCode?: boolean;
|
|
24
|
+
/** Whether the node already has a table in its richContent.
|
|
25
|
+
* Same role as hasCode for the table action. */
|
|
26
|
+
hasTable?: boolean;
|
|
20
27
|
/** True if the component is in readonly mode — all actions
|
|
21
28
|
* render but are disabled. */
|
|
22
29
|
readonly?: boolean;
|
|
@@ -29,6 +36,12 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
29
36
|
editNote: () => any;
|
|
30
37
|
removeNote: () => any;
|
|
31
38
|
removeImage: () => any;
|
|
39
|
+
addCode: () => any;
|
|
40
|
+
editCode: () => any;
|
|
41
|
+
removeCode: () => any;
|
|
42
|
+
addTable: () => any;
|
|
43
|
+
editTable: () => any;
|
|
44
|
+
removeTable: () => any;
|
|
32
45
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
33
46
|
onClose?: (() => any) | undefined;
|
|
34
47
|
onPickImage?: (() => any) | undefined;
|
|
@@ -37,10 +50,18 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
37
50
|
onEditNote?: (() => any) | undefined;
|
|
38
51
|
onRemoveNote?: (() => any) | undefined;
|
|
39
52
|
onRemoveImage?: (() => any) | undefined;
|
|
53
|
+
onAddCode?: (() => any) | undefined;
|
|
54
|
+
onEditCode?: (() => any) | undefined;
|
|
55
|
+
onRemoveCode?: (() => any) | undefined;
|
|
56
|
+
onAddTable?: (() => any) | undefined;
|
|
57
|
+
onEditTable?: (() => any) | undefined;
|
|
58
|
+
onRemoveTable?: (() => any) | undefined;
|
|
40
59
|
}>, {
|
|
41
60
|
hasImage: boolean;
|
|
42
61
|
hasLink: boolean;
|
|
43
62
|
hasNote: boolean;
|
|
63
|
+
hasCode: boolean;
|
|
64
|
+
hasTable: boolean;
|
|
44
65
|
readonly: boolean;
|
|
45
66
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
46
67
|
export default _default;
|
|
@@ -11,10 +11,24 @@ type __VLS_Props = {
|
|
|
11
11
|
focusTick?: number;
|
|
12
12
|
};
|
|
13
13
|
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
14
|
+
"set-link": (url: string) => any;
|
|
14
15
|
apply: (text: string) => any;
|
|
15
16
|
remove: () => any;
|
|
17
|
+
"set-image": (src: string) => any;
|
|
18
|
+
"set-rich": (payload: {
|
|
19
|
+
kind: "code" | "table";
|
|
20
|
+
raw: string;
|
|
21
|
+
lang?: string;
|
|
22
|
+
} | null) => any;
|
|
16
23
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
24
|
+
"onSet-link"?: ((url: string) => any) | undefined;
|
|
17
25
|
onApply?: ((text: string) => any) | undefined;
|
|
18
26
|
onRemove?: (() => any) | undefined;
|
|
27
|
+
"onSet-image"?: ((src: string) => any) | undefined;
|
|
28
|
+
"onSet-rich"?: ((payload: {
|
|
29
|
+
kind: "code" | "table";
|
|
30
|
+
raw: string;
|
|
31
|
+
lang?: string;
|
|
32
|
+
} | null) => any) | undefined;
|
|
19
33
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
34
|
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny autosize helper for textareas. Usage:
|
|
3
|
+
*
|
|
4
|
+
* const taRef = ref<HTMLTextAreaElement | null>(null)
|
|
5
|
+
* useAutosize(taRef, { minRows: 4, maxRows: 12 })
|
|
6
|
+
*
|
|
7
|
+
* The composable listens to the textarea's `input` event, sets
|
|
8
|
+
* its height to its scrollHeight (clamped to the row range), and
|
|
9
|
+
* also re-runs when the bound value changes from outside so a
|
|
10
|
+
* parent that resets `.value` (e.g. on node switch) still sizes
|
|
11
|
+
* correctly.
|
|
12
|
+
*/
|
|
13
|
+
import { type Ref } from 'vue';
|
|
14
|
+
export interface AutosizeOptions {
|
|
15
|
+
/** Minimum visible rows when the textarea is empty. Default 3. */
|
|
16
|
+
minRows?: number;
|
|
17
|
+
/** Maximum visible rows before the textarea starts scrolling.
|
|
18
|
+
* Default 12. Set to 0 for "no cap". */
|
|
19
|
+
maxRows?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function useAutosize(refEl: Ref<HTMLTextAreaElement | null>, options?: AutosizeOptions): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Strip the opening and closing ``` fences from a code block,
|
|
2
|
+
* returning just the body. Handles both ``` and ~~~ markers. */
|
|
3
|
+
export declare function stripCodeFence(raw: string): string;
|
|
4
|
+
/** Detect the info-string from the opening fence. Returns an
|
|
5
|
+
* empty string when the block has no fence or the language
|
|
6
|
+
* isn't one of our registered ones (so callers can fall back
|
|
7
|
+
* to a plain `<pre>`). */
|
|
8
|
+
export declare function codeLang(raw: string): string;
|
|
9
|
+
/** Run highlight.js on a code body and return sanitized HTML.
|
|
10
|
+
* Falls back to an escaped plain-text version when the language
|
|
11
|
+
* isn't registered — never throws. `body` should already be
|
|
12
|
+
* fence-stripped (see `stripCodeFence`). */
|
|
13
|
+
export declare function highlightCode(body: string, lang: string): string;
|
|
14
|
+
/** Split a pipe-delimited table into rows of cells, dropping the
|
|
15
|
+
* alignment separator row. Each inner array is the cells of one
|
|
16
|
+
* row. The first row is conventionally the header. */
|
|
17
|
+
export declare function tableRows(raw: string): string[][];
|
|
18
|
+
/** Re-join a 2-D cell array into pipe-delimited markdown. Used
|
|
19
|
+
* when the user edits a table in CSV/textarea form and we need
|
|
20
|
+
* to push it back into `richContent.raw`. */
|
|
21
|
+
export declare function rowsToTable(rows: string[][]): string;
|
|
22
|
+
/** Sort a 2-D cell array in place around a chosen column. The
|
|
23
|
+
* first row is the header and stays pinned at the top.
|
|
24
|
+
* Direction is `'asc'` | `'desc'`. When every value in the
|
|
25
|
+
* column parses as a finite number the sort is numeric,
|
|
26
|
+
* otherwise lexical (locale-aware). Stable across equal keys.
|
|
27
|
+
* Doesn't mutate the input. */
|
|
28
|
+
export type SortDir = 'asc' | 'desc';
|
|
29
|
+
export declare function sortTable(rows: string[][], col: number, dir: SortDir): string[][];
|
package/dist/core/layout.d.ts
CHANGED
|
@@ -50,6 +50,15 @@ export interface LayoutNode {
|
|
|
50
50
|
* only — the default behaviour, unchanged from before this
|
|
51
51
|
* field was introduced. */
|
|
52
52
|
richContent?: RichContent;
|
|
53
|
+
/** Inset (px) the SVG edge anchor should retreat from the
|
|
54
|
+
* geometric box edge on the in-side, to land at the visible
|
|
55
|
+
* content edge instead. Set to `.zm-node` padding +
|
|
56
|
+
* `.zm-rich` padding + 2 for code/table nodes (their visible
|
|
57
|
+
* content sits well inside the box); 0 for plain nodes (the
|
|
58
|
+
* geometric edge IS the visible edge). Used by lineAnchor
|
|
59
|
+
* in MindMap.vue — non-zero for nodes whose first child of
|
|
60
|
+
* the line would otherwise appear to pierce the rich body. */
|
|
61
|
+
_richInsetX?: number;
|
|
53
62
|
children: LayoutNode[];
|
|
54
63
|
parent: LayoutNode | null;
|
|
55
64
|
}
|
|
@@ -91,6 +100,20 @@ export interface LayoutOptions {
|
|
|
91
100
|
* position since their LayoutNode has x = 0, y = 0.
|
|
92
101
|
*/
|
|
93
102
|
preservePositions?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Per-node measured size of the rendered rich body (the
|
|
105
|
+
* `<div class="zm-rich">` element above the title), in px. The
|
|
106
|
+
* caller (MindMap.vue) populates this after each render with
|
|
107
|
+
* `el.offsetWidth` / `el.offsetHeight`; layout reads it for
|
|
108
|
+
* nodes that carry code / table rich content. When a node has
|
|
109
|
+
* a measured size we use it directly so the box grows /
|
|
110
|
+
* shrinks to fit the content. When the caller hasn't
|
|
111
|
+
* measured a node yet we fall back to the fixed floor / cap.
|
|
112
|
+
* IDs not present in the map are simply ignored — useful for
|
|
113
|
+
* the very first render before measurement has happened.
|
|
114
|
+
*/
|
|
115
|
+
richHeights?: Record<string, number>;
|
|
116
|
+
richWidths?: Record<string, number>;
|
|
94
117
|
}
|
|
95
118
|
export declare function layout(root: MindMapNode, options?: LayoutOptions): {
|
|
96
119
|
root: LayoutNode;
|