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
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# markmap-view-plus
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
View markmaps in browser.
|
|
8
|
+
|
|
9
|
+
This is an editable version of markmap-view-plus with enhanced features for node editing, adding, and deleting.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
$ npm install markmap-view-plus
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This package is separated from [markmap-lib](https://github.com/markmap/markmap/tree/master/packages/markmap-lib) to decrease the size of `node_modules` because you don't need this in `node_modules` most of the time.
|
|
19
|
+
|
|
20
|
+
👉 [Read the documentation](https://markmap.js.org/docs) for more detail.
|
package/dist/action.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type * as d3 from 'd3';
|
|
2
|
+
import { INode } from 'markmap-common';
|
|
3
|
+
import { ID3SVGElement, IMarkmapOptions, IMarkmapState } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* The subset of Markmap that ActionManager needs to read or call back into.
|
|
6
|
+
* Keeping this as an interface avoids a circular import between action.ts ↔ view.ts.
|
|
7
|
+
*/
|
|
8
|
+
export interface IMarkmapActionContext {
|
|
9
|
+
svg: ID3SVGElement;
|
|
10
|
+
g: d3.Selection<SVGGElement, INode, HTMLElement, INode>;
|
|
11
|
+
state: IMarkmapState;
|
|
12
|
+
options: IMarkmapOptions;
|
|
13
|
+
renderData: (originData?: INode) => Promise<void>;
|
|
14
|
+
findElement: (node: INode) => {
|
|
15
|
+
data: INode;
|
|
16
|
+
g: SVGGElement;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Manages all node add / edit / delete actions and their associated UI overlays.
|
|
21
|
+
*
|
|
22
|
+
* Responsibilities:
|
|
23
|
+
* - Overlay lifecycle: + button, new-node input, edit input
|
|
24
|
+
* - Tree mutations: insert child, insert sibling, delete node
|
|
25
|
+
* - Selection state: editingNode, selectedNode
|
|
26
|
+
*
|
|
27
|
+
* view.ts creates one ActionManager per Markmap instance and delegates to it.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ActionManager {
|
|
30
|
+
private ctx;
|
|
31
|
+
/** Node currently being edited (null when idle). */
|
|
32
|
+
editingNode: INode | null;
|
|
33
|
+
/** Currently selected node (null when nothing is selected). */
|
|
34
|
+
selectedNode: INode | null;
|
|
35
|
+
/** Active edit-overlay state (shared by existing-node edits and new-node edits). */
|
|
36
|
+
editOverlay?: {
|
|
37
|
+
wrap: HTMLDivElement;
|
|
38
|
+
input: HTMLInputElement;
|
|
39
|
+
contentEl: HTMLDivElement;
|
|
40
|
+
prevVisibility: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
/** Active + button UI state. */
|
|
43
|
+
addUI?: {
|
|
44
|
+
node: INode;
|
|
45
|
+
btn: HTMLButtonElement;
|
|
46
|
+
wrap: HTMLDivElement;
|
|
47
|
+
cleanupDoc: () => void;
|
|
48
|
+
} | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Kept for overlay-guard checks in view.ts.
|
|
51
|
+
* In the current flow this is only set briefly during legacy paths.
|
|
52
|
+
*/
|
|
53
|
+
addInputUI?: {
|
|
54
|
+
node: INode;
|
|
55
|
+
input: HTMLInputElement;
|
|
56
|
+
wrap: HTMLDivElement;
|
|
57
|
+
} | undefined;
|
|
58
|
+
constructor(ctx: IMarkmapActionContext);
|
|
59
|
+
private _getNodeContentEl;
|
|
60
|
+
private _getOverlayRoot;
|
|
61
|
+
private _positionOverlayToEl;
|
|
62
|
+
private _safeRemoveEl;
|
|
63
|
+
private _clearSelectionCss;
|
|
64
|
+
private _findParent;
|
|
65
|
+
/** Create a blank child INode and append it to parent.children. */
|
|
66
|
+
private _insertNewChildNode;
|
|
67
|
+
/**
|
|
68
|
+
* Core overlay builder shared by _editNewNode and handleEdit.
|
|
69
|
+
*
|
|
70
|
+
* @param node - The INode being edited (content will be mutated on save).
|
|
71
|
+
* @param contentNode - The inner <div> whose position / style drives the overlay.
|
|
72
|
+
* @param opts.initialValue - Starting text in the input ('': new node, textContent: existing).
|
|
73
|
+
* @param opts.minWidth - Minimum overlay width in px.
|
|
74
|
+
* @param opts.placeholder - Input placeholder (only shown when initialValue is empty).
|
|
75
|
+
* @param opts.selectAll - Whether to select all text on focus (true for existing nodes).
|
|
76
|
+
* @param opts.onSave - Called after the overlay is torn down on a successful save.
|
|
77
|
+
* @param opts.onCancel - Called after the overlay is torn down on cancel / empty input.
|
|
78
|
+
*/
|
|
79
|
+
private _openEditOverlay;
|
|
80
|
+
/**
|
|
81
|
+
* Open an edit overlay for a freshly-inserted node.
|
|
82
|
+
* Empty input → confirm saves; blank input → cancels and removes the node from the tree.
|
|
83
|
+
*/
|
|
84
|
+
private _editNewNode;
|
|
85
|
+
/** Reposition all active overlays after zoom / pan. */
|
|
86
|
+
repositionOverlays(): void;
|
|
87
|
+
/** Hide and destroy the + button and any associated input overlay. */
|
|
88
|
+
hideAddUI(): void;
|
|
89
|
+
/** Show the + button anchored to the bottom-right corner of `node`. */
|
|
90
|
+
showAddUI(node: INode): void;
|
|
91
|
+
/** Delete `node` from the tree and re-render. */
|
|
92
|
+
deleteNode(node: INode): void;
|
|
93
|
+
/**
|
|
94
|
+
* Insert a new sibling node after `sibling`, render it, then open an edit overlay.
|
|
95
|
+
* Called when the user presses Enter on a selected node.
|
|
96
|
+
*/
|
|
97
|
+
showAddSiblingInput(sibling: INode): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Insert a new child node under `node`, render it, then open an edit overlay.
|
|
100
|
+
* Called when the user clicks the + button or presses Tab.
|
|
101
|
+
*/
|
|
102
|
+
showAddInput(node: INode): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Open an edit overlay for an *existing* node.
|
|
105
|
+
* Called on double-click. On confirm the node content is updated in-place.
|
|
106
|
+
*/
|
|
107
|
+
handleEdit(e: MouseEvent, d: INode): void;
|
|
108
|
+
/** Immediately discard any in-progress edit overlay without saving. */
|
|
109
|
+
saveEdit(): void;
|
|
110
|
+
}
|