tiny-markdown-editor 0.1.33 → 0.2.0
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/tiny-mde.js +2994 -3424
- package/dist/tiny-mde.min.js +1 -1
- package/dist/tiny-mde.tiny.js +1 -1
- package/lib/TinyMDE.d.ts +95 -0
- package/lib/TinyMDE.js +1434 -1714
- package/lib/TinyMDECommandBar.d.ts +35 -0
- package/lib/TinyMDECommandBar.js +311 -260
- package/lib/grammar.d.ts +70 -0
- package/lib/grammar.js +245 -367
- package/lib/index.d.ts +3 -0
- package/lib/index.js +9 -19
- package/lib/svg/svg.d.ts +2 -0
- package/lib/svg/svg.js +17 -21
- package/lib/tiny.d.ts +2 -0
- package/lib/tiny.js +7 -12
- package/package.json +12 -3
- package/globals.d.ts +0 -175
package/lib/TinyMDE.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export interface EditorProps {
|
|
2
|
+
element?: string | HTMLElement;
|
|
3
|
+
editor?: string | HTMLElement;
|
|
4
|
+
content?: string;
|
|
5
|
+
textarea?: string | HTMLTextAreaElement;
|
|
6
|
+
}
|
|
7
|
+
export interface Position {
|
|
8
|
+
row: number;
|
|
9
|
+
col: number;
|
|
10
|
+
}
|
|
11
|
+
export interface HistoryState {
|
|
12
|
+
content: string;
|
|
13
|
+
selection: Position | null;
|
|
14
|
+
anchor: Position | null;
|
|
15
|
+
}
|
|
16
|
+
export interface ChangeEvent {
|
|
17
|
+
content: string;
|
|
18
|
+
linesDirty: boolean[];
|
|
19
|
+
}
|
|
20
|
+
export interface SelectionEvent {
|
|
21
|
+
focus: Position;
|
|
22
|
+
anchor: Position;
|
|
23
|
+
commandState: Record<string, boolean | null>;
|
|
24
|
+
}
|
|
25
|
+
export interface DropEvent {
|
|
26
|
+
dataTransfer: DataTransfer;
|
|
27
|
+
}
|
|
28
|
+
type EventType = 'change' | 'selection' | 'drop';
|
|
29
|
+
type EventHandler<T> = (event: T) => void;
|
|
30
|
+
export declare class Editor {
|
|
31
|
+
e: HTMLDivElement | null;
|
|
32
|
+
textarea: HTMLTextAreaElement | null;
|
|
33
|
+
lines: string[];
|
|
34
|
+
lineElements: NodeListOf<ChildNode> | HTMLCollection | ChildNode[];
|
|
35
|
+
lineTypes: string[];
|
|
36
|
+
lineCaptures: RegExpExecArray[];
|
|
37
|
+
lineReplacements: string[];
|
|
38
|
+
linkLabels: string[];
|
|
39
|
+
lineDirty: boolean[];
|
|
40
|
+
lastCommandState: Record<string, boolean | null> | null;
|
|
41
|
+
listeners: {
|
|
42
|
+
change: EventHandler<ChangeEvent>[];
|
|
43
|
+
selection: EventHandler<SelectionEvent>[];
|
|
44
|
+
drop: EventHandler<DropEvent>[];
|
|
45
|
+
};
|
|
46
|
+
private undoStack;
|
|
47
|
+
private redoStack;
|
|
48
|
+
private isRestoringHistory;
|
|
49
|
+
private maxHistory;
|
|
50
|
+
constructor(props?: EditorProps);
|
|
51
|
+
get canUndo(): boolean;
|
|
52
|
+
get canRedo(): boolean;
|
|
53
|
+
private pushHistory;
|
|
54
|
+
private pushCurrentState;
|
|
55
|
+
undo(): void;
|
|
56
|
+
redo(): void;
|
|
57
|
+
private handleUndoRedoKey;
|
|
58
|
+
private createEditorElement;
|
|
59
|
+
setContent(content: string): void;
|
|
60
|
+
getContent(): string;
|
|
61
|
+
private updateFormatting;
|
|
62
|
+
private updateLinkLabels;
|
|
63
|
+
private replace;
|
|
64
|
+
private applyLineTypes;
|
|
65
|
+
private updateLineTypes;
|
|
66
|
+
getSelection(getAnchor?: boolean): Position | null;
|
|
67
|
+
setSelection(focus: Position, anchor?: Position | null): void;
|
|
68
|
+
paste(text: string, anchor?: Position | null, focus?: Position | null): void;
|
|
69
|
+
wrapSelection(pre: string, post: string, focus?: Position | null, anchor?: Position | null): void;
|
|
70
|
+
addEventListener<T extends EventType>(type: T, listener: T extends 'change' ? EventHandler<ChangeEvent> : T extends 'selection' ? EventHandler<SelectionEvent> : T extends 'drop' ? EventHandler<DropEvent> : never): void;
|
|
71
|
+
private fireChange;
|
|
72
|
+
private handleInputEvent;
|
|
73
|
+
private handleSelectionChangeEvent;
|
|
74
|
+
private handlePaste;
|
|
75
|
+
private handleDrop;
|
|
76
|
+
private processInlineStyles;
|
|
77
|
+
private computeColumn;
|
|
78
|
+
private computeNodeAndOffset;
|
|
79
|
+
private updateLineContentsAndFormatting;
|
|
80
|
+
private clearDirtyFlag;
|
|
81
|
+
private updateLineContents;
|
|
82
|
+
private processNewParagraph;
|
|
83
|
+
private spliceLines;
|
|
84
|
+
private fixNodeHierarchy;
|
|
85
|
+
private parseLinkOrImage;
|
|
86
|
+
private computeCommonAncestor;
|
|
87
|
+
private computeEnclosingMarkupNode;
|
|
88
|
+
getCommandState(focus?: Position | null, anchor?: Position | null): Record<string, boolean | null>;
|
|
89
|
+
setCommandState(command: string, state: boolean): void;
|
|
90
|
+
private isInlineFormattingAllowed;
|
|
91
|
+
toggleCommandState(command: string): void;
|
|
92
|
+
private fireDrop;
|
|
93
|
+
private fireSelection;
|
|
94
|
+
}
|
|
95
|
+
export default Editor;
|