@uiw/react-md-editor 3.20.5 → 3.20.7
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 +8 -2
- package/dist/mdeditor.css +13 -0
- package/dist/mdeditor.js +9517 -1252
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.d.ts +3 -3
- package/esm/Context.js +1 -2
- package/esm/Editor.d.ts +1 -1
- package/esm/Editor.js +9 -2
- package/esm/commands/bold.js +1 -2
- package/esm/commands/code.js +2 -3
- package/esm/commands/comment.js +2 -2
- package/esm/commands/divider.js +1 -2
- package/esm/commands/fullscreen.js +2 -3
- package/esm/commands/group.d.ts +1 -1
- package/esm/commands/group.js +1 -2
- package/esm/commands/hr.js +2 -3
- package/esm/commands/image.js +2 -3
- package/esm/commands/index.d.ts +2 -2
- package/esm/commands/index.js +1 -2
- package/esm/commands/italic.js +2 -3
- package/esm/commands/link.js +2 -3
- package/esm/commands/list.d.ts +1 -1
- package/esm/commands/list.js +2 -3
- package/esm/commands/preview.js +2 -3
- package/esm/commands/quote.js +2 -3
- package/esm/commands/strikeThrough.js +2 -3
- package/esm/commands/title.js +1 -2
- package/esm/commands/title1.js +1 -2
- package/esm/commands/title2.js +2 -3
- package/esm/commands/title3.js +2 -3
- package/esm/commands/title4.js +2 -3
- package/esm/commands/title5.js +2 -3
- package/esm/commands/title6.js +2 -3
- package/esm/components/DragBar/index.js +8 -3
- package/esm/components/TextArea/Markdown.js +1 -2
- package/esm/components/TextArea/Textarea.js +1 -2
- package/esm/components/TextArea/handleKeyDown.d.ts +1 -0
- package/esm/components/TextArea/handleKeyDown.js +1 -2
- package/esm/components/TextArea/index.d.ts +2 -2
- package/esm/components/TextArea/index.js +1 -2
- package/esm/components/TextArea/shortcuts.d.ts +1 -0
- package/esm/components/TextArea/shortcuts.js +1 -2
- package/esm/components/Toolbar/Child.d.ts +2 -1
- package/esm/components/Toolbar/Child.js +1 -2
- package/esm/components/Toolbar/index.d.ts +1 -0
- package/esm/components/Toolbar/index.js +1 -2
- package/esm/index.js +1 -2
- package/esm/react-app-env.d.ts +1 -0
- package/esm/utils/InsertTextAtPosition.js +1 -2
- package/esm/utils/markdownUtils.js +1 -2
- package/lib/Context.d.ts +3 -3
- package/lib/Context.js +1 -2
- package/lib/Editor.d.ts +1 -1
- package/lib/Editor.js +13 -2
- package/lib/commands/bold.js +1 -2
- package/lib/commands/code.js +3 -4
- package/lib/commands/comment.js +3 -2
- package/lib/commands/divider.js +1 -2
- package/lib/commands/fullscreen.js +3 -4
- package/lib/commands/group.d.ts +1 -1
- package/lib/commands/group.js +1 -2
- package/lib/commands/hr.js +3 -4
- package/lib/commands/image.js +3 -4
- package/lib/commands/index.d.ts +2 -2
- package/lib/commands/index.js +1 -2
- package/lib/commands/italic.js +3 -4
- package/lib/commands/link.js +3 -4
- package/lib/commands/list.d.ts +1 -1
- package/lib/commands/list.js +3 -4
- package/lib/commands/preview.js +3 -4
- package/lib/commands/quote.js +3 -4
- package/lib/commands/strikeThrough.js +3 -4
- package/lib/commands/title.js +1 -2
- package/lib/commands/title1.js +1 -2
- package/lib/commands/title2.js +3 -4
- package/lib/commands/title3.js +3 -4
- package/lib/commands/title4.js +3 -4
- package/lib/commands/title5.js +3 -4
- package/lib/commands/title6.js +3 -4
- package/lib/components/DragBar/index.js +8 -3
- package/lib/components/TextArea/Markdown.js +1 -2
- package/lib/components/TextArea/Textarea.js +1 -2
- package/lib/components/TextArea/handleKeyDown.d.ts +1 -0
- package/lib/components/TextArea/handleKeyDown.js +1 -2
- package/lib/components/TextArea/index.d.ts +2 -2
- package/lib/components/TextArea/index.js +1 -2
- package/lib/components/TextArea/shortcuts.d.ts +1 -0
- package/lib/components/TextArea/shortcuts.js +1 -2
- package/lib/components/Toolbar/Child.d.ts +2 -1
- package/lib/components/Toolbar/Child.js +1 -2
- package/lib/components/Toolbar/index.d.ts +1 -0
- package/lib/components/Toolbar/index.js +1 -2
- package/lib/index.js +1 -2
- package/lib/react-app-env.d.ts +1 -0
- package/lib/utils/InsertTextAtPosition.js +1 -2
- package/lib/utils/markdownUtils.js +1 -2
- package/package.json +1 -1
- package/src/Editor.tsx +4 -0
- package/src/__test__/commands.test.tsx +4 -4
- package/src/commands/code.tsx +1 -1
- package/src/commands/comment.tsx +1 -0
- package/src/commands/divider.tsx +1 -0
- package/src/commands/fullscreen.tsx +1 -1
- package/src/commands/hr.tsx +1 -1
- package/src/commands/image.tsx +1 -1
- package/src/commands/italic.tsx +1 -1
- package/src/commands/link.tsx +1 -1
- package/src/commands/list.tsx +1 -1
- package/src/commands/preview.tsx +1 -1
- package/src/commands/quote.tsx +1 -1
- package/src/commands/strikeThrough.tsx +1 -1
- package/src/commands/title2.tsx +1 -1
- package/src/commands/title3.tsx +1 -1
- package/src/commands/title4.tsx +1 -1
- package/src/commands/title5.tsx +1 -1
- package/src/commands/title6.tsx +1 -1
- package/src/components/DragBar/index.tsx +9 -1
- package/esm/Context.js.map +0 -19
- package/esm/Editor.js.map +0 -116
- package/esm/commands/bold.js.map +0 -38
- package/esm/commands/code.js.map +0 -47
- package/esm/commands/comment.js.map +0 -35
- package/esm/commands/divider.js.map +0 -14
- package/esm/commands/fullscreen.js.map +0 -28
- package/esm/commands/group.js.map +0 -26
- package/esm/commands/hr.js.map +0 -27
- package/esm/commands/image.js.map +0 -40
- package/esm/commands/index.js.map +0 -69
- package/esm/commands/italic.js.map +0 -38
- package/esm/commands/link.js.map +0 -38
- package/esm/commands/list.js.map +0 -61
- package/esm/commands/preview.js.map +0 -31
- package/esm/commands/quote.js.map +0 -44
- package/esm/commands/strikeThrough.js.map +0 -38
- package/esm/commands/title.js.map +0 -16
- package/esm/commands/title1.js.map +0 -33
- package/esm/commands/title2.js.map +0 -33
- package/esm/commands/title3.js.map +0 -33
- package/esm/commands/title4.js.map +0 -33
- package/esm/commands/title5.js.map +0 -33
- package/esm/commands/title6.js.map +0 -33
- package/esm/components/DragBar/index.js.map +0 -41
- package/esm/components/TextArea/Markdown.js.map +0 -47
- package/esm/components/TextArea/Textarea.js.map +0 -47
- package/esm/components/TextArea/handleKeyDown.js.map +0 -66
- package/esm/components/TextArea/index.js.map +0 -57
- package/esm/components/TextArea/shortcuts.js.map +0 -52
- package/esm/components/Toolbar/Child.js.map +0 -28
- package/esm/components/Toolbar/index.js.map +0 -84
- package/esm/index.js.map +0 -15
- package/esm/utils/InsertTextAtPosition.js.map +0 -67
- package/esm/utils/markdownUtils.js.map +0 -31
- package/lib/Context.js.map +0 -19
- package/lib/Editor.js.map +0 -112
- package/lib/commands/bold.js.map +0 -37
- package/lib/commands/code.js.map +0 -46
- package/lib/commands/comment.js.map +0 -35
- package/lib/commands/divider.js.map +0 -14
- package/lib/commands/fullscreen.js.map +0 -27
- package/lib/commands/group.js.map +0 -25
- package/lib/commands/hr.js.map +0 -26
- package/lib/commands/image.js.map +0 -39
- package/lib/commands/index.js.map +0 -64
- package/lib/commands/italic.js.map +0 -37
- package/lib/commands/link.js.map +0 -37
- package/lib/commands/list.js.map +0 -60
- package/lib/commands/preview.js.map +0 -30
- package/lib/commands/quote.js.map +0 -43
- package/lib/commands/strikeThrough.js.map +0 -37
- package/lib/commands/title.js.map +0 -15
- package/lib/commands/title1.js.map +0 -32
- package/lib/commands/title2.js.map +0 -32
- package/lib/commands/title3.js.map +0 -32
- package/lib/commands/title4.js.map +0 -32
- package/lib/commands/title5.js.map +0 -32
- package/lib/commands/title6.js.map +0 -32
- package/lib/components/DragBar/index.js.map +0 -40
- package/lib/components/TextArea/Markdown.js.map +0 -47
- package/lib/components/TextArea/Textarea.js.map +0 -47
- package/lib/components/TextArea/handleKeyDown.js.map +0 -66
- package/lib/components/TextArea/index.js.map +0 -54
- package/lib/components/TextArea/shortcuts.js.map +0 -52
- package/lib/components/Toolbar/Child.js.map +0 -26
- package/lib/components/Toolbar/index.js.map +0 -82
- package/lib/index.js.map +0 -13
- package/lib/utils/InsertTextAtPosition.js.map +0 -67
- package/lib/utils/markdownUtils.js.map +0 -31
package/esm/Context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ICommand, TextAreaCommandOrchestrator } from './commands';
|
|
3
3
|
import { MDEditorProps } from './Editor';
|
|
4
|
-
export
|
|
4
|
+
export type PreviewType = 'live' | 'edit' | 'preview';
|
|
5
5
|
export interface ContextStore {
|
|
6
6
|
components?: MDEditorProps['components'];
|
|
7
7
|
commands?: ICommand<string>[];
|
|
@@ -24,7 +24,7 @@ export interface ContextStore {
|
|
|
24
24
|
tabSize?: number;
|
|
25
25
|
defaultTabEnable?: boolean;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type ExecuteCommandState = Pick<ContextStore, 'fullscreen' | 'preview' | 'highlightEnable'>;
|
|
28
28
|
export declare function reducer(state: ContextStore, action: ContextStore): {
|
|
29
29
|
components?: {
|
|
30
30
|
textarea?: ((props: React.HTMLAttributes<HTMLDivElement> | React.TextareaHTMLAttributes<HTMLTextAreaElement>, opts: {
|
|
@@ -35,7 +35,7 @@ export declare function reducer(state: ContextStore, action: ContextStore): {
|
|
|
35
35
|
extraCommands: ICommand<string>[] | undefined;
|
|
36
36
|
commandOrchestrator?: TextAreaCommandOrchestrator | undefined;
|
|
37
37
|
} | undefined;
|
|
38
|
-
shortcuts?: ((e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand
|
|
38
|
+
shortcuts?: ((e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator | undefined, dispatch?: React.Dispatch<ContextStore> | undefined, state?: ExecuteCommandState | undefined) => void) | undefined;
|
|
39
39
|
}) => JSX.Element) | undefined;
|
|
40
40
|
toolbar?: ((command: ICommand<string>, disabled: boolean, executeCommand: (command: ICommand<string>, name?: string | undefined) => void, index: number) => void | React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined) | undefined;
|
|
41
41
|
preview?: ((source: string, state: ContextStore, dispath: React.Dispatch<ContextStore>) => JSX.Element) | undefined;
|
package/esm/Context.js
CHANGED
package/esm/Editor.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
141
141
|
}
|
|
142
142
|
export interface RefMDEditor extends ContextStore {
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
type Editor = React.FC<PropsWithRef<MDEditorProps>> & {
|
|
145
145
|
Markdown: typeof MarkdownPreview;
|
|
146
146
|
};
|
|
147
147
|
declare const mdEditor: Editor;
|
package/esm/Editor.js
CHANGED
|
@@ -120,6 +120,14 @@ var InternalMDEditor = (props, ref) => {
|
|
|
120
120
|
height: height
|
|
121
121
|
}), [height]);
|
|
122
122
|
useMemo(() => height !== state.height && onHeightChange && onHeightChange(state.height, height, state), [height, onHeightChange, state]);
|
|
123
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
|
+
useMemo(() => commands !== state.commands && dispatch({
|
|
125
|
+
commands: cmds
|
|
126
|
+
}), [props.commands]);
|
|
127
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
128
|
+
useMemo(() => extraCommands !== state.extraCommands && dispatch({
|
|
129
|
+
extraCommands: extraCmds
|
|
130
|
+
}), [props.extraCommands]);
|
|
123
131
|
var textareaDomRef = useRef();
|
|
124
132
|
var active = useRef('preview');
|
|
125
133
|
var initScroll = useRef(false);
|
|
@@ -235,5 +243,4 @@ var InternalMDEditor = (props, ref) => {
|
|
|
235
243
|
};
|
|
236
244
|
var mdEditor = /*#__PURE__*/React.forwardRef(InternalMDEditor);
|
|
237
245
|
mdEditor.Markdown = MarkdownPreview;
|
|
238
|
-
export default mdEditor;
|
|
239
|
-
//# sourceMappingURL=Editor.js.map
|
|
246
|
+
export default mdEditor;
|
package/esm/commands/bold.js
CHANGED
package/esm/commands/code.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var code = {
|
|
@@ -91,5 +91,4 @@ export var codeBlock = {
|
|
|
91
91
|
end: selectionEnd
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=code.js.map
|
|
94
|
+
};
|
package/esm/commands/comment.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
2
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
4
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -49,5 +50,4 @@ export var comment = {
|
|
|
49
50
|
})]
|
|
50
51
|
})
|
|
51
52
|
})
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=comment.js.map
|
|
53
|
+
};
|
package/esm/commands/divider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
export var fullscreen = {
|
|
4
4
|
name: 'fullscreen',
|
|
@@ -26,5 +26,4 @@ export var fullscreen = {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=fullscreen.js.map
|
|
29
|
+
};
|
package/esm/commands/group.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICommand, ICommandChildCommands, ICommandChildHandle } from './';
|
|
2
|
-
export
|
|
2
|
+
export type GroupOptions = Omit<ICommand<string>, 'children'> & {
|
|
3
3
|
children?: ICommandChildHandle['children'];
|
|
4
4
|
};
|
|
5
5
|
export declare const group: (arr: ICommandChildCommands['children'], options?: GroupOptions) => ICommand<string>;
|
package/esm/commands/group.js
CHANGED
package/esm/commands/hr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
export var hr = {
|
|
4
4
|
name: 'hr',
|
|
@@ -22,5 +22,4 @@ export var hr = {
|
|
|
22
22
|
execute: (state, api) => {
|
|
23
23
|
api.replaceSelection(state.selectedText + "\n\n" + (state.command.value || '') + "-\n\n");
|
|
24
24
|
}
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=hr.js.map
|
|
25
|
+
};
|
package/esm/commands/image.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var image = {
|
|
@@ -40,5 +40,4 @@ export var image = {
|
|
|
40
40
|
end
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=image.js.map
|
|
43
|
+
};
|
package/esm/commands/index.d.ts
CHANGED
|
@@ -49,10 +49,10 @@ export interface ICommandBase<T> {
|
|
|
49
49
|
render?: (command: ICommand<T>, disabled: boolean, executeCommand: (command: ICommand<T>, name?: string) => void, index: number) => void | undefined | null | React.ReactElement;
|
|
50
50
|
execute?: (state: ExecuteState, api: TextAreaTextApi, dispatch?: React.Dispatch<ContextStore>, executeCommandState?: ExecuteCommandState, shortcuts?: string[]) => void;
|
|
51
51
|
}
|
|
52
|
-
export
|
|
52
|
+
export type ExecuteState = TextState & {
|
|
53
53
|
command: ICommand;
|
|
54
54
|
};
|
|
55
|
-
export
|
|
55
|
+
export type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;
|
|
56
56
|
export interface TextRange {
|
|
57
57
|
start: number;
|
|
58
58
|
end: number;
|
package/esm/commands/index.js
CHANGED
|
@@ -87,5 +87,4 @@ class TextAreaCommandOrchestrator {
|
|
|
87
87
|
}
|
|
88
88
|
export { title, title1, title2, title3, title4, title5, title6, bold, codeBlock, comment, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, codeEdit, codeLive, codePreview, fullscreen,
|
|
89
89
|
// Tool method.
|
|
90
|
-
getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi };
|
|
91
|
-
//# sourceMappingURL=index.js.map
|
|
90
|
+
getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi };
|
package/esm/commands/italic.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var italic = {
|
|
@@ -39,5 +39,4 @@ export var italic = {
|
|
|
39
39
|
end
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=italic.js.map
|
|
42
|
+
};
|
package/esm/commands/link.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var link = {
|
|
@@ -39,5 +39,4 @@ export var link = {
|
|
|
39
39
|
end
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=link.js.map
|
|
42
|
+
};
|
package/esm/commands/list.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICommand, TextState, TextAreaTextApi } from './';
|
|
2
|
-
export
|
|
2
|
+
export type AlterLineFunction = (line: string, index: number) => string;
|
|
3
3
|
/**
|
|
4
4
|
* Inserts insertionString before each line
|
|
5
5
|
*/
|
package/esm/commands/list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
/**
|
|
@@ -118,5 +118,4 @@ export var checkedListCommand = {
|
|
|
118
118
|
execute: (state, api) => {
|
|
119
119
|
makeList(state, api, (item, index) => "- [ ] ");
|
|
120
120
|
}
|
|
121
|
-
};
|
|
122
|
-
//# sourceMappingURL=list.js.map
|
|
121
|
+
};
|
package/esm/commands/preview.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
export var codePreview = {
|
|
@@ -90,5 +90,4 @@ export var codeLive = {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
};
|
|
94
|
-
//# sourceMappingURL=preview.js.map
|
|
93
|
+
};
|
package/esm/commands/quote.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var quote = {
|
|
@@ -39,5 +39,4 @@ export var quote = {
|
|
|
39
39
|
end: selectionEnd
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=quote.js.map
|
|
42
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var strikethrough = {
|
|
@@ -39,5 +39,4 @@ export var strikethrough = {
|
|
|
39
39
|
end
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=strikeThrough.js.map
|
|
42
|
+
};
|
package/esm/commands/title.js
CHANGED
|
@@ -12,5 +12,4 @@ export var title = _extends({}, title1, {
|
|
|
12
12
|
d: "M15.7083333,468 C7.03242448,468 0,462.030833 0,454.666667 L0,421.333333 C0,413.969167 7.03242448,408 15.7083333,408 L361.291667,408 C369.967576,408 377,413.969167 377,421.333333 L377,454.666667 C377,462.030833 369.967576,468 361.291667,468 L15.7083333,468 Z M21.6666667,366 C9.69989583,366 0,359.831861 0,352.222222 L0,317.777778 C0,310.168139 9.69989583,304 21.6666667,304 L498.333333,304 C510.300104,304 520,310.168139 520,317.777778 L520,352.222222 C520,359.831861 510.300104,366 498.333333,366 L21.6666667,366 Z M136.835938,64 L136.835937,126 L107.25,126 L107.25,251 L40.75,251 L40.75,126 L-5.68434189e-14,126 L-5.68434189e-14,64 L136.835938,64 Z M212,64 L212,251 L161.648438,251 L161.648438,64 L212,64 Z M378,64 L378,126 L343.25,126 L343.25,251 L281.75,251 L281.75,126 L238,126 L238,64 L378,64 Z M449.047619,189.550781 L520,189.550781 L520,251 L405,251 L405,64 L449.047619,64 L449.047619,189.550781 Z"
|
|
13
13
|
})
|
|
14
14
|
})
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=title.js.map
|
|
15
|
+
});
|
package/esm/commands/title1.js
CHANGED
package/esm/commands/title2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title2 = {
|
|
@@ -24,5 +24,4 @@ export var title2 = {
|
|
|
24
24
|
insertAtLineStart('## ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title2.js.map
|
|
27
|
+
};
|
package/esm/commands/title3.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title3 = {
|
|
@@ -24,5 +24,4 @@ export var title3 = {
|
|
|
24
24
|
insertAtLineStart('### ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title3.js.map
|
|
27
|
+
};
|
package/esm/commands/title4.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title4 = {
|
|
@@ -24,5 +24,4 @@ export var title4 = {
|
|
|
24
24
|
insertAtLineStart('#### ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title4.js.map
|
|
27
|
+
};
|
package/esm/commands/title5.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title5 = {
|
|
@@ -24,5 +24,4 @@ export var title5 = {
|
|
|
24
24
|
insertAtLineStart('##### ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title5.js.map
|
|
27
|
+
};
|
package/esm/commands/title6.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title6 = {
|
|
@@ -24,5 +24,4 @@ export var title6 = {
|
|
|
24
24
|
insertAtLineStart('###### ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title6.js.map
|
|
27
|
+
};
|
|
@@ -8,6 +8,12 @@ var DragBar = props => {
|
|
|
8
8
|
} = props || {};
|
|
9
9
|
var $dom = useRef(null);
|
|
10
10
|
var dragRef = useRef();
|
|
11
|
+
var heightRef = useRef(props.height);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (heightRef.current !== props.height) {
|
|
14
|
+
heightRef.current = props.height;
|
|
15
|
+
}
|
|
16
|
+
}, [props.height]);
|
|
11
17
|
function handleMouseMove(event) {
|
|
12
18
|
if (dragRef.current) {
|
|
13
19
|
var _changedTouches$;
|
|
@@ -31,7 +37,7 @@ var DragBar = props => {
|
|
|
31
37
|
event.preventDefault();
|
|
32
38
|
var clientY = event.clientY || ((_changedTouches$2 = event.changedTouches[0]) == null ? void 0 : _changedTouches$2.clientY);
|
|
33
39
|
dragRef.current = {
|
|
34
|
-
height:
|
|
40
|
+
height: heightRef.current,
|
|
35
41
|
dragY: clientY
|
|
36
42
|
};
|
|
37
43
|
document.addEventListener('mousemove', handleMouseMove);
|
|
@@ -74,5 +80,4 @@ var DragBar = props => {
|
|
|
74
80
|
children: svg
|
|
75
81
|
});
|
|
76
82
|
};
|
|
77
|
-
export default DragBar;
|
|
78
|
-
//# sourceMappingURL=index.js.map
|
|
83
|
+
export default DragBar;
|
|
@@ -4,7 +4,7 @@ import { TextAreaProps } from './Textarea';
|
|
|
4
4
|
import { IProps } from '../../Editor';
|
|
5
5
|
import { TextAreaCommandOrchestrator, ICommand } from '../../commands';
|
|
6
6
|
import './index.less';
|
|
7
|
-
|
|
7
|
+
type RenderTextareaHandle = {
|
|
8
8
|
dispatch: ContextStore['dispatch'];
|
|
9
9
|
onChange?: TextAreaProps['onChange'];
|
|
10
10
|
useContext?: {
|
|
@@ -19,7 +19,7 @@ export interface ITextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTe
|
|
|
19
19
|
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
20
20
|
renderTextarea?: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>, opts: RenderTextareaHandle) => JSX.Element;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export type TextAreaRef = {
|
|
23
23
|
text?: HTMLTextAreaElement;
|
|
24
24
|
warp?: HTMLDivElement;
|
|
25
25
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ICommand, TextAreaCommandOrchestrator } from '../../commands';
|
|
2
3
|
import { ContextStore, ExecuteCommandState } from '../../Context';
|
|
3
4
|
export default function shortcutsHandle(e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands?: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState): void;
|
package/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|
package/lib/Context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ICommand, TextAreaCommandOrchestrator } from './commands';
|
|
3
3
|
import { MDEditorProps } from './Editor';
|
|
4
|
-
export
|
|
4
|
+
export type PreviewType = 'live' | 'edit' | 'preview';
|
|
5
5
|
export interface ContextStore {
|
|
6
6
|
components?: MDEditorProps['components'];
|
|
7
7
|
commands?: ICommand<string>[];
|
|
@@ -24,7 +24,7 @@ export interface ContextStore {
|
|
|
24
24
|
tabSize?: number;
|
|
25
25
|
defaultTabEnable?: boolean;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type ExecuteCommandState = Pick<ContextStore, 'fullscreen' | 'preview' | 'highlightEnable'>;
|
|
28
28
|
export declare function reducer(state: ContextStore, action: ContextStore): {
|
|
29
29
|
components?: {
|
|
30
30
|
textarea?: ((props: React.HTMLAttributes<HTMLDivElement> | React.TextareaHTMLAttributes<HTMLTextAreaElement>, opts: {
|
|
@@ -35,7 +35,7 @@ export declare function reducer(state: ContextStore, action: ContextStore): {
|
|
|
35
35
|
extraCommands: ICommand<string>[] | undefined;
|
|
36
36
|
commandOrchestrator?: TextAreaCommandOrchestrator | undefined;
|
|
37
37
|
} | undefined;
|
|
38
|
-
shortcuts?: ((e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand
|
|
38
|
+
shortcuts?: ((e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator | undefined, dispatch?: React.Dispatch<ContextStore> | undefined, state?: ExecuteCommandState | undefined) => void) | undefined;
|
|
39
39
|
}) => JSX.Element) | undefined;
|
|
40
40
|
toolbar?: ((command: ICommand<string>, disabled: boolean, executeCommand: (command: ICommand<string>, name?: string | undefined) => void, index: number) => void | React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined) | undefined;
|
|
41
41
|
preview?: ((source: string, state: ContextStore, dispath: React.Dispatch<ContextStore>) => JSX.Element) | undefined;
|
package/lib/Context.js
CHANGED
package/lib/Editor.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
141
141
|
}
|
|
142
142
|
export interface RefMDEditor extends ContextStore {
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
type Editor = React.FC<PropsWithRef<MDEditorProps>> & {
|
|
145
145
|
Markdown: typeof MarkdownPreview;
|
|
146
146
|
};
|
|
147
147
|
declare const mdEditor: Editor;
|
package/lib/Editor.js
CHANGED
|
@@ -166,6 +166,18 @@ var InternalMDEditor = function InternalMDEditor(props, ref) {
|
|
|
166
166
|
(0, _react.useMemo)(function () {
|
|
167
167
|
return height !== state.height && onHeightChange && onHeightChange(state.height, height, state);
|
|
168
168
|
}, [height, onHeightChange, state]);
|
|
169
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
|
+
(0, _react.useMemo)(function () {
|
|
171
|
+
return commands !== state.commands && dispatch({
|
|
172
|
+
commands: cmds
|
|
173
|
+
});
|
|
174
|
+
}, [props.commands]);
|
|
175
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
176
|
+
(0, _react.useMemo)(function () {
|
|
177
|
+
return extraCommands !== state.extraCommands && dispatch({
|
|
178
|
+
extraCommands: extraCmds
|
|
179
|
+
});
|
|
180
|
+
}, [props.extraCommands]);
|
|
169
181
|
var textareaDomRef = (0, _react.useRef)();
|
|
170
182
|
var active = (0, _react.useRef)('preview');
|
|
171
183
|
var initScroll = (0, _react.useRef)(false);
|
|
@@ -293,5 +305,4 @@ var mdEditor = /*#__PURE__*/_react["default"].forwardRef(InternalMDEditor);
|
|
|
293
305
|
mdEditor.Markdown = _reactMarkdownPreview["default"];
|
|
294
306
|
var _default = mdEditor;
|
|
295
307
|
exports["default"] = _default;
|
|
296
|
-
module.exports = exports.default;
|
|
297
|
-
//# sourceMappingURL=Editor.js.map
|
|
308
|
+
module.exports = exports.default;
|
package/lib/commands/bold.js
CHANGED
package/lib/commands/code.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.codeBlock = exports.code = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var code = {
|
|
@@ -100,5 +100,4 @@ var codeBlock = {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
exports.codeBlock = codeBlock;
|
|
104
|
-
//# sourceMappingURL=code.js.map
|
|
103
|
+
exports.codeBlock = codeBlock;
|