markmap-view-plus 0.0.1
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 +20 -0
- package/dist/action.d.ts +110 -0
- package/dist/browser/index.js +2159 -0
- package/dist/constants.d.ts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1506 -0
- package/dist/to-markdown.d.ts +34 -0
- package/dist/types.d.ts +73 -0
- package/dist/util.d.ts +7 -0
- package/dist/view.d.ts +94 -0
- package/package.json +54 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IPureNode } from 'markmap-common';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a single HTML inline-content string to Markdown text.
|
|
4
|
+
* Handles common inline elements produced by markdown-it:
|
|
5
|
+
* strong, em, del/s, code, a, img, br, and HTML entities.
|
|
6
|
+
*/
|
|
7
|
+
export declare function htmlInlineToMarkdown(html: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Serialize an `IPureNode` tree back to a Markdown string.
|
|
10
|
+
*
|
|
11
|
+
* This is the conceptual inverse of `Transformer.transform()`.
|
|
12
|
+
* The algorithm maps tree depth to Markdown heading levels:
|
|
13
|
+
*
|
|
14
|
+
* - depth 0 → `# text`
|
|
15
|
+
* - depth 1 → `## text`
|
|
16
|
+
* - depth 2 → `### text`
|
|
17
|
+
* - depth 3+ → `- text` (indented list items, 2 spaces per extra level)
|
|
18
|
+
*
|
|
19
|
+
* A blank line is inserted between heading-level siblings to keep the
|
|
20
|
+
* output readable and round-trip-stable through `transform()`.
|
|
21
|
+
*
|
|
22
|
+
* @param root Root node of the markmap tree (e.g. from `mm.getData(true)`).
|
|
23
|
+
* @returns Markdown string.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { toMarkdown } from 'markmap-lib';
|
|
28
|
+
*
|
|
29
|
+
* const pureNode = mm.getData(true); // IPureNode
|
|
30
|
+
* const markdown = toMarkdown(pureNode);
|
|
31
|
+
* console.log(markdown);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function toMarkdown(root: IPureNode): string;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { INode, IPureNode } from 'markmap-common';
|
|
2
|
+
export interface IMarkmapState {
|
|
3
|
+
id: string;
|
|
4
|
+
data?: INode;
|
|
5
|
+
highlight?: INode;
|
|
6
|
+
rect: {
|
|
7
|
+
x1: number;
|
|
8
|
+
x2: number;
|
|
9
|
+
y1: number;
|
|
10
|
+
y2: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Portable options that can be derived into `IMarkmapOptions`.
|
|
15
|
+
*/
|
|
16
|
+
export interface IMarkmapJSONOptions {
|
|
17
|
+
color: string[];
|
|
18
|
+
colorFreezeLevel: number;
|
|
19
|
+
duration: number;
|
|
20
|
+
extraCss: string[];
|
|
21
|
+
extraJs: string[];
|
|
22
|
+
fitRatio: number;
|
|
23
|
+
initialExpandLevel: number;
|
|
24
|
+
maxInitialScale: number;
|
|
25
|
+
maxWidth: number;
|
|
26
|
+
nodeMinHeight: number;
|
|
27
|
+
paddingX: number;
|
|
28
|
+
pan: boolean;
|
|
29
|
+
spacingHorizontal: number;
|
|
30
|
+
spacingVertical: number;
|
|
31
|
+
zoom: boolean;
|
|
32
|
+
lineWidth: number | number[];
|
|
33
|
+
}
|
|
34
|
+
export type IMarkmapMode = 'display' | 'editable';
|
|
35
|
+
export interface IMarkmapOptions {
|
|
36
|
+
autoFit: boolean;
|
|
37
|
+
duration: number;
|
|
38
|
+
embedGlobalCSS: boolean;
|
|
39
|
+
fitRatio: number;
|
|
40
|
+
id?: string;
|
|
41
|
+
initialExpandLevel: number;
|
|
42
|
+
maxInitialScale: number;
|
|
43
|
+
pan: boolean;
|
|
44
|
+
scrollForPan: boolean;
|
|
45
|
+
style?: (id: string) => string;
|
|
46
|
+
toggleRecursively: boolean;
|
|
47
|
+
zoom: boolean;
|
|
48
|
+
/** Preset shortcut: 'display' sets all interactive options to false; 'editable' sets them all to true. */
|
|
49
|
+
mode?: IMarkmapMode;
|
|
50
|
+
editable: boolean;
|
|
51
|
+
addable: boolean;
|
|
52
|
+
deletable: boolean;
|
|
53
|
+
collapseOnHover: boolean;
|
|
54
|
+
hoverBorder: boolean;
|
|
55
|
+
clickBorder: boolean;
|
|
56
|
+
onNodeEdit?: (node: INode, newContent: string) => void;
|
|
57
|
+
onNodeAdd?: (parent: INode, child: IPureNode) => void;
|
|
58
|
+
inputPlaceholder: string;
|
|
59
|
+
color: (node: INode) => string;
|
|
60
|
+
lineWidth: (node: INode) => number;
|
|
61
|
+
maxWidth: number;
|
|
62
|
+
nodeMinHeight: number;
|
|
63
|
+
paddingX: number;
|
|
64
|
+
spacingHorizontal: number;
|
|
65
|
+
spacingVertical: number;
|
|
66
|
+
}
|
|
67
|
+
export interface IPadding {
|
|
68
|
+
left: number;
|
|
69
|
+
right: number;
|
|
70
|
+
top: number;
|
|
71
|
+
bottom: number;
|
|
72
|
+
}
|
|
73
|
+
export type ID3SVGElement = d3.Selection<SVGElement, INode, HTMLElement, INode>;
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IMarkmapJSONOptions, IMarkmapOptions } from './types';
|
|
2
|
+
export declare function deriveOptions(jsonOptions?: Partial<IMarkmapJSONOptions>): Partial<IMarkmapOptions>;
|
|
3
|
+
/**
|
|
4
|
+
* Credit: https://gist.github.com/jlevy/c246006675becc446360a798e2b2d781?permalink_comment_id=4738050#gistcomment-4738050
|
|
5
|
+
*/
|
|
6
|
+
export declare function simpleHash(str: string): string;
|
|
7
|
+
export declare function childSelector<T extends Element>(filter?: string | ((el: T) => boolean)): () => T[];
|
package/dist/view.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type * as d3 from 'd3';
|
|
2
|
+
import { Hook, INode, IPureNode } from 'markmap-common';
|
|
3
|
+
import { ID3SVGElement, IMarkmapOptions, IMarkmapState, IPadding } from './types';
|
|
4
|
+
export declare const globalCSS: string;
|
|
5
|
+
/**
|
|
6
|
+
* A global hook to refresh all markmaps when called.
|
|
7
|
+
*/
|
|
8
|
+
export declare const refreshHook: Hook<[]>;
|
|
9
|
+
export declare class Markmap {
|
|
10
|
+
options: {
|
|
11
|
+
autoFit: boolean;
|
|
12
|
+
duration: number;
|
|
13
|
+
embedGlobalCSS: boolean;
|
|
14
|
+
fitRatio: number;
|
|
15
|
+
id?: string;
|
|
16
|
+
initialExpandLevel: number;
|
|
17
|
+
maxInitialScale: number;
|
|
18
|
+
pan: boolean;
|
|
19
|
+
scrollForPan: boolean;
|
|
20
|
+
style?: (id: string) => string;
|
|
21
|
+
toggleRecursively: boolean;
|
|
22
|
+
zoom: boolean;
|
|
23
|
+
mode?: import("./types").IMarkmapMode;
|
|
24
|
+
editable: boolean;
|
|
25
|
+
addable: boolean;
|
|
26
|
+
deletable: boolean;
|
|
27
|
+
collapseOnHover: boolean;
|
|
28
|
+
hoverBorder: boolean;
|
|
29
|
+
clickBorder: boolean;
|
|
30
|
+
onNodeEdit?: (node: INode, newContent: string) => void;
|
|
31
|
+
onNodeAdd?: (parent: INode, child: IPureNode) => void;
|
|
32
|
+
inputPlaceholder: string;
|
|
33
|
+
color: (node: INode) => string;
|
|
34
|
+
lineWidth: (node: INode) => number;
|
|
35
|
+
maxWidth: number;
|
|
36
|
+
nodeMinHeight: number;
|
|
37
|
+
paddingX: number;
|
|
38
|
+
spacingHorizontal: number;
|
|
39
|
+
spacingVertical: number;
|
|
40
|
+
};
|
|
41
|
+
state: IMarkmapState;
|
|
42
|
+
svg: ID3SVGElement;
|
|
43
|
+
styleNode: d3.Selection<HTMLStyleElement, INode, HTMLElement, INode>;
|
|
44
|
+
g: d3.Selection<SVGGElement, INode, HTMLElement, INode>;
|
|
45
|
+
zoom: d3.ZoomBehavior<SVGElement, INode>;
|
|
46
|
+
private _observer;
|
|
47
|
+
private _disposeList;
|
|
48
|
+
/** Manages add / edit / delete overlays and node mutations. */
|
|
49
|
+
private _actions;
|
|
50
|
+
constructor(svg: string | SVGElement | ID3SVGElement, opts?: Partial<IMarkmapOptions>);
|
|
51
|
+
getStyleContent(): string;
|
|
52
|
+
updateStyle(): void;
|
|
53
|
+
handleZoom: (e: any) => void;
|
|
54
|
+
handlePan: (e: WheelEvent) => void;
|
|
55
|
+
toggleNode(data: INode, recursive?: boolean): Promise<void>;
|
|
56
|
+
handleClick: (e: MouseEvent, d: INode) => void;
|
|
57
|
+
private _initializeData;
|
|
58
|
+
private _relayout;
|
|
59
|
+
setOptions(opts?: Partial<IMarkmapOptions>): void;
|
|
60
|
+
setData(data?: IPureNode | null, opts?: Partial<IMarkmapOptions>): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get the whole mindmap data.
|
|
63
|
+
*
|
|
64
|
+
* - default: returns internal runtime node tree (`INode`) including `state`
|
|
65
|
+
* - `pure=true`: returns a plain data tree (`IPureNode`) without `state`
|
|
66
|
+
*/
|
|
67
|
+
getData(): INode | undefined;
|
|
68
|
+
getData(pure: true): IPureNode | undefined;
|
|
69
|
+
setHighlight(node?: INode | null): Promise<void>;
|
|
70
|
+
private _getHighlightRect;
|
|
71
|
+
renderData(originData?: INode): Promise<void>;
|
|
72
|
+
transition<T extends d3.BaseType, U, P extends d3.BaseType, Q>(sel: d3.Selection<T, U, P, Q>): d3.Transition<T, U, P, Q>;
|
|
73
|
+
/**
|
|
74
|
+
* Fit the content to the viewport.
|
|
75
|
+
*/
|
|
76
|
+
fit(maxScale?: number): Promise<void>;
|
|
77
|
+
findElement(node: INode): {
|
|
78
|
+
data: INode;
|
|
79
|
+
g: SVGGElement;
|
|
80
|
+
} | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Pan the content to make the provided node visible in the viewport.
|
|
83
|
+
*/
|
|
84
|
+
ensureVisible(node: INode, padding?: Partial<IPadding>): Promise<void>;
|
|
85
|
+
/** @deprecated Use `ensureVisible` instead */
|
|
86
|
+
ensureView: (node: INode, padding?: Partial<IPadding>) => Promise<void>;
|
|
87
|
+
centerNode(node: INode, padding?: Partial<IPadding>): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Scale content with it pinned at the center of the viewport.
|
|
90
|
+
*/
|
|
91
|
+
rescale(scale: number): Promise<void>;
|
|
92
|
+
destroy(): void;
|
|
93
|
+
static create(svg: string | SVGElement | ID3SVGElement, opts?: Partial<IMarkmapOptions>, data?: IPureNode | null): Markmap;
|
|
94
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "markmap-view-plus",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "View markmaps in browser",
|
|
5
|
+
"author": "Lin Jiman <temman_lin@qq.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"markmap",
|
|
9
|
+
"markdown",
|
|
10
|
+
"mindmap"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/markmap/markmap/packages/markmap-view-plus#readme",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public",
|
|
15
|
+
"registry": "https://registry.npmjs.org/"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/markmap/markmap.git"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "del-cli dist tsconfig.tsbuildinfo",
|
|
23
|
+
"build:types": "tsc",
|
|
24
|
+
"build:js": "vite build && pnpm build:js:es",
|
|
25
|
+
"build:js:es": "cross-env TARGET=es vite build",
|
|
26
|
+
"build": "pnpm clean && pnpm /^build:/",
|
|
27
|
+
"prepublishOnly": "pnpm build"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/markmap/markmap/issues"
|
|
31
|
+
},
|
|
32
|
+
"type": "module",
|
|
33
|
+
"main": "dist/index.js",
|
|
34
|
+
"module": "dist/index.js",
|
|
35
|
+
"unpkg": "dist/browser/index.js",
|
|
36
|
+
"jsdelivr": "dist/browser/index.js",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"typings": "dist/index.d.ts",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@babel/runtime": "^7.22.6",
|
|
43
|
+
"d3": "^7.8.5"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@gera2ld/jsx-dom": "^2.2.2",
|
|
47
|
+
"@types/d3": "^7.4.0",
|
|
48
|
+
"@types/d3-flextree": "^2.1.1",
|
|
49
|
+
"d3-flextree": "^2.1.2",
|
|
50
|
+
"cross-env": "^7.0.3",
|
|
51
|
+
"markmap-common": "^0.18.9"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|