@uiw/react-md-editor 3.25.5 → 3.25.6
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 +2 -0
- package/commands.d.ts +148 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -794,6 +794,8 @@ import "@uiw/react-markdown-preview/markdown.css";
|
|
|
794
794
|
import dynamic from "next/dynamic";
|
|
795
795
|
import { useState } from "react";
|
|
796
796
|
|
|
797
|
+
import * as commands from "@uiw/react-md-editor/commands"
|
|
798
|
+
|
|
797
799
|
const MDEditor = dynamic(
|
|
798
800
|
() => import("@uiw/react-md-editor"),
|
|
799
801
|
{ ssr: false }
|
package/commands.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
declare module '@uiw/react-md-editor/commands' {
|
|
2
|
+
import { ContextStore, ExecuteCommandState } from '@uiw/react-md-editor/esm/Context';
|
|
3
|
+
import { bold } from '@uiw/react-md-editor/esm/commands/bold';
|
|
4
|
+
import { code, codeBlock } from '@uiw/react-md-editor/esm/commands/code';
|
|
5
|
+
import { comment } from '@uiw/react-md-editor/esm/commands/comment';
|
|
6
|
+
import { divider } from '@uiw/react-md-editor/esm/commands/divider';
|
|
7
|
+
import { fullscreen } from '@uiw/react-md-editor/esm/commands/fullscreen';
|
|
8
|
+
import { group } from '@uiw/react-md-editor/esm/commands/group';
|
|
9
|
+
import { hr } from '@uiw/react-md-editor/esm/commands/hr';
|
|
10
|
+
import { image } from '@uiw/react-md-editor/esm/commands/image';
|
|
11
|
+
import { italic } from '@uiw/react-md-editor/esm/commands/italic';
|
|
12
|
+
import { link } from '@uiw/react-md-editor/esm/commands/link';
|
|
13
|
+
import { checkedListCommand, orderedListCommand, unorderedListCommand } from '@uiw/react-md-editor/esm/commands/list';
|
|
14
|
+
import { codeEdit, codeLive, codePreview } from '@uiw/react-md-editor/esm/commands/preview';
|
|
15
|
+
import { quote } from '@uiw/react-md-editor/esm/commands/quote';
|
|
16
|
+
import { strikethrough } from '@uiw/react-md-editor/esm/commands/strikeThrough';
|
|
17
|
+
import { title } from '@uiw/react-md-editor/esm/commands/title';
|
|
18
|
+
import { title1 } from '@uiw/react-md-editor/esm/commands/title1';
|
|
19
|
+
import { title2 } from '@uiw/react-md-editor/esm/commands/title2';
|
|
20
|
+
import { title3 } from '@uiw/react-md-editor/esm/commands/title3';
|
|
21
|
+
import { title4 } from '@uiw/react-md-editor/esm/commands/title4';
|
|
22
|
+
import { title5 } from '@uiw/react-md-editor/esm/commands/title5';
|
|
23
|
+
import { title6 } from '@uiw/react-md-editor/esm/commands/title6';
|
|
24
|
+
import { table } from '@uiw/react-md-editor/esm/commands/table';
|
|
25
|
+
import { issue } from '@uiw/react-md-editor/esm/commands/issue';
|
|
26
|
+
import { help } from '@uiw/react-md-editor/esm/commands/help';
|
|
27
|
+
export interface CommandOrchestrator {
|
|
28
|
+
executeCommand(command: ICommand): void;
|
|
29
|
+
}
|
|
30
|
+
export interface ICommandChildHandle<T = string> extends ICommandBase<T> {
|
|
31
|
+
children?: (handle: {
|
|
32
|
+
close: () => void;
|
|
33
|
+
execute: () => void;
|
|
34
|
+
getState?: TextAreaCommandOrchestrator['getState'];
|
|
35
|
+
textApi?: TextAreaTextApi;
|
|
36
|
+
dispatch?: React.Dispatch<ContextStore>;
|
|
37
|
+
}) => React.ReactElement;
|
|
38
|
+
}
|
|
39
|
+
export interface ICommandChildCommands<T = string> extends ICommandBase<T> {
|
|
40
|
+
children?: Array<ICommand<T>>;
|
|
41
|
+
}
|
|
42
|
+
export interface ICommandBase<T> {
|
|
43
|
+
parent?: ICommand<any>;
|
|
44
|
+
keyCommand?: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
shortcuts?: string;
|
|
47
|
+
groupName?: string;
|
|
48
|
+
icon?: React.ReactElement;
|
|
49
|
+
value?: string;
|
|
50
|
+
prefix?: string;
|
|
51
|
+
suffix?: string;
|
|
52
|
+
position?: 'right';
|
|
53
|
+
liProps?: React.LiHTMLAttributes<HTMLLIElement>;
|
|
54
|
+
buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement> | null;
|
|
55
|
+
render?: (
|
|
56
|
+
command: ICommand<T>,
|
|
57
|
+
disabled: boolean,
|
|
58
|
+
executeCommand: (command: ICommand<T>, name?: string) => void,
|
|
59
|
+
index: number,
|
|
60
|
+
) => void | undefined | null | React.ReactElement;
|
|
61
|
+
execute?: (
|
|
62
|
+
state: ExecuteState,
|
|
63
|
+
api: TextAreaTextApi,
|
|
64
|
+
dispatch?: React.Dispatch<ContextStore>,
|
|
65
|
+
executeCommandState?: ExecuteCommandState,
|
|
66
|
+
shortcuts?: string[],
|
|
67
|
+
) => void;
|
|
68
|
+
}
|
|
69
|
+
export type ExecuteState = TextState & {
|
|
70
|
+
command: ICommand;
|
|
71
|
+
};
|
|
72
|
+
export type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;
|
|
73
|
+
export interface TextRange {
|
|
74
|
+
start: number;
|
|
75
|
+
end: number;
|
|
76
|
+
}
|
|
77
|
+
export interface TextState {
|
|
78
|
+
text: string;
|
|
79
|
+
selectedText: string;
|
|
80
|
+
selection: TextRange;
|
|
81
|
+
}
|
|
82
|
+
const getCommands: () => ICommand[];
|
|
83
|
+
const getExtraCommands: () => ICommand[];
|
|
84
|
+
function getStateFromTextArea(textArea: HTMLTextAreaElement): TextState;
|
|
85
|
+
class TextAreaTextApi {
|
|
86
|
+
textArea: HTMLTextAreaElement;
|
|
87
|
+
constructor(textArea: HTMLTextAreaElement);
|
|
88
|
+
/**
|
|
89
|
+
* Replaces the current selection with the new text. This will make the new selectedText to be empty, the
|
|
90
|
+
* selection start and selection end will be the same and will both point to the end
|
|
91
|
+
* @param text Text that should replace the current selection
|
|
92
|
+
*/
|
|
93
|
+
replaceSelection(text: string): TextState;
|
|
94
|
+
/**
|
|
95
|
+
* Selects the specified text range
|
|
96
|
+
* @param selection
|
|
97
|
+
*/
|
|
98
|
+
setSelectionRange(selection: TextRange): TextState;
|
|
99
|
+
}
|
|
100
|
+
class TextAreaCommandOrchestrator implements CommandOrchestrator {
|
|
101
|
+
textArea: HTMLTextAreaElement;
|
|
102
|
+
textApi: TextAreaTextApi;
|
|
103
|
+
constructor(textArea: HTMLTextAreaElement);
|
|
104
|
+
getState(): false | TextState;
|
|
105
|
+
executeCommand(
|
|
106
|
+
command: ICommand<string>,
|
|
107
|
+
dispatch?: React.Dispatch<ContextStore>,
|
|
108
|
+
state?: ExecuteCommandState,
|
|
109
|
+
shortcuts?: string[],
|
|
110
|
+
): void;
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
title,
|
|
114
|
+
title1,
|
|
115
|
+
title2,
|
|
116
|
+
title3,
|
|
117
|
+
title4,
|
|
118
|
+
title5,
|
|
119
|
+
title6,
|
|
120
|
+
bold,
|
|
121
|
+
codeBlock,
|
|
122
|
+
comment,
|
|
123
|
+
italic,
|
|
124
|
+
strikethrough,
|
|
125
|
+
hr,
|
|
126
|
+
group,
|
|
127
|
+
divider,
|
|
128
|
+
link,
|
|
129
|
+
quote,
|
|
130
|
+
code,
|
|
131
|
+
image,
|
|
132
|
+
unorderedListCommand,
|
|
133
|
+
orderedListCommand,
|
|
134
|
+
checkedListCommand,
|
|
135
|
+
table,
|
|
136
|
+
issue,
|
|
137
|
+
help,
|
|
138
|
+
codeEdit,
|
|
139
|
+
codeLive,
|
|
140
|
+
codePreview,
|
|
141
|
+
fullscreen,
|
|
142
|
+
getCommands,
|
|
143
|
+
getExtraCommands,
|
|
144
|
+
getStateFromTextArea,
|
|
145
|
+
TextAreaCommandOrchestrator,
|
|
146
|
+
TextAreaTextApi,
|
|
147
|
+
};
|
|
148
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-md-editor",
|
|
3
|
-
"version": "3.25.
|
|
3
|
+
"version": "3.25.6",
|
|
4
4
|
"description": "A markdown editor with preview, implemented with React.js and TypeScript.",
|
|
5
5
|
"homepage": "https://uiwjs.github.io/react-md-editor/",
|
|
6
6
|
"author": "kenny wang <wowohoo@qq.com>",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"files": [
|
|
37
37
|
"markdown-editor.css",
|
|
38
38
|
"nohighlight.d.ts",
|
|
39
|
+
"commands.d.ts",
|
|
39
40
|
"lib",
|
|
40
41
|
"dist",
|
|
41
42
|
"esm",
|