@uiw/react-md-editor 4.0.11 → 4.1.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 +91 -35
- package/common.d.ts +17 -0
- package/dist/mdeditor.css +105 -110
- package/dist/mdeditor.js +3280 -4534
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/dist/mdeditor.min.js.LICENSE.txt +2 -2
- package/esm/Editor.common.d.ts +5 -0
- package/esm/Editor.common.js +7 -0
- package/esm/Editor.d.ts +4 -11
- package/esm/Editor.factory.d.ts +14 -0
- package/esm/Editor.factory.js +285 -0
- package/esm/Editor.js +5 -261
- package/esm/Editor.nohighlight.d.ts +4 -11
- package/esm/Editor.nohighlight.js +5 -261
- package/esm/commands/list.js +3 -4
- package/esm/commands/title.js +5 -6
- package/esm/components/DragBar/index.js +3 -4
- package/esm/components/TextArea/Markdown.common.d.ts +5 -0
- package/esm/components/TextArea/Markdown.common.js +57 -0
- package/esm/components/TextArea/Markdown.js +6 -8
- package/esm/components/TextArea/Textarea.js +13 -17
- package/esm/components/TextArea/factory.d.ts +33 -0
- package/esm/components/TextArea/factory.js +102 -0
- package/esm/components/TextArea/index.common.d.ts +3 -0
- package/esm/components/TextArea/index.common.js +6 -0
- package/esm/components/TextArea/index.d.ts +3 -27
- package/esm/components/TextArea/index.js +5 -100
- package/esm/components/TextArea/index.nohighlight.d.ts +3 -27
- package/esm/components/TextArea/index.nohighlight.js +2 -93
- package/esm/components/Toolbar/Child.js +8 -9
- package/esm/components/Toolbar/index.js +22 -28
- package/esm/index.common.d.ts +16 -0
- package/esm/index.common.js +16 -0
- package/esm/react-markdown-preview.common.d.ts +4 -0
- package/esm/utils/markdownUtils.js +13 -17
- package/lib/Editor.common.d.ts +5 -0
- package/lib/Editor.common.js +15 -0
- package/lib/Editor.d.ts +4 -11
- package/lib/Editor.factory.d.ts +14 -0
- package/lib/Editor.factory.js +333 -0
- package/lib/Editor.js +4 -318
- package/lib/Editor.nohighlight.d.ts +4 -11
- package/lib/Editor.nohighlight.js +4 -318
- package/lib/components/TextArea/Markdown.common.d.ts +5 -0
- package/lib/components/TextArea/Markdown.common.js +68 -0
- package/lib/components/TextArea/factory.d.ts +33 -0
- package/lib/components/TextArea/factory.js +109 -0
- package/lib/components/TextArea/index.common.d.ts +3 -0
- package/lib/components/TextArea/index.common.js +14 -0
- package/lib/components/TextArea/index.d.ts +3 -27
- package/lib/components/TextArea/index.js +6 -98
- package/lib/components/TextArea/index.nohighlight.d.ts +3 -27
- package/lib/components/TextArea/index.nohighlight.js +3 -92
- package/lib/index.common.d.ts +16 -0
- package/lib/index.common.js +123 -0
- package/lib/react-markdown-preview.common.d.ts +4 -0
- package/package.json +8 -2
- package/src/Editor.common.tsx +7 -0
- package/src/Editor.factory.tsx +286 -0
- package/src/Editor.nohighlight.tsx +3 -271
- package/src/Editor.tsx +3 -271
- package/src/components/TextArea/Markdown.common.tsx +49 -0
- package/src/components/TextArea/factory.tsx +120 -0
- package/src/components/TextArea/index.common.tsx +6 -0
- package/src/components/TextArea/index.nohighlight.tsx +3 -108
- package/src/components/TextArea/index.tsx +3 -110
- package/src/index.common.tsx +19 -0
- package/src/react-markdown-preview.common.d.ts +4 -0
|
@@ -1,101 +1,6 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["prefixCls", "className", "onScroll", "renderTextarea"];
|
|
4
|
-
import React, { useEffect, Fragment, useContext } from 'react';
|
|
5
|
-
import { EditorContext } from "../../Context.js";
|
|
6
|
-
import shortcuts from "./shortcuts.js";
|
|
7
1
|
import Markdown from "./Markdown.js";
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _ref = props || {},
|
|
14
|
-
{
|
|
15
|
-
prefixCls,
|
|
16
|
-
className,
|
|
17
|
-
onScroll,
|
|
18
|
-
renderTextarea
|
|
19
|
-
} = _ref,
|
|
20
|
-
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
21
|
-
var {
|
|
22
|
-
markdown,
|
|
23
|
-
scrollTop,
|
|
24
|
-
commands,
|
|
25
|
-
minHeight,
|
|
26
|
-
highlightEnable,
|
|
27
|
-
extraCommands,
|
|
28
|
-
dispatch
|
|
29
|
-
} = useContext(EditorContext);
|
|
30
|
-
var textRef = React.useRef(null);
|
|
31
|
-
var executeRef = React.useRef();
|
|
32
|
-
var warp = /*#__PURE__*/React.createRef();
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
var state = {};
|
|
35
|
-
if (warp.current) {
|
|
36
|
-
state.textareaWarp = warp.current || undefined;
|
|
37
|
-
warp.current.scrollTop = scrollTop || 0;
|
|
38
|
-
}
|
|
39
|
-
if (dispatch) {
|
|
40
|
-
dispatch(_extends({}, state));
|
|
41
|
-
}
|
|
42
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
-
}, []);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (textRef.current && dispatch) {
|
|
46
|
-
var commandOrchestrator = new TextAreaCommandOrchestrator(textRef.current);
|
|
47
|
-
executeRef.current = commandOrchestrator;
|
|
48
|
-
dispatch({
|
|
49
|
-
textarea: textRef.current,
|
|
50
|
-
commandOrchestrator
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
-
}, []);
|
|
55
|
-
var textStyle = highlightEnable ? {} : {
|
|
56
|
-
WebkitTextFillColor: 'initial',
|
|
57
|
-
overflow: 'auto'
|
|
58
|
-
};
|
|
59
|
-
return /*#__PURE__*/_jsx("div", {
|
|
60
|
-
ref: warp,
|
|
61
|
-
className: prefixCls + "-area " + (className || ''),
|
|
62
|
-
onScroll: onScroll,
|
|
63
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
64
|
-
className: prefixCls + "-text",
|
|
65
|
-
style: {
|
|
66
|
-
minHeight
|
|
67
|
-
},
|
|
68
|
-
children: renderTextarea ? (/*#__PURE__*/React.cloneElement(renderTextarea(_extends({}, otherProps, {
|
|
69
|
-
value: markdown,
|
|
70
|
-
autoComplete: 'off',
|
|
71
|
-
autoCorrect: 'off',
|
|
72
|
-
spellCheck: 'false',
|
|
73
|
-
autoCapitalize: 'off',
|
|
74
|
-
className: prefixCls + "-text-input",
|
|
75
|
-
style: {
|
|
76
|
-
WebkitTextFillColor: 'inherit',
|
|
77
|
-
overflow: 'auto'
|
|
78
|
-
}
|
|
79
|
-
}), {
|
|
80
|
-
dispatch,
|
|
81
|
-
onChange: otherProps.onChange,
|
|
82
|
-
shortcuts,
|
|
83
|
-
useContext: {
|
|
84
|
-
commands,
|
|
85
|
-
extraCommands,
|
|
86
|
-
commandOrchestrator: executeRef.current
|
|
87
|
-
}
|
|
88
|
-
}), {
|
|
89
|
-
ref: textRef
|
|
90
|
-
})) : /*#__PURE__*/_jsxs(Fragment, {
|
|
91
|
-
children: [highlightEnable && /*#__PURE__*/_jsx(Markdown, {
|
|
92
|
-
prefixCls: prefixCls
|
|
93
|
-
}), /*#__PURE__*/_jsx(Textarea, _extends({
|
|
94
|
-
prefixCls: prefixCls
|
|
95
|
-
}, otherProps, {
|
|
96
|
-
style: textStyle
|
|
97
|
-
}))]
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
});
|
|
101
|
-
}
|
|
2
|
+
import { createTextArea } from "./factory.js";
|
|
3
|
+
export default createTextArea({
|
|
4
|
+
Markdown,
|
|
5
|
+
useMinHeight: true
|
|
6
|
+
});
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { type IProps } from '../../Types';
|
|
5
|
-
import { TextAreaCommandOrchestrator, type ICommand } from '../../commands/';
|
|
6
|
-
import './index.less';
|
|
7
|
-
type RenderTextareaHandle = {
|
|
8
|
-
dispatch: ContextStore['dispatch'];
|
|
9
|
-
onChange?: TextAreaProps['onChange'];
|
|
10
|
-
useContext?: {
|
|
11
|
-
commands: ContextStore['commands'];
|
|
12
|
-
extraCommands: ContextStore['extraCommands'];
|
|
13
|
-
commandOrchestrator?: TextAreaCommandOrchestrator;
|
|
14
|
-
};
|
|
15
|
-
shortcuts?: (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState) => void;
|
|
16
|
-
};
|
|
17
|
-
export interface ITextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>, IProps {
|
|
18
|
-
value?: string;
|
|
19
|
-
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
20
|
-
renderTextarea?: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>, opts: RenderTextareaHandle) => JSX.Element;
|
|
21
|
-
}
|
|
22
|
-
export type TextAreaRef = {
|
|
23
|
-
text?: HTMLTextAreaElement;
|
|
24
|
-
warp?: HTMLDivElement;
|
|
25
|
-
};
|
|
26
|
-
export default function TextArea(props: ITextAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export {};
|
|
1
|
+
export type { ITextAreaProps, RenderTextareaHandle, TextAreaRef } from './factory';
|
|
2
|
+
declare const _default: (props: import("./factory").ITextAreaProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default _default;
|
|
@@ -1,93 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
var _excluded = ["prefixCls", "className", "onScroll", "renderTextarea"];
|
|
4
|
-
import React, { useEffect, Fragment, useContext } from 'react';
|
|
5
|
-
import { EditorContext } from "../../Context.js";
|
|
6
|
-
import shortcuts from "./shortcuts.js";
|
|
7
|
-
import Textarea from "./Textarea.js";
|
|
8
|
-
import { TextAreaCommandOrchestrator } from "../../commands/index.js";
|
|
9
|
-
import "./index.css";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
export default function TextArea(props) {
|
|
12
|
-
var _ref = props || {},
|
|
13
|
-
{
|
|
14
|
-
prefixCls,
|
|
15
|
-
className,
|
|
16
|
-
onScroll,
|
|
17
|
-
renderTextarea
|
|
18
|
-
} = _ref,
|
|
19
|
-
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
20
|
-
var {
|
|
21
|
-
markdown,
|
|
22
|
-
scrollTop,
|
|
23
|
-
commands,
|
|
24
|
-
extraCommands,
|
|
25
|
-
dispatch
|
|
26
|
-
} = useContext(EditorContext);
|
|
27
|
-
var textRef = React.useRef(null);
|
|
28
|
-
var executeRef = React.useRef();
|
|
29
|
-
var warp = /*#__PURE__*/React.createRef();
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
var state = {};
|
|
32
|
-
if (warp.current) {
|
|
33
|
-
state.textareaWarp = warp.current || undefined;
|
|
34
|
-
warp.current.scrollTop = scrollTop || 0;
|
|
35
|
-
}
|
|
36
|
-
if (dispatch) {
|
|
37
|
-
dispatch(_extends({}, state));
|
|
38
|
-
}
|
|
39
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
-
}, []);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (textRef.current && dispatch) {
|
|
43
|
-
var commandOrchestrator = new TextAreaCommandOrchestrator(textRef.current);
|
|
44
|
-
executeRef.current = commandOrchestrator;
|
|
45
|
-
dispatch({
|
|
46
|
-
textarea: textRef.current,
|
|
47
|
-
commandOrchestrator
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
-
}, []);
|
|
52
|
-
var textStyle = {
|
|
53
|
-
WebkitTextFillColor: 'initial',
|
|
54
|
-
overflow: 'auto'
|
|
55
|
-
};
|
|
56
|
-
return /*#__PURE__*/_jsx("div", {
|
|
57
|
-
ref: warp,
|
|
58
|
-
className: prefixCls + "-area " + (className || ''),
|
|
59
|
-
onScroll: onScroll,
|
|
60
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
61
|
-
className: prefixCls + "-text",
|
|
62
|
-
children: renderTextarea ? (/*#__PURE__*/React.cloneElement(renderTextarea(_extends({}, otherProps, {
|
|
63
|
-
value: markdown,
|
|
64
|
-
autoComplete: 'off',
|
|
65
|
-
autoCorrect: 'off',
|
|
66
|
-
spellCheck: 'false',
|
|
67
|
-
autoCapitalize: 'off',
|
|
68
|
-
className: prefixCls + "-text-input",
|
|
69
|
-
style: {
|
|
70
|
-
WebkitTextFillColor: 'inherit',
|
|
71
|
-
overflow: 'auto'
|
|
72
|
-
}
|
|
73
|
-
}), {
|
|
74
|
-
dispatch,
|
|
75
|
-
onChange: otherProps.onChange,
|
|
76
|
-
shortcuts,
|
|
77
|
-
useContext: {
|
|
78
|
-
commands,
|
|
79
|
-
extraCommands,
|
|
80
|
-
commandOrchestrator: executeRef.current
|
|
81
|
-
}
|
|
82
|
-
}), {
|
|
83
|
-
ref: textRef
|
|
84
|
-
})) : /*#__PURE__*/_jsx(Fragment, {
|
|
85
|
-
children: /*#__PURE__*/_jsx(Textarea, _extends({
|
|
86
|
-
prefixCls: prefixCls
|
|
87
|
-
}, otherProps, {
|
|
88
|
-
style: textStyle
|
|
89
|
-
}))
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
});
|
|
93
|
-
}
|
|
1
|
+
import { createTextArea } from "./factory.js";
|
|
2
|
+
export default createTextArea();
|
|
@@ -5,15 +5,14 @@ import Toolbar from "./index.js";
|
|
|
5
5
|
import { EditorContext } from "../../Context.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export default function Child(props) {
|
|
8
|
-
var {
|
|
9
|
-
prefixCls,
|
|
10
|
-
groupName,
|
|
11
|
-
commands,
|
|
12
|
-
children
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
barPopup = {}
|
|
16
|
-
} = useContext(EditorContext);
|
|
8
|
+
var _ref = props || {},
|
|
9
|
+
prefixCls = _ref.prefixCls,
|
|
10
|
+
groupName = _ref.groupName,
|
|
11
|
+
commands = _ref.commands,
|
|
12
|
+
children = _ref.children;
|
|
13
|
+
var _useContext = useContext(EditorContext),
|
|
14
|
+
_useContext$barPopup = _useContext.barPopup,
|
|
15
|
+
barPopup = _useContext$barPopup === void 0 ? {} : _useContext$barPopup;
|
|
17
16
|
return useMemo(() => /*#__PURE__*/_jsx("div", {
|
|
18
17
|
className: prefixCls + "-toolbar-child " + (groupName && barPopup[groupName] ? 'active' : ''),
|
|
19
18
|
onClick: e => e.stopPropagation(),
|
|
@@ -5,18 +5,16 @@ import Child from "./Child.js";
|
|
|
5
5
|
import "./index.css";
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
export function ToolbarItems(props) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
dispatch
|
|
19
|
-
} = useContext(EditorContext);
|
|
8
|
+
var prefixCls = props.prefixCls,
|
|
9
|
+
overflow = props.overflow;
|
|
10
|
+
var _useContext = useContext(EditorContext),
|
|
11
|
+
fullscreen = _useContext.fullscreen,
|
|
12
|
+
preview = _useContext.preview,
|
|
13
|
+
_useContext$barPopup = _useContext.barPopup,
|
|
14
|
+
barPopup = _useContext$barPopup === void 0 ? {} : _useContext$barPopup,
|
|
15
|
+
components = _useContext.components,
|
|
16
|
+
commandOrchestrator = _useContext.commandOrchestrator,
|
|
17
|
+
dispatch = _useContext.dispatch;
|
|
20
18
|
var originalOverflow = useRef('');
|
|
21
19
|
function handleClick(command, name) {
|
|
22
20
|
if (!dispatch) return;
|
|
@@ -110,15 +108,13 @@ export default function Toolbar(props) {
|
|
|
110
108
|
if (props === void 0) {
|
|
111
109
|
props = {};
|
|
112
110
|
}
|
|
113
|
-
var
|
|
114
|
-
prefixCls,
|
|
115
|
-
isChild,
|
|
116
|
-
className
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
extraCommands
|
|
121
|
-
} = useContext(EditorContext);
|
|
111
|
+
var _props = props,
|
|
112
|
+
prefixCls = _props.prefixCls,
|
|
113
|
+
isChild = _props.isChild,
|
|
114
|
+
className = _props.className;
|
|
115
|
+
var _useContext2 = useContext(EditorContext),
|
|
116
|
+
commands = _useContext2.commands,
|
|
117
|
+
extraCommands = _useContext2.extraCommands;
|
|
122
118
|
return /*#__PURE__*/_jsxs("div", {
|
|
123
119
|
className: prefixCls + "-toolbar " + className,
|
|
124
120
|
children: [/*#__PURE__*/_jsx(ToolbarItems, _extends({}, props, {
|
|
@@ -129,13 +125,11 @@ export default function Toolbar(props) {
|
|
|
129
125
|
});
|
|
130
126
|
}
|
|
131
127
|
export function ToolbarVisibility(props) {
|
|
132
|
-
var
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
prefixCls
|
|
138
|
-
} = props;
|
|
128
|
+
var hideToolbar = props.hideToolbar,
|
|
129
|
+
toolbarBottom = props.toolbarBottom,
|
|
130
|
+
placement = props.placement,
|
|
131
|
+
overflow = props.overflow,
|
|
132
|
+
prefixCls = props.prefixCls;
|
|
139
133
|
if (hideToolbar || placement === 'bottom' && !toolbarBottom || placement === 'top' && toolbarBottom) {
|
|
140
134
|
return null;
|
|
141
135
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MDEditor from './Editor.common';
|
|
2
|
+
import * as commands from './commands/';
|
|
3
|
+
import * as MarkdownUtil from './utils/markdownUtils';
|
|
4
|
+
import './index.less';
|
|
5
|
+
export { headingExecute } from './commands/title';
|
|
6
|
+
export * from './commands/';
|
|
7
|
+
export * from './commands/group';
|
|
8
|
+
export * from './utils/markdownUtils';
|
|
9
|
+
export * from './utils/InsertTextAtPosition';
|
|
10
|
+
export * from './Editor.common';
|
|
11
|
+
export * from './Context';
|
|
12
|
+
export * from './Types';
|
|
13
|
+
export { default as handleKeyDown } from './components/TextArea/handleKeyDown';
|
|
14
|
+
export { default as shortcuts } from './components/TextArea/shortcuts';
|
|
15
|
+
export { MarkdownUtil, commands };
|
|
16
|
+
export default MDEditor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MDEditor from './Editor.common';
|
|
2
|
+
import * as commands from "./commands/index.js";
|
|
3
|
+
import * as MarkdownUtil from "./utils/markdownUtils.js";
|
|
4
|
+
import "./index.css";
|
|
5
|
+
export { headingExecute } from "./commands/title.js";
|
|
6
|
+
export * from "./commands/index.js";
|
|
7
|
+
export * from "./commands/group.js";
|
|
8
|
+
export * from "./utils/markdownUtils.js";
|
|
9
|
+
export * from "./utils/InsertTextAtPosition.js";
|
|
10
|
+
export * from './Editor.common';
|
|
11
|
+
export * from "./Context.js";
|
|
12
|
+
export * from "./Types.js";
|
|
13
|
+
export { default as handleKeyDown } from "./components/TextArea/handleKeyDown.js";
|
|
14
|
+
export { default as shortcuts } from "./components/TextArea/shortcuts.js";
|
|
15
|
+
export { MarkdownUtil, commands };
|
|
16
|
+
export default MDEditor;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export function selectWord(_ref) {
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
suffix = prefix
|
|
7
|
-
} = _ref;
|
|
2
|
+
var text = _ref.text,
|
|
3
|
+
selection = _ref.selection,
|
|
4
|
+
prefix = _ref.prefix,
|
|
5
|
+
_ref$suffix = _ref.suffix,
|
|
6
|
+
suffix = _ref$suffix === void 0 ? prefix : _ref$suffix;
|
|
8
7
|
var result = selection;
|
|
9
8
|
if (text && text.length && selection.start === selection.end) {
|
|
10
9
|
result = getSurroundingWord(text, selection.start);
|
|
@@ -21,10 +20,8 @@ export function selectWord(_ref) {
|
|
|
21
20
|
return result;
|
|
22
21
|
}
|
|
23
22
|
export function selectLine(_ref2) {
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
selection
|
|
27
|
-
} = _ref2;
|
|
23
|
+
var text = _ref2.text,
|
|
24
|
+
selection = _ref2.selection;
|
|
28
25
|
var start = text.slice(0, selection.start).lastIndexOf('\n') + 1;
|
|
29
26
|
var end = text.slice(selection.end).indexOf('\n') + selection.end;
|
|
30
27
|
if (end === selection.end - 1) {
|
|
@@ -133,13 +130,12 @@ export function getSurroundingWord(text, position) {
|
|
|
133
130
|
};
|
|
134
131
|
}
|
|
135
132
|
export function executeCommand(_ref3) {
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
suffix = prefix
|
|
142
|
-
} = _ref3;
|
|
133
|
+
var api = _ref3.api,
|
|
134
|
+
selectedText = _ref3.selectedText,
|
|
135
|
+
selection = _ref3.selection,
|
|
136
|
+
prefix = _ref3.prefix,
|
|
137
|
+
_ref3$suffix = _ref3.suffix,
|
|
138
|
+
suffix = _ref3$suffix === void 0 ? prefix : _ref3$suffix;
|
|
143
139
|
if (selectedText.length >= prefix.length + suffix.length && selectedText.startsWith(prefix) && selectedText.endsWith(suffix)) {
|
|
144
140
|
api.replaceSelection(selectedText.slice(prefix.length, suffix.length ? -suffix.length : undefined));
|
|
145
141
|
api.setSelectionRange({
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { RefMDEditor } from './Editor.factory';
|
|
2
|
+
declare const _default: import("react").ForwardRefExoticComponent<import("./Types").MDEditorProps & import("react").RefAttributes<import("./Editor.factory").RefMDEditor>> & {
|
|
3
|
+
Markdown: import("react").ForwardRefExoticComponent<import("@uiw/react-markdown-preview/common").MarkdownPreviewProps & import("react").RefAttributes<import("@uiw/react-markdown-preview/common").MarkdownPreviewRef>>;
|
|
4
|
+
};
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _common = _interopRequireDefault(require("@uiw/react-markdown-preview/common"));
|
|
9
|
+
var _index = _interopRequireDefault(require("./components/TextArea/index.common"));
|
|
10
|
+
var _Editor = require("./Editor.factory");
|
|
11
|
+
var _default = exports["default"] = (0, _Editor.createMDEditor)({
|
|
12
|
+
MarkdownPreview: _common["default"],
|
|
13
|
+
TextArea: _index["default"]
|
|
14
|
+
});
|
|
15
|
+
module.exports = exports.default;
|
package/lib/Editor.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type { MDEditorProps } from './Types';
|
|
5
|
-
export interface RefMDEditor extends ContextStore {
|
|
6
|
-
}
|
|
7
|
-
declare const InternalMDEditor: React.ForwardRefExoticComponent<MDEditorProps & React.RefAttributes<RefMDEditor>>;
|
|
8
|
-
type EditorComponent = typeof InternalMDEditor & {
|
|
9
|
-
Markdown: typeof MarkdownPreview;
|
|
1
|
+
export type { RefMDEditor } from './Editor.factory';
|
|
2
|
+
declare const _default: import("react").ForwardRefExoticComponent<import("./Types").MDEditorProps & import("react").RefAttributes<import("./Editor.factory").RefMDEditor>> & {
|
|
3
|
+
Markdown: import("react").ForwardRefExoticComponent<import("@uiw/react-markdown-preview").MarkdownPreviewProps & import("react").RefAttributes<import("@uiw/react-markdown-preview").MarkdownPreviewRef>>;
|
|
10
4
|
};
|
|
11
|
-
|
|
12
|
-
export default Editor;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ContextStore } from './Context';
|
|
3
|
+
import type { MDEditorProps } from './Types';
|
|
4
|
+
export interface RefMDEditor extends ContextStore {
|
|
5
|
+
}
|
|
6
|
+
type PreviewComponent = React.ComponentType<any>;
|
|
7
|
+
type TextAreaComponent = React.ComponentType<any>;
|
|
8
|
+
export declare function createMDEditor<TMarkdownPreview extends PreviewComponent, TTextArea extends TextAreaComponent>(options: {
|
|
9
|
+
MarkdownPreview: TMarkdownPreview;
|
|
10
|
+
TextArea: TTextArea;
|
|
11
|
+
}): React.ForwardRefExoticComponent<MDEditorProps & React.RefAttributes<RefMDEditor>> & {
|
|
12
|
+
Markdown: TMarkdownPreview;
|
|
13
|
+
};
|
|
14
|
+
export {};
|