bto-md-editor 0.1.17 → 0.1.18
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/dist/lib/utils/ResizableNodeView.d.ts +87 -0
- package/dist/md-editor.es.js +1998 -1880
- package/dist/md-editor.umd.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Node as PMNode } from '@tiptap/pm/model';
|
|
2
|
+
import { Decoration, DecorationSource, NodeView } from '@tiptap/pm/view';
|
|
3
|
+
export type ResizableNodeViewDirection = 'top' | 'right' | 'bottom' | 'left' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
4
|
+
export type ResizableNodeDimensions = {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
export type ResizableNodeViewOptions = {
|
|
9
|
+
element: HTMLElement;
|
|
10
|
+
contentElement?: HTMLElement;
|
|
11
|
+
node: PMNode;
|
|
12
|
+
getPos: () => number | undefined;
|
|
13
|
+
onResize?: (width: number, height: number) => void;
|
|
14
|
+
onCommit: (width: number, height: number) => void;
|
|
15
|
+
onUpdate: NodeView['update'];
|
|
16
|
+
options?: {
|
|
17
|
+
directions?: ResizableNodeViewDirection[];
|
|
18
|
+
min?: Partial<ResizableNodeDimensions>;
|
|
19
|
+
max?: Partial<ResizableNodeDimensions>;
|
|
20
|
+
preserveAspectRatio?: boolean;
|
|
21
|
+
className?: {
|
|
22
|
+
container?: string;
|
|
23
|
+
wrapper?: string;
|
|
24
|
+
handle?: string;
|
|
25
|
+
resizing?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare class ResizableNodeView {
|
|
30
|
+
node: PMNode;
|
|
31
|
+
element: HTMLElement;
|
|
32
|
+
contentElement?: HTMLElement;
|
|
33
|
+
container: HTMLElement;
|
|
34
|
+
wrapper: HTMLElement;
|
|
35
|
+
getPos: () => number | undefined;
|
|
36
|
+
onResize?: (width: number, height: number) => void;
|
|
37
|
+
onCommit: (width: number, height: number) => void;
|
|
38
|
+
onUpdate?: NodeView['update'];
|
|
39
|
+
directions: ResizableNodeViewDirection[];
|
|
40
|
+
minSize: ResizableNodeDimensions;
|
|
41
|
+
maxSize?: Partial<ResizableNodeDimensions>;
|
|
42
|
+
preserveAspectRatio: boolean;
|
|
43
|
+
classNames: {
|
|
44
|
+
container: string;
|
|
45
|
+
wrapper: string;
|
|
46
|
+
handle: string;
|
|
47
|
+
resizing: string;
|
|
48
|
+
};
|
|
49
|
+
private initialWidth;
|
|
50
|
+
private initialHeight;
|
|
51
|
+
private aspectRatio;
|
|
52
|
+
private isResizing;
|
|
53
|
+
private activeHandle;
|
|
54
|
+
private startX;
|
|
55
|
+
private startY;
|
|
56
|
+
private startWidth;
|
|
57
|
+
private startHeight;
|
|
58
|
+
private isShiftKeyPressed;
|
|
59
|
+
constructor(options: ResizableNodeViewOptions);
|
|
60
|
+
get dom(): HTMLElement;
|
|
61
|
+
get contentDOM(): HTMLElement | undefined;
|
|
62
|
+
update(node: PMNode, decorations: readonly Decoration[], innerDecorations: DecorationSource): boolean;
|
|
63
|
+
destroy(): void;
|
|
64
|
+
createContainer(): HTMLDivElement;
|
|
65
|
+
createWrapper(): HTMLDivElement;
|
|
66
|
+
private createHandle;
|
|
67
|
+
private positionHandle;
|
|
68
|
+
private attachHandles;
|
|
69
|
+
private applyInitialSize;
|
|
70
|
+
private handleResizeStart;
|
|
71
|
+
private handleMouseMove;
|
|
72
|
+
private handleTouchMove;
|
|
73
|
+
private handleResize;
|
|
74
|
+
/**
|
|
75
|
+
* Completes the resize operation when the mouse button is released.
|
|
76
|
+
*
|
|
77
|
+
* Captures final dimensions, calls the onCommit callback to persist changes,
|
|
78
|
+
* removes the resizing state and class, and cleans up document-level listeners.
|
|
79
|
+
*/
|
|
80
|
+
private handleMouseUp;
|
|
81
|
+
private handleKeyDown;
|
|
82
|
+
private handleKeyUp;
|
|
83
|
+
private calculateNewDimensions;
|
|
84
|
+
private applyConstraints;
|
|
85
|
+
private applyAspectRatio;
|
|
86
|
+
}
|
|
87
|
+
export declare const ResizableNodeview: typeof ResizableNodeView;
|